diff --git a/.env.production b/.env.production index c9256cd..a2c524a 100644 --- a/.env.production +++ b/.env.production @@ -2,4 +2,4 @@ ENV = production # 线上环境接口地址 -VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/' \ No newline at end of file +VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/api/' \ No newline at end of file diff --git a/.gitignore b/.gitignore index cce5b04..c30169e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ lerna-debug.log* node_modules release -dist-electron dist dist-ssr diff --git a/dist-electron/main.js b/dist-electron/main.js index fb3d5a9..49faa13 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -1,6 +1,6 @@ "use strict"; const electron = require("electron"); -const path$1 = require("path"); +const path = require("path"); function printUtils(params) { return new Promise(async (resolvePrint, rejectPrint) => { let subMainWindow = new electron.BrowserWindow({ @@ -13,7 +13,7 @@ function printUtils(params) { enableRemoteModule: true } }); - subMainWindow.loadFile(path$1.join(__dirname, "../public/print.html")); + subMainWindow.loadFile(path.join(__dirname, "../public/print.html")); subMainWindow.webContents.on("did-finish-load", async (res) => { subMainWindow.webContents.openDevTools(); console.log("网页加载完成", res); @@ -28,16 +28,15 @@ function printUtils(params) { }); }); } -const NODE_ENV = process.env.NODE_ENV; electron.app.whenReady().then(() => { const win = new electron.BrowserWindow({ title: "银收客", width: 1200, height: 800, fullscreenable: true, - fullscreen: true, + fullscreen: false, simpleFullscreen: true, - frame: false, + frame: true, webPreferences: { // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 nodeIntegration: true, @@ -47,11 +46,9 @@ electron.app.whenReady().then(() => { if (process.env.VITE_DEV_SERVER_URL) { win.loadURL(process.env.VITE_DEV_SERVER_URL); } else { - win.loadFile(path.join(__dirname, "../dist/index.html")); - } - if (NODE_ENV == "development") { - win.webContents.openDevTools(); + win.loadFile(path.resolve(__dirname, "../dist/index.html")); } + win.webContents.openDevTools(); electron.app.on("activate", () => { if (electron.BrowserWindow.getAllWindows().length === 0) { createWindow(); diff --git a/electron/main.js b/electron/main.js index bb05ed3..50313f8 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1,17 +1,16 @@ import { app, BrowserWindow, ipcMain } from "electron"; +import path from 'path' import { printUtils } from './printUtils' -const NODE_ENV = process.env.NODE_ENV - app.whenReady().then(() => { const win = new BrowserWindow({ title: "银收客", width: 1200, height: 800, fullscreenable: true, - fullscreen: true, + fullscreen: false, simpleFullscreen: true, - frame: false, + frame: true, webPreferences: { // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 nodeIntegration: true, @@ -21,14 +20,12 @@ app.whenReady().then(() => { // You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve` if (process.env.VITE_DEV_SERVER_URL) { - win.loadURL(process.env.VITE_DEV_SERVER_URL); // 使用vite开发服务的url路径访问应用 + win.loadURL(process.env.VITE_DEV_SERVER_URL); + // 使用vite开发服务的url路径访问应用 } else { - win.loadFile(path.join(__dirname, '../dist/index.html')); // 打包后使用文件路径访问应用 - } - - if (NODE_ENV == 'development') { - win.webContents.openDevTools(); + win.loadFile(path.resolve(__dirname, '../dist/index.html')); // 打包后使用文件路径访问应用 } + win.webContents.openDevTools(); app.on("activate", () => { // 在 macOS 系统内, 如果没有已开启的应用窗口 diff --git a/package.json b/package.json index 29ef93b..26fa836 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "chcp 65001 && vite", "build": "vite build && electron-builder", - "preview": "vite preview" + "preview": "vite preview", + "build:win": "vite build && electron-builder --w" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", @@ -31,27 +32,37 @@ "vite-plugin-electron-renderer": "^0.14.5" }, "build": { - "appId": "com.example.app", + "appId": "com.cashierdesktop.app", "productName": "cashier_desktop", "asar": true, + "files": [ + "./dist/**/*", + "./dist-electron/**/*" + ], "directories": { "buildResources": "build", "output": "release" }, "win": { - "icon": "./src/assets/logo.ico", - "target": "nsis" + "icon": "./public/logo.ico", + "target": [ + { + "target": "nsis", + "arch": [ + "ia32" + ] + } + ] }, "nsis": { "oneClick": false, "allowElevation": true, "allowToChangeInstallationDirectory": true, - "installerIcon": "./src/assets/logo.ico", - "uninstallerIcon": "./src/assets/logo.ico", - "installerHeaderIcon": "./src/assets/logo.ico", + "installerIcon": "./public/logo.ico", + "uninstallerIcon": "./public/logo.ico", + "installerHeaderIcon": "./public/logo.ico", "createDesktopShortcut": true, - "createStartMenuShortcut": true, - "license": "LICENSE.txt" + "createStartMenuShortcut": true } } } diff --git a/src/assets/logo.ico b/public/logo.ico similarity index 100% rename from src/assets/logo.ico rename to public/logo.ico diff --git a/public/print.html b/public/print.html index e2b37a1..847b5d3 100644 --- a/public/print.html +++ b/public/print.html @@ -49,36 +49,28 @@
-