Electron 打包
This commit is contained in:
parent
28981248cf
commit
7b2b67564c
@ -1,11 +1,12 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE = 若依管理系统
|
||||
VITE_APP_TITLE = 伊特机械MES
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV = 'production'
|
||||
|
||||
# 若依管理系统/生产环境
|
||||
#VITE_APP_BASE_API = '/prod-api'
|
||||
VITE_APP_BASE_API = 'https://api.evo-techina.com'
|
||||
# VITE_APP_BASE_API = 'https://api.evo-techina.com'
|
||||
VITE_APP_BASE_API = 'http://192.168.6.107:8888/api'
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
36
electron/main.cjs
Normal file
36
electron/main.cjs
Normal file
@ -0,0 +1,36 @@
|
||||
const { app, BrowserWindow, Menu } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
Menu.setApplicationMenu(null)
|
||||
|
||||
let mainWin = null
|
||||
function createWindow() {
|
||||
mainWin = new BrowserWindow({
|
||||
width: 1400,
|
||||
height: 900,
|
||||
title: "伊特机械MES",
|
||||
//关键配置,隐藏顶部File/Edit菜单栏
|
||||
autoHideMenBar: true,//按ALTE可临时调出
|
||||
menu: null,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
})
|
||||
|
||||
// 区分 本地开发 / 打包exe 两种环境
|
||||
if (app.isPackaged) {
|
||||
// 打包后:读取 asar 内部资源,不能走磁盘本地路径
|
||||
mainWin.loadFile(path.join(__dirname, "../dist/index.html"))
|
||||
} else {
|
||||
// 本地 npm run electron:dev 预览
|
||||
mainWin.loadFile(path.join(__dirname, "../dist/index.html"))
|
||||
// 开发时自动打开调试面板
|
||||
mainWin.webContents.openDevTools()
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow)
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
23
package.json
23
package.json
@ -3,11 +3,14 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "electron/main.cjs",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"postinstall": "node scripts/copy-draco.js"
|
||||
"postinstall": "node scripts/copy-draco.js",
|
||||
"electron:dev": "npm run build && electron .",
|
||||
"electron:build": "npm run build && electron-builder"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vicons/ionicons5": "^0.12.0",
|
||||
@ -30,9 +33,27 @@
|
||||
"@types/node": "^20.11.5",
|
||||
"@types/three": "^0.184.1",
|
||||
"@vitejs/plugin-vue": "^5.0.3",
|
||||
"electron": "^42.5.0",
|
||||
"electron-builder": "^26.15.3",
|
||||
"sass": "^1.70.0",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.11",
|
||||
"vue-tsc": "^1.8.27"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.mes.viewer",
|
||||
"productName": "伊特机械MES",
|
||||
"win": {
|
||||
"target": "nsis"
|
||||
},
|
||||
"asar": true,
|
||||
"files": [
|
||||
"electron/**/*",
|
||||
"dist/**/*"
|
||||
],
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
"allowToChangeInstallationDirectory": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const BASE_API = import.meta.env.VITE_APP_BASE_API
|
||||
|
||||
// API响应结构
|
||||
interface ApiResponse<T = any> {
|
||||
code: number
|
||||
@ -114,7 +116,8 @@ async function decryptResponseData(data: string): Promise<any> {
|
||||
// 创建axios实例
|
||||
// 后端 API 统一使用 /api 前缀
|
||||
const service: AxiosInstance = axios.create({
|
||||
baseURL: '/api',
|
||||
// baseURL:'/api',
|
||||
baseURL: BASE_API,
|
||||
timeout: 30000
|
||||
})
|
||||
|
||||
@ -151,6 +154,12 @@ service.interceptors.response.use(
|
||||
return response.data
|
||||
}
|
||||
|
||||
if (response.config.responseType === 'arraybuffer') {
|
||||
// 二进制流不走code校验,直接完整返回ArrayBuffer
|
||||
return response.data
|
||||
}
|
||||
|
||||
|
||||
const res = response.data
|
||||
|
||||
if (res.code !== 200) {
|
||||
|
||||
@ -253,8 +253,8 @@ import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline,
|
||||
import { concessionApplyApi, DetailModel, type ConcessionApply } from '@/api/concessionApply'
|
||||
import { dictDataApi } from '@/api/org'
|
||||
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
// import html2canvas from 'html2canvas'
|
||||
// import { jsPDF } from 'jspdf'
|
||||
import * as dd from 'dingtalk-jsapi';
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user