解决打包问题

This commit is contained in:
gyq 2024-03-06 10:49:45 +08:00
parent 48d6583a03
commit 91ce993270
11 changed files with 119 additions and 118 deletions

View File

@ -2,4 +2,4 @@
ENV = production ENV = production
# 线上环境接口地址 # 线上环境接口地址
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/' VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/api/'

1
.gitignore vendored
View File

@ -9,7 +9,6 @@ lerna-debug.log*
node_modules node_modules
release release
dist-electron
dist dist
dist-ssr dist-ssr

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
const electron = require("electron"); const electron = require("electron");
const path$1 = require("path"); const path = require("path");
function printUtils(params) { function printUtils(params) {
return new Promise(async (resolvePrint, rejectPrint) => { return new Promise(async (resolvePrint, rejectPrint) => {
let subMainWindow = new electron.BrowserWindow({ let subMainWindow = new electron.BrowserWindow({
@ -13,7 +13,7 @@ function printUtils(params) {
enableRemoteModule: true 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.on("did-finish-load", async (res) => {
subMainWindow.webContents.openDevTools(); subMainWindow.webContents.openDevTools();
console.log("网页加载完成", res); console.log("网页加载完成", res);
@ -28,16 +28,15 @@ function printUtils(params) {
}); });
}); });
} }
const NODE_ENV = process.env.NODE_ENV;
electron.app.whenReady().then(() => { electron.app.whenReady().then(() => {
const win = new electron.BrowserWindow({ const win = new electron.BrowserWindow({
title: "银收客", title: "银收客",
width: 1200, width: 1200,
height: 800, height: 800,
fullscreenable: true, fullscreenable: true,
fullscreen: true, fullscreen: false,
simpleFullscreen: true, simpleFullscreen: true,
frame: false, frame: true,
webPreferences: { webPreferences: {
// 集成网页和 Node.js也就是在渲染进程中可以调用 Node.js 方法 // 集成网页和 Node.js也就是在渲染进程中可以调用 Node.js 方法
nodeIntegration: true, nodeIntegration: true,
@ -47,11 +46,9 @@ electron.app.whenReady().then(() => {
if (process.env.VITE_DEV_SERVER_URL) { if (process.env.VITE_DEV_SERVER_URL) {
win.loadURL(process.env.VITE_DEV_SERVER_URL); win.loadURL(process.env.VITE_DEV_SERVER_URL);
} else { } else {
win.loadFile(path.join(__dirname, "../dist/index.html")); win.loadFile(path.resolve(__dirname, "../dist/index.html"));
}
if (NODE_ENV == "development") {
win.webContents.openDevTools();
} }
win.webContents.openDevTools();
electron.app.on("activate", () => { electron.app.on("activate", () => {
if (electron.BrowserWindow.getAllWindows().length === 0) { if (electron.BrowserWindow.getAllWindows().length === 0) {
createWindow(); createWindow();

View File

@ -1,17 +1,16 @@
import { app, BrowserWindow, ipcMain } from "electron"; import { app, BrowserWindow, ipcMain } from "electron";
import path from 'path'
import { printUtils } from './printUtils' import { printUtils } from './printUtils'
const NODE_ENV = process.env.NODE_ENV
app.whenReady().then(() => { app.whenReady().then(() => {
const win = new BrowserWindow({ const win = new BrowserWindow({
title: "银收客", title: "银收客",
width: 1200, width: 1200,
height: 800, height: 800,
fullscreenable: true, fullscreenable: true,
fullscreen: true, fullscreen: false,
simpleFullscreen: true, simpleFullscreen: true,
frame: false, frame: true,
webPreferences: { webPreferences: {
// 集成网页和 Node.js也就是在渲染进程中可以调用 Node.js 方法 // 集成网页和 Node.js也就是在渲染进程中可以调用 Node.js 方法
nodeIntegration: true, 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` // You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve`
if (process.env.VITE_DEV_SERVER_URL) { 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 { } else {
win.loadFile(path.join(__dirname, '../dist/index.html')); // 打包后使用文件路径访问应用 win.loadFile(path.resolve(__dirname, '../dist/index.html')); // 打包后使用文件路径访问应用
}
if (NODE_ENV == 'development') {
win.webContents.openDevTools();
} }
win.webContents.openDevTools();
app.on("activate", () => { app.on("activate", () => {
// 在 macOS 系统内, 如果没有已开启的应用窗口 // 在 macOS 系统内, 如果没有已开启的应用窗口

View File

@ -6,7 +6,8 @@
"scripts": { "scripts": {
"dev": "chcp 65001 && vite", "dev": "chcp 65001 && vite",
"build": "vite build && electron-builder", "build": "vite build && electron-builder",
"preview": "vite preview" "preview": "vite preview",
"build:win": "vite build && electron-builder --w"
}, },
"dependencies": { "dependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
@ -31,27 +32,37 @@
"vite-plugin-electron-renderer": "^0.14.5" "vite-plugin-electron-renderer": "^0.14.5"
}, },
"build": { "build": {
"appId": "com.example.app", "appId": "com.cashierdesktop.app",
"productName": "cashier_desktop", "productName": "cashier_desktop",
"asar": true, "asar": true,
"files": [
"./dist/**/*",
"./dist-electron/**/*"
],
"directories": { "directories": {
"buildResources": "build", "buildResources": "build",
"output": "release" "output": "release"
}, },
"win": { "win": {
"icon": "./src/assets/logo.ico", "icon": "./public/logo.ico",
"target": "nsis" "target": [
{
"target": "nsis",
"arch": [
"ia32"
]
}
]
}, },
"nsis": { "nsis": {
"oneClick": false, "oneClick": false,
"allowElevation": true, "allowElevation": true,
"allowToChangeInstallationDirectory": true, "allowToChangeInstallationDirectory": true,
"installerIcon": "./src/assets/logo.ico", "installerIcon": "./public/logo.ico",
"uninstallerIcon": "./src/assets/logo.ico", "uninstallerIcon": "./public/logo.ico",
"installerHeaderIcon": "./src/assets/logo.ico", "installerHeaderIcon": "./public/logo.ico",
"createDesktopShortcut": true, "createDesktopShortcut": true,
"createStartMenuShortcut": true, "createStartMenuShortcut": true
"license": "LICENSE.txt"
} }
} }
} }

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -49,36 +49,28 @@
</head> </head>
<body> <body>
<br />
<section id="app"> <section id="app">
<div class="title_wrap"> <RS:2><L><CB>####### 6 ######</CB></L><BR>
<div class="title"> <RS:2><C>*沙县小吃*</C><BR>
<b>{{data.shop_name}}</b> <RS:2><CB>--已在线支付--</CB><BR>
</div> <RS:2><C>----------------</C><BR>
<div class="min_title">结账单</div> 送达时间: 2021-01-04 13:28:50<BR>
</div> 送达时间: 2021-01-04 12:28:50<BR>
<div class="item b">NO:{{data.orderId}}</div> 订单编号: 1200897812792015996<BR>
<div class="item b">开始时间2023-3-4 16:32:54</div> -------01号篮子------<BR>
<div class="item b">结束时间2023-3-4 16:32:54</div> <L>爆炒肥肠 x2 80.0</L><BR>
<div class="item b">打印人002-蔡紫薇 打印次数:第一次打印</div> <L>蚂蚁上树 x1 12.3</L><BR>
<div class="item b">品相费450</div> [会员减配送费: 0.0]<BR>
<div class="item b">服务费280</div> <RS:1>[商家承担的配送费: 1.0]<BR>
<div v-for="(item,index) in data.carts" :key="index"> 配送费: ¥1.0<BR>
<div class="item">{{item.name}} {{item.number}}</div> <B>实付: ¥43.3</B><BR>
<br /> <B>手机号: 13012345678</B><BR>
</div> <RS:2><B>仲恺高新区惠风西3路1号</B><BR>
<div class="item b">收银员:张三</div> 备 注: 不要辣椒<BR>
发票抬头: 惠州市博实结科技有限公司<BR>
<LOGO>
<CUT>
</section> </section>
<div class="item b">电话</div>
<br />
<div class="item b">地址:陕西省西安市灞桥区后海餐厅一二三</div>
<br />
<div class="item b">--------------------------------</div>
<br />
<div class="item b">--------------------------------</div>
<br />
<div class="item b">--------------------------------</div>
<br />
<script type="module"> <script type="module">
const { ipcRenderer } = require("electron"); const { ipcRenderer } = require("electron");
import { import {

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -52,9 +52,9 @@ router.beforeEach((to, from) => {
} }
:root { :root {
--r: 47; --r: 24;
--g: 175; --g: 124;
--b: 162; --b: 170;
--r-lighter: calc(var(--r) + (255 - var(--r)) * 0.2); --r-lighter: calc(var(--r) + (255 - var(--r)) * 0.2);
--g-lighter: calc(var(--g) + (255 - var(--g)) * 0.2); --g-lighter: calc(var(--g) + (255 - var(--g)) * 0.2);
--b-lighter: calc(var(--b) + (255 - var(--b)) * 0.2); --b-lighter: calc(var(--b) + (255 - var(--b)) * 0.2);

View File

@ -142,6 +142,8 @@ const createOrderLoading = ref(false)
// //
const masterId = ref('') const masterId = ref('')
const uuid = ref('')
// //
const pendingCartNum = ref(0) const pendingCartNum = ref(0)
@ -197,7 +199,7 @@ async function pendingCart(params, status = true) {
status: status, status: status,
uuid: params.uuid uuid: params.uuid
}) })
if (status && !cartList.value.length) createCodeAjax() if (status && cartList.value.length) createCodeAjax()
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@ -255,7 +257,8 @@ async function addCart(params, type = 'add') {
number: params.number || 1, number: params.number || 1,
isPack: params.isPack || false, isPack: params.isPack || false,
isGift: params.isGift || false, isGift: params.isGift || false,
cartId: type == 'add' ? '' : params.id cartId: type == 'add' ? '' : params.id,
uuid: params.uuid || store.userInfo.uuid
}) })
masterId.value = res masterId.value = res
goodsRef.value.updateData() goodsRef.value.updateData()
@ -281,10 +284,12 @@ async function queryCartAjax() {
} }
} }
// //
async function createCodeAjax() { async function createCodeAjax() {
try { try {
const res = await createCode({ shopId: store.userInfo.shopId }) const res = await createCode({
shopId: store.userInfo.shopId
})
masterId.value = res.code masterId.value = res.code
// masterId.value = '#13' // masterId.value = '#13'
queryCartAjax() queryCartAjax()

View File

@ -3,46 +3,48 @@
<div class="logo"> <div class="logo">
<el-image :src="logo" style="width: 180px"></el-image> <el-image :src="logo" style="width: 180px"></el-image>
</div> </div>
<div class="form-wrap"> <div class="form-wrap" style="display: flex;align-items: center;">
<!-- <div class="reg-wrap"> <div style="flex: 1;">
<!-- <div class="reg-wrap">
<router-link :to="{ name: 'register' }"> <router-link :to="{ name: 'register' }">
<el-link type="primary">注册</el-link> <el-link type="primary">注册</el-link>
</router-link> </router-link>
</div> --> </div> -->
<div class="header"> <div class="header">
<span class="t1">银收客</span> <span class="t1">银收客</span>
<span class="t2">收银库存营销支付等业务一体化解决方案</span> <span class="t2">收银库存营销支付等业务一体化解决方案</span>
</div> </div>
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" hide-required-asterisk> <el-form ref="formRef" :model="form" :rules="rules" label-position="top" hide-required-asterisk>
<!-- <el-form-item label="注册商户号" prop="shopCode"> <el-form-item label="商户号" prop="merchantName">
<el-input v-model="form.shopCode" placeholder="请输入注册商户号"></el-input> <el-input v-model="form.merchantName" placeholder="请输入注册商户号"></el-input>
</el-form-item> --> </el-form-item>
<el-form-item label="手机号码" prop="phone"> <el-form-item label="手机号码" prop="loginName">
<el-input v-model="form.phone" placeholder="请输入11位手机号码"></el-input> <el-input v-model="form.loginName" placeholder="请输入11位手机号码"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="登录密码" prop="password"> <el-form-item label="登录密码" prop="password">
<el-input v-model="form.password" type="password" placeholder="请输入登录密码"></el-input> <el-input v-model="form.password" type="password" placeholder="请输入登录密码"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <!-- <el-form-item>
<div style="width: 100%; display: flex; justify-content: flex-end"> <div style="width: 100%; display: flex; justify-content: flex-end">
<router-link :to="{ name: 'register' }"> <router-link :to="{ name: 'register' }">
<el-link type="info">忘记密码</el-link> <el-link type="info">忘记密码</el-link>
</router-link> </router-link>
</div> </div>
</el-form-item> </el-form-item> -->
<el-form-item> <el-form-item>
<el-button type="primary" style="width: 100%" :loading="loading" @click="submitHandle"> <el-button type="primary" style="width: 100%" :loading="loading" @click="submitHandle">
<span v-if="!loading">登录</span> <span v-if="!loading">登录</span>
<span v-else>登录中...</span> <span v-else>登录中...</span>
</el-button> </el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button plain style="width: 100%" @click="logout">退出</el-button> <el-button plain style="width: 100%" @click="logout">退出</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="version"> <div class="version">
<el-text size="large">Ver2.1.6</el-text> <el-text size="large">Ver2.1.6</el-text>
<el-text size="large">陕西超掌柜科技有限公司</el-text> <el-text size="large">陕西超掌柜科技有限公司</el-text>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -66,30 +68,32 @@ const loading = ref(false);
const form = reactive({ const form = reactive({
shopCode: "", serialNumber: RandomNumBoth(1000, 9999),
phone: "", clientType: 'pc',
password: "", merchantName: '18821670757',
loginName: "18821670757",
password: "123456",
}); });
const rules = reactive({ const rules = reactive({
shopCode: [ merchantName: [
{ {
required: true, required: true,
message: "请输入注册商户号", message: " ",
trigger: "blur", trigger: "blur",
}, },
], ],
phone: [ loginName: [
{ {
required: true, required: true,
message: "请输入11位手机号码", message: " ",
trigger: "blur", trigger: "blur",
}, },
], ],
password: [ password: [
{ {
required: true, required: true,
message: "请输入登录密码", message: " ",
trigger: "blur", trigger: "blur",
}, },
], ],
@ -99,14 +103,7 @@ const rules = reactive({
const submitHandle = () => { const submitHandle = () => {
formRef.value.validate(async (valid) => { formRef.value.validate(async (valid) => {
if (valid) { if (valid) {
const params = { store.userlogin(form).then((res) => {
serialNumber: RandomNumBoth(1000, 9999),
clientType: 'pc',
loginName: form.phone,
password: form.password
}
store.userlogin(params).then((res) => {
loading.value = true; loading.value = true;
ElMessage.success("登录成功"); ElMessage.success("登录成功");
setTimeout(() => { setTimeout(() => {
@ -137,6 +134,10 @@ const logout = () => {
height: 100vh; height: 100vh;
background-color: #efefef; background-color: #efefef;
:deep(.el-form-item__label) {
font-size: var(--el-font-size-base);
}
.logo { .logo {
flex: 1; flex: 1;
height: inherit; height: inherit;