From 0fbc614c6150cc92fc57f585e003086d3393965e Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Mon, 11 Mar 2024 14:34:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- dist-electron/main.js | 20 +-- electron/main.js | 47 +++---- package.json | 5 +- public/print.html | 132 ++++++-------------- src/App.vue | 20 ++- src/components/skuModal.vue | 77 ++++++------ src/router/index.js | 3 + src/views/home/components/cartOperation.vue | 4 +- src/views/home/components/goods.vue | 15 ++- src/views/home/index.vue | 5 + src/views/home/test.vue | 37 ++---- src/views/login.vue | 6 +- 13 files changed, 156 insertions(+), 217 deletions(-) diff --git a/.env.development b/.env.development index f2a84a7..b59f2dc 100644 --- a/.env.development +++ b/.env.development @@ -3,4 +3,4 @@ ENV = development # 本地环境接口地址 # VITE_API_URL = 'http://192.168.2.87:10587/cashier-client' -VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client' \ No newline at end of file +VITE_API_URL = 'https://cashiernew.sxczgkj.cn/cashier-client' \ No newline at end of file diff --git a/dist-electron/main.js b/dist-electron/main.js index 501d667..4bb7d2b 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -19,6 +19,7 @@ electron.app.whenReady().then(() => { }); if (process.env.VITE_DEV_SERVER_URL) { win.loadURL(process.env.VITE_DEV_SERVER_URL); + win.webContents.openDevTools(); } else { win.loadFile(path.resolve(__dirname, "../dist/index.html")); } @@ -30,24 +31,7 @@ electron.app.whenReady().then(() => { electron.ipcMain.on("quitHandler", (_, msg) => { electron.app.quit(); }); - const printWin = new electron.BrowserWindow({ - show: false, - webPreferences: { - // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 - nodeIntegration: true, - contextIsolation: false - } - }); - if (process.env.VITE_DEV_SERVER_URL) { - printWin.loadFile(path.join(__dirname, "../public/print.html")); - } else { - printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); - } - electron.ipcMain.on("printerInfoSync", (event, params) => { - printWin.webContents.send("getParams", params); - }); - electron.ipcMain.on("printStart", () => { - console.log("开始打印"); + electron.ipcMain.on("printStart", (event, arg) => { }); }); electron.app.on("window-all-closed", () => { diff --git a/electron/main.js b/electron/main.js index a159aaf..4dbe197 100644 --- a/electron/main.js +++ b/electron/main.js @@ -22,7 +22,7 @@ app.whenReady().then(() => { if (process.env.VITE_DEV_SERVER_URL) { win.loadURL(process.env.VITE_DEV_SERVER_URL); // 使用vite开发服务的url路径访问应用 - // win.webContents.openDevTools(); + win.webContents.openDevTools(); } else { win.loadFile(path.resolve(__dirname, "../dist/index.html")); // 打包后使用文件路径访问应用 } @@ -40,36 +40,37 @@ app.whenReady().then(() => { }); // 创建打印小票子窗口 - const printWin = new BrowserWindow({ - show: false, - webPreferences: { - // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 - nodeIntegration: true, - contextIsolation: false, - }, - }); + // const printWin = new BrowserWindow({ + // show: false, + // webPreferences: { + // // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 + // nodeIntegration: true, + // contextIsolation: false, + // }, + // }); - if (process.env.VITE_DEV_SERVER_URL) { - // 加载打印的html文件 - printWin.loadFile(path.join(__dirname, "../public/print.html")); - } else { - printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用 - } + // if (process.env.VITE_DEV_SERVER_URL) { + // // 加载打印的html文件 + // printWin.loadFile(path.join(__dirname, "../public/print.html")); + // } else { + // printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用 + // } // win.webContents.getPrintersAsync().then(res => { - // console.log('list', res) + // // console.log('list', res) // }) - ipcMain.on("printerInfoSync", (event, params) => { - // console.log(JSON.parse(params)) - printWin.webContents.send("getParams", params); - }); + // ipcMain.on("printerInfoSync", (event, params) => { + // // console.log(JSON.parse(params)) + // printWin.webContents.send("getParams", params); + // }); // 执行打印操作 - ipcMain.on('printStart', () => { - console.log('开始打印') + ipcMain.on('printStart', (event, arg) => { + // console.log('开始打印', arg) - let name = 'RONGTA 80mm Series Printer' + // let name = 'Xprinter XP-365B' + // // let name = 'Generic / Text Only' // printWin.webContents.print({ // silent: true, diff --git a/package.json b/package.json index 2c03e31..2e5dfcf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vite-electron", "private": true, - "version": "0.0.5", + "version": "0.0.7", "main": "dist-electron/main.js", "scripts": { "dev": "chcp 65001 && vite", @@ -13,7 +13,8 @@ "@element-plus/icons-vue": "^2.3.1", "axios": "^1.6.2", "dayjs": "^1.11.10", - "electron-pos-printer": "^1.3.7", + "electron-pos-printer": "^1.3.6", + "electron-pos-printer-vue": "^1.0.9", "element-plus": "^2.4.3", "lodash": "^4.17.21", "pinia": "^2.1.7", diff --git a/public/print.html b/public/print.html index c0c9b5d..d188388 100644 --- a/public/print.html +++ b/public/print.html @@ -7,114 +7,58 @@
{{data.shop_name || '结账单位'}}
-