Commit a7c170cc by linjinhong

驱动兼容

parent 77af1dff
[{"head_setting":{"gridShow":1,"gridValue":0,"unit":"inch","language":"cn","autoPrint":false,"gridSpacing":1},"version":"1.0.16","print_setting":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false},"production_no":"GCPSC2507193437","print_time":"2025-07-19 15:12:08","position_unit":{"x":408.8,"rate":1.396341463414634,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":458.6,"w":594.4,"h":826.7,"r":0},"position_after_px":{"x":"0.4","rate":1.0410958904109588,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":"1.5","w":"26.4","h":"27.4","r":0},"position_before_px":{"url":"D:\\work\\electron-printer\\print\\Input\\fe1efecb-506e-4400-b264-c8e2d87adc5e.png","fileName":"fe1efecb-506e-4400-b264-c8e2d87adc5e.png","rate":1.0410958904109588,"w":795.3157894736843,"zIndex":0,"x":11.342105263157862,"y":46,"h":828,"r":0},"send_api_data":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false,"byPlatenSize":1,"cmd":"GTXproCMD.exe print -X \"Profile\\fe1efecb-506e-4400-b264-c8e2d87adc5e.xml\" -I \"Input\\fe1efecb-506e-4400-b264-c8e2d87adc5e.png\" -A \"Output\\fe1efecb-506e-4400-b264-c8e2d87adc5e.arxp\" -S 39374100 -L 00610233 -D 0 -W 1","fileName":"fe1efecb-506e-4400-b264-c8e2d87adc5e.png","print_cmd":"GTXproCMD.exe send -A \"Output\\fe1efecb-506e-4400-b264-c8e2d87adc5e.arxp\" -P \"Brother GTX pro FileOutput"}},{"head_setting":{"gridShow":1,"gridValue":0,"unit":"inch","language":"cn","autoPrint":false,"gridSpacing":1},"version":"1.0.16","print_setting":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false},"production_no":"GCPSC2507193437","print_time":"2025-07-19 15:12:00","position_unit":{"x":408.8,"rate":1.396341463414634,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":458.6,"w":594.4,"h":826.7,"r":0},"position_after_px":{"x":"0.4","rate":1.0410958904109588,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":"1.5","w":"26.4","h":"27.4","r":0},"position_before_px":{"url":"D:\\work\\electron-printer\\print\\Input\\fe1efecb-506e-4400-b264-c8e2d87adc5e.png","fileName":"fe1efecb-506e-4400-b264-c8e2d87adc5e.png","rate":1.0410958904109588,"w":795.3157894736843,"zIndex":0,"x":11.342105263157862,"y":46,"h":828,"r":0},"send_api_data":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false,"byPlatenSize":1,"cmd":"GTXproCMD.exe print -X \"Profile\\fe1efecb-506e-4400-b264-c8e2d87adc5e.xml\" -I \"Input\\fe1efecb-506e-4400-b264-c8e2d87adc5e.png\" -A \"Output\\fe1efecb-506e-4400-b264-c8e2d87adc5e.arxp\" -S 39374100 -L 00610233 -D 0 -W 1","fileName":"fe1efecb-506e-4400-b264-c8e2d87adc5e.png","print_cmd":"GTXproCMD.exe send -A \"Output\\fe1efecb-506e-4400-b264-c8e2d87adc5e.arxp\" -P \"导出为WPS PDF"}}]
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
[{"head_setting":{"gridShow":1,"gridValue":1,"unit":"inch","language":"cn","autoPrint":false,"gridSpacing":1},"version":"1.0.19","print_setting":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false},"production_no":"USPSC250621003","print_time":"2025-08-20 07:19:01","position_unit":{"x":408.8,"rate":1.396341463414634,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":458.6,"w":594.4,"h":826.7,"r":0},"position_after_px":{"x":"0.0","rate":1.0676110753380554,"sx":0,"zIndex":0,"sh":0,"sw":0,"sy":0,"y":"1.5","w":"22.3","h":"26.4","r":0},"position_before_px":{"url":"D:\\work\\gtx-3.0\\print4.0\\Input\\7fd25868-79c5-478e-9c10-9becba9ef2dd.png","fileName":"7fd25868-79c5-478e-9c10-9becba9ef2dd.png","rate":1.0676110753380554,"w":674,"zIndex":0,"x":0,"y":44.19999999999999,"h":795.6,"r":0},"send_api_data":{"printer":"","xy":"","byInk":2,"byInkVolume":1,"byDoublePrint":3,"bEcoMode":false,"bMaterialBlack":false,"byHighlight":5,"printNum":1,"bFastMode":false,"bUniPrint":false,"bDivide":false,"bPause":false,"byMask":3,"bTransColor":false,"byChoke":2,"minWhiteInkType":0,"bySaturation":5,"byBrightness":5,"byContrast":5,"iCyanBalance":0,"iMagentaBalance":0,"iBlackBalance":0,"iYellowBalance":0,"byMinWhite":1,"bMultiple":false,"byPlatenSize":0,"cmd":"GTXproCMD.exe print -X \"Profile\\7fd25868-79c5-478e-9c10-9becba9ef2dd.xml\" -I \"Input\\7fd25868-79c5-478e-9c10-9becba9ef2dd.png\" -A \"Output\\7fd25868-79c5-478e-9c10-9becba9ef2dd.arxp\" -S 40534786 -L 00060272 -D 0 -W 1","fileName":"7fd25868-79c5-478e-9c10-9becba9ef2dd.png","print_cmd":"GTXproCMD.exe send -A \"Output\\7fd25868-79c5-478e-9c10-9becba9ef2dd.arxp\" -P \"Brother GTX pro FileOutput"}}]
\ No newline at end of file
......@@ -2,7 +2,7 @@
"name": "JomallProductionAssistant",
"productName": "JomallProductionAssistant",
"description": "",
"version": "1.0.18",
"version": "1.0.19",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
......@@ -26,7 +26,7 @@
"electron-builder": "^24.13.3",
"electron-icon-builder": "^2.0.1",
"electron-log": "^5.1.7",
"electron-store": "^4.0.0",
"electron-store": "^5.2.0",
"electron-updater": "^6.2.1",
"element-ui": "^2.13.0",
"express": "^4.17.1",
......
// preload.js
const { contextBridge, ipcRenderer } = require("electron");
// 暴露安全的 IPC 方法给渲染进程
contextBridge.exposeInMainWorld("electronAPI", {
sendToMain: (channel, data) => ipcRenderer.send(channel, data),
receiveFromMain: (channel, callback) => {
ipcRenderer.on(channel, (event, ...args) => callback(...args));
},
});
<?xml version="1.0" encoding="utf-8"?>
<GTOPTION xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<szFileName />
<uiCopies>1</uiCopies>
<byPlatenSize>1</byPlatenSize>
<bEcoMode>false</bEcoMode>
<byInk>2</byInk>
<bMaterialBlack>false</bMaterialBlack>
<bMultiple>false</bMultiple>
<byHighlight>5</byHighlight>
<byMask>3</byMask>
<bFastMode>false</bFastMode>
<bDivide>false</bDivide>
<bPause>false</bPause>
<bTransColor>false</bTransColor>
<byChoke>2</byChoke>
<byMinWhite>1</byMinWhite>
<bySaturation>5</bySaturation>
<byBrightness>5</byBrightness>
<byContrast>5</byContrast>
<iCyanBalance>0</iCyanBalance>
<bUniPrint>false</bUniPrint>
<iMagentaBalance>0</iMagentaBalance>
<iYellowBalance>0</iYellowBalance>
<iBlackBalance>0</iBlackBalance>
<byResolution>1</byResolution>
</GTOPTION>
\ No newline at end of file
......@@ -7,6 +7,7 @@ import { autoUpdater } from "electron-updater";
import path from "path"; // 引入 path 模块
const { exec } = require("child_process");
const { setVersion } = require("@/server/utils/store");
Object.defineProperty(app, "isPackaged", {
get() {
......@@ -27,8 +28,6 @@ const winURL =
: `file://${__dirname}/index.html`;
async function createWindow() {
let latestVersion = "print"; // 默认值
win = new BrowserWindow({
width: 1500,
height: 1000,
......@@ -36,9 +35,6 @@ async function createWindow() {
webPreferences: {
webSecurity: false,
nodeIntegration: true,
//p.s.路径为绝对路径
preload: path.join(__dirname, "./preloadOther.js"),
},
});
......@@ -85,9 +81,6 @@ async function createWindow() {
win.webContents.send("sendWebsockt", obj);
});
ipcMain.on("sync-version", (_, version) => {
latestVersion = version; // 更新全局变量
});
win.on("closed", () => {
// win && win.removeAllListeners();
// win = null;
......@@ -204,6 +197,11 @@ app.on("ready", async () => {
globalShortcut.register("CommandOrControl+R", () => {
return false;
});
ipcMain.on("update-version", (_, version) => {
console.log(72, version);
setVersion(version); // 保存到 electron-store
});
});
app.on("will-quit", () => {
......
......@@ -21,11 +21,13 @@ const { app } = require("electron");
let fileEnv, env, visionUrl;
axios.defaults.timeout = 12600000;
const multiparty = require("multiparty");
// import store from "@/store/index.js";
let version;
const { getVersion } = require("@/server/utils/store");
function getCurrentVersion() {
const version = getVersion();
console.log("version", version);
return version;
}
......
......@@ -6,10 +6,12 @@ var request = require("request");
var uuid = require("uuid");
const compressing = require("compressing");
// import store from "@/store/index.js";
let version;
const { getVersion } = require("@/server/utils/store");
function getCurrentVersion() {
const version = getVersion();
console.log("version", version);
return version;
}
......@@ -239,7 +241,7 @@ export const toSend = (body) => {
exec(
body.cmd,
{ cwd: path.join(process.cwd(), getCurrentVersion()), shell: true },
(err, stdout, stderr) => {
(err) => {
// console.log(stdout, 1);
// console.log(stderr, 2);
console.log("err", err);
......@@ -277,14 +279,14 @@ export const toSend = (body) => {
}
);
} else {
const errorCode = err.code || "UNKNOWN_ERROR";
const errorDetails = [
`生成命令失败: ${body.cmd}`,
`错误代码: ${errorCode}`,
`错误信息: ${err.message}`,
`标准错误输出: ${stderr}`,
].join("\n");
// const errorCode = err.code || "UNKNOWN_ERROR";
// const errorDetails = [
// `生成命令失败: ${body.cmd}`,
// `错误代码: ${errorCode}`,
// `错误信息: ${err.message}`,
// `标准错误输出: ${stderr}`,
// ].join("\n");
const errorDetails = "未匹配到对应版本的驱动,请检查驱动";
return reject(errorDetails);
}
}
......
const Store = require("electron-store");
const store = new Store();
module.exports = {
setVersion: (version) => {
store.set("desktoVersion", version);
console.log("store", store.get("desktoVersion"));
},
getVersion: () => store.get("desktoVersion") || "print",
};
......@@ -63,14 +63,14 @@ export default new Vuex.Store({
h: 0,
w: 0,
},
// {
// label: "16×21",
// value: 0,
// row: 16,
// col: 21,
// h: 0,
// w: 0,
// },
{
label: "16×21",
value: 0,
row: 16,
col: 21,
h: 0,
w: 0,
},
],
},
mutations: {
......@@ -110,11 +110,25 @@ export default new Vuex.Store({
setGrid(state) {
// state.grid[0].h = h;
// state.grid[0].w = w;
console.log(state.WHproportion);
state.grid.forEach((el) => {
if (el.value == 0) {
el.h = 630 * (state.WHproportion - 0.3);
el.w = 480 * (state.WHproportion - 0.3);
console.log("16*21", state.WHproportion);
console.log("16*21..", state.defaultProportion);
let proportion = state.WHproportion;
if (state.defaultProportion == 1.5) {
proportion = 1.4;
} else if (state.defaultProportion == 1.7) {
proportion = 1.4;
}
el.h = 630 * proportion;
el.w = 480 * proportion;
} else if (el.value == 1) {
console.log("16*18", state.WHproportion);
console.log("16*18..", state.defaultProportion);
el.h = 540 * state.WHproportion;
el.w = 480 * state.WHproportion;
} else if (el.value == 2) {
......
......@@ -12,6 +12,7 @@ import axios from "axios";
const uuid = require("uuid");
const fs = require("fs");
import { mapState } from "vuex";
const { getVersion } = require("@/server/utils/store");
export default {
components: { UpdateDialog },
......@@ -29,7 +30,7 @@ export default {
return {
checkList: [],
desktopDevice: 1,
version: "print",
desktoVersion: getVersion(),
checked: false,
isFirst: true,
cacheList: [
......@@ -102,7 +103,7 @@ export default {
});
},
created() {
this.version = localStorage.getItem("desktoVersion");
localStorage.setItem("desktoVersion", "print");
if (this.$dataStore.get("setting")) {
this.setting = this.$dataStore.get("setting");
} else {
......@@ -526,11 +527,11 @@ export default {
if (i === 1) {
this.$store.commit("setWHproportion", this.defaultProportion - 0.3);
this.$store.commit("setGrid");
} else {
this.$store.commit("setWHproportion", this.defaultProportion);
this.$store.commit("setGrid");
}
this.$store.commit("setGrid");
this.selectGridIndex = i;
this.setting.gridValue = i;
......@@ -548,7 +549,12 @@ export default {
this.$store.commit("changeImgList", []);
console.log(347, store.state.desktopDevice);
},
changeDesktoVersionFn(value) {
console.log(553, value);
this.$store.commit("changeDesktoVersion", value);
ipcRenderer.send("update-version", value);
},
async cutImgFn(arr) {
if (!arr.length) return arr;
console.log(arr);
......@@ -680,13 +686,20 @@ export default {
<el-option label="其他" :value="2"></el-option>
</el-select>
</div>
<div class="selectInput">
<div>驱动版本:</div>
<el-dropdown
trigger="click"
@command="command"
:hide-on-click="false"
:disabled="true"
>
<el-select
v-model="desktoVersion"
@change="changeDesktoVersionFn"
placeholder="请选择版本"
>
<el-option label="2.0" value="print"></el-option>
<el-option label="4.0" value="print4.0"></el-option>
</el-select>
</div>
<el-dropdown trigger="click" @command="command" :hide-on-click="false">
<el-button style="height: 100%;margin-right: 0" size="small"
>{{ grid[selectGridIndex].label }}
</el-button>
......@@ -819,9 +832,6 @@ export default {
>检查更新
</el-button>
</el-form-item>
<el-form-item prop="language" label="驱动版本">
<b>{{ version === "print" ? "2.0" : "4.0" }}</b>
</el-form-item>
<!-- <el-form-item label="自动打印模式">-->
<!-- <el-switch @change="(e)=>settingChange('autoPrint',e)" v-model="setting.autoPrint"></el-switch>-->
......
......@@ -50,6 +50,7 @@ export default {
this.$store.commit("setDefaultproportion", proportion);
this.$store.commit("setGrid");
});
if (!this.countryList.length) {
this.getAllCountryFn();
}
......@@ -67,6 +68,8 @@ export default {
w: this.grid[this.systemSetting.gridValue].w,
v: this.grid[this.systemSetting.gridValue].value,
h: this.grid[this.systemSetting.gridValue].h,
row: this.grid[this.systemSetting.gridValue].row,
col: this.grid[this.systemSetting.gridValue].col,
};
},
gridSpacing() {
......@@ -114,7 +117,7 @@ export default {
},
computedGridSize() {
const getter = this.systemSetting;
const num = getter.gridSpacing.slice(0, 2);
// const num = getter.gridSpacing.slice(0, 2);
return 10 + "px";
},
......@@ -141,6 +144,7 @@ export default {
"grid",
"windowWH",
"countryList",
"desktoVersion",
]),
},
data() {
......@@ -241,6 +245,16 @@ export default {
this.selectImgIndex = 0;
}
},
desktoVersion(newValue) {
if (newValue) {
this.imgList = [];
this.selectImgList = [];
this.selectIndex = -1;
this.selectImgIndex = 0;
this.detail = {};
}
},
productDetail(newValue) {
this.detail = { ...newValue };
if (typeof this.detail.imageAry == "string") {
......@@ -664,13 +678,17 @@ export default {
let data = await that.getImageSize(files[i].url);
rate = data.height / data.width;
console.log(679, rate);
if (rate > 1) {
height_px = bh * (9 / 10);
height_px = bh * (8 / 10);
// width_px = height_px / rate > bw ? bw : height_px / rate;
width_px = height_px / rate;
x = width_px / 2;
y = h;
} else {
width_px = bw * (2 / 3);
// height_px = width_px * rate > bh ? bh : width_px * rate;
height_px = width_px * rate;
x = w;
y = height_px / 2;
......@@ -705,7 +723,7 @@ export default {
addFile(file, callback) {
let that = this;
let bw = document.getElementById("line").clientWidth;
let bh = document.getElementById("line").clientHeight;
// let bh = document.getElementById("line").clientHeight;
that.$nextTick(() => {
that.getImageSize(file.url).then((data) => {
let w = document.getElementById("line").clientWidth / 2;
......@@ -1357,8 +1375,8 @@ export default {
<div
:class="{ 'no-border-grid': systemSetting.gridShow !== 1 }"
:style="{
width: 480 + 'px',
height: 540 + 'px',
width: gridWH.row * 30 + 'px',
height: gridWH.col * 30 + 'px',
}"
class="grid"
style="border-style:dashed"
......
......@@ -2,6 +2,7 @@
const { ipcRenderer } = require("electron");
import { mapState } from "vuex";
// 状态更新时发送
export default {
data() {
return {
......@@ -97,10 +98,6 @@ export default {
this.form.factoryCode = this.userList[v].factoryCode;
this.form.password = this.userList[v].password;
},
changeDesktoVersion(value) {
// this.$store.commit("changeDesktoVersion", value);
localStorage.setItem("desktoVersion", value);
},
},
};
</script>
......@@ -110,35 +107,24 @@ export default {
<div class="form-content">
<el-form ref="formRef" :rules="rules" size="small" :model="form">
<el-form-item v-if="userList.length > 0">
<div style="display: flex;">
<el-select
@change="userChange"
filterable
style="width: 100%"
placeholder="登录记录"
v-model="form.user"
clearable
>
<template slot="prefix">
<i class="el-icon-monitor"></i>
</template>
<el-option
v-for="(it, i) in userList"
:key="i"
:label="`${it.account}(${it.factoryCode})`"
:value="i"
></el-option>
</el-select>
<el-select
style="margin-left: 8px;"
v-model="desktoVersion"
@change="changeDesktoVersion"
placeholder="请选择版本"
>
<el-option label="驱动2.0" value="print"></el-option>
<el-option label="驱动4.0" value="print4.0"></el-option>
</el-select>
</div>
<el-select
@change="userChange"
filterable
style="width: 100%"
placeholder="登录记录"
v-model="form.user"
clearable
>
<template slot="prefix">
<i class="el-icon-monitor"></i>
</template>
<el-option
v-for="(it, i) in userList"
:key="i"
:label="`${it.account}(${it.factoryCode})`"
:value="i"
></el-option>
</el-select>
</el-form-item>
<el-form-item prop="factoryCode">
<el-input
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment