Commit 77af1dff by linjinhong

新增驱动

parent c2b510b7
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.
......@@ -20,6 +20,7 @@
"@vue/composition-api": "^0.3.4",
"axios": "^0.19.2",
"bignumber.js": "^9.2.1",
"canvas": "^2.11.2",
"compressing": "^1.10.1",
"core-js": "^3.6.4",
"electron-builder": "^24.13.3",
......@@ -39,6 +40,7 @@
"multiparty": "^4.2.3",
"nodemon": "^3.1.4",
"normalize.css": "^8.0.1",
"rebuild": "^0.1.2",
"sharp": "0.28.0",
"vue": "^2.6.11",
"vue-draggable-resizable": "^2.0.0",
......
// 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));
},
});
GTXproCMD.exe print -X "Profile\CO12.xml" -I "Input\sample.png" -A "Output\pO12.arxp" -S 01000200 -L 02540254
echo %errorlevel%
\ No newline at end of file
GTXproCMD.exe print -X "Profile\CO12.xml" -I "Input\sample.png" -A "Output\pO12.arxp" -S 01000200 -L 02540254
echo %errorlevel%
\ No newline at end of file
<?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>
<bMultiple>1</bMultiple>
<byResolution>1</byResolution>
<byInk>1</byInk>
<byInkVolume>1</byInkVolume>
<byDoublePrint>1</byDoublePrint>
<bySaturation>1</bySaturation>
<byBrightness>1</byBrightness>
<byContrast>1</byContrast>
<iCyanBalance>1</iCyanBalance>
<iMagentaBalance>1</iMagentaBalance>
<iYellowBalance>1</iYellowBalance>
<iBlackBalance>1</iBlackBalance>
<bUniPrint>1</bUniPrint>
</GTOPTION>
\ No newline at end of file
<?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>
<byHighlight>1</byHighlight>
<byMask>1</byMask>
<bDivide>1</bDivide>
<bTransColor>1</bTransColor>
<bySaturation>1</bySaturation>
<byBrightness>1</byBrightness>
<byContrast>1</byContrast>
<bUniPrint>1</bUniPrint>
<byResolution>1</byResolution>
<byInk>1</byInk>
</GTOPTION>
\ No newline at end of file
<?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
<?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>1</bEcoMode>
<byInk>1</byInk>
<bMaterialBlack>1</bMaterialBlack>
<bMultiple>1</bMultiple>
<byHighlight>1</byHighlight>
<byMask>1</byMask>
<bFastMode>1</bFastMode>
<bDivide>1</bDivide>
<bPause>1</bPause>
<bTransColor>1</bTransColor>
<byChoke>1</byChoke>
<byMinWhite>1</byMinWhite>
<bySaturation>1</bySaturation>
<byBrightness>1</byBrightness>
<byContrast>1</byContrast>
<iCyanBalance>1</iCyanBalance>
<bUniPrint>1</bUniPrint>
<iMagentaBalance>1</iMagentaBalance>
<iYellowBalance>1</iYellowBalance>
<iBlackBalance>1</iBlackBalance>
<byResolution>1</byResolution>
</GTOPTION>
\ No newline at end of file
<?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>
<byResolution>1</byResolution>
<byInk>1</byInk>
<bMultiple>1</bMultiple>
<byInkVolume>1</byInkVolume>
<byDoublePrint>1</byDoublePrint>
<bySaturation>1</bySaturation>
<byBrightness>1</byBrightness>
<byContrast>1</byContrast>
<iBlackBalance>1</iBlackBalance>
<bUniPrint>1</bUniPrint>
</GTOPTION>
\ No newline at end of file
<?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
<?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
<?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
GTXproCMD.exe print -X "Profile\CO12.xml" -I "Input\sample.png" -A "Output\pO12.arxp" -S 01000200 -L 02540254
echo %errorlevel%
\ No newline at end of file
GTXproCMD.exe send -A "D:\sample\Output\pO12.arxp" -P "Brother GTX pro" -D 1
echo %errorlevel%
\ No newline at end of file
......@@ -27,6 +27,8 @@ const winURL =
: `file://${__dirname}/index.html`;
async function createWindow() {
let latestVersion = "print"; // 默认值
win = new BrowserWindow({
width: 1500,
height: 1000,
......@@ -34,6 +36,9 @@ async function createWindow() {
webPreferences: {
webSecurity: false,
nodeIntegration: true,
//p.s.路径为绝对路径
preload: path.join(__dirname, "./preloadOther.js"),
},
});
......@@ -80,6 +85,9 @@ async function createWindow() {
win.webContents.send("sendWebsockt", obj);
});
ipcMain.on("sync-version", (_, version) => {
latestVersion = version; // 更新全局变量
});
win.on("closed", () => {
// win && win.removeAllListeners();
// win = null;
......
......@@ -22,6 +22,13 @@ let fileEnv, env, visionUrl;
axios.defaults.timeout = 12600000;
const multiparty = require("multiparty");
// import store from "@/store/index.js";
let version;
function getCurrentVersion() {
return version;
}
function readEnv() {
let exePath, configPath;
if (process.env.NODE_ENV === "development") {
......@@ -52,7 +59,10 @@ export default {
responseType: "stream",
});
let fileName = uuid.v4() + ".png";
const filePath = path.join(process.cwd(), "./print/Input/" + fileName);
const filePath = path.join(
process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName
);
const writer = fs.createWriteStream(filePath);
response.data.pipe(writer);
......@@ -215,7 +225,7 @@ export default {
for (let k in q.imgList) {
const p = path.join(
process.cwd(),
"./print/Input/" + q.imgList[k].fileName
`./${getCurrentVersion()}/Input/` + q.imgList[k].fileName
);
zipStream.addEntry(p);
}
......@@ -254,7 +264,7 @@ export default {
},
uploadImage: async (req, res) => {
try {
const p = path.join(process.cwd(), "./print/Input/");
const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
let fileName = uuid.v4() + ".png";
console.log(fileName);
......@@ -269,7 +279,10 @@ export default {
code: 200,
data: {
fileName,
url: path.join(process.cwd(), "./print/Input/" + fileName),
url: path.join(
process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName
),
},
});
}
......@@ -283,7 +296,7 @@ export default {
try {
const filePath = path.join(
process.cwd(),
`./print/Input/${req.body.fileName}`
`./${getCurrentVersion()}/Input/${req.body.fileName}`
);
console.log(filePath);
// 给客户端返回一个文件流 type类型
......@@ -318,7 +331,7 @@ export default {
toPrint: (req, res) => {
let body = req.body;
writeProfileXml(body); // 写入xml文件
// GTXproCMD.exe print -X "Profile\\CO12.xml" -I "Input\\sample.png" -A "Output\\pO12.arxp" -S 03000400 -L 02540254
// GTX6CMD.exe print -X "Profile\\CO12.xml" -I "Input\\sample.png" -A "Output\\pO12.arxp" -S 03000400 -L 02540254
console.log(249, body);
toSend(body)
......@@ -410,7 +423,7 @@ export default {
},
//删除图片
cleanDirectorySync: async (req, res) => {
let dirPath = path.join(process.cwd(), `./print/Input`);
let dirPath = path.join(process.cwd(), `./${getCurrentVersion()}/Input`);
if (!fs.existsSync(dirPath)) {
console.log(`目录不存在: ${dirPath}`);
res.json({ code: 500, msg: `目录不存在: ${dirPath}` });
......@@ -442,7 +455,7 @@ export default {
},
saveToPng: async (req, res) => {
try {
const p = path.join(process.cwd(), "./print/Input/");
const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
const form = new multiparty.Form({ uploadDir: p });
form.parse(req, function(err, fields, files) {
console.log(367, fields, files, err);
......@@ -455,7 +468,10 @@ export default {
fs.renameSync(file.path, path.join(p, fileName));
list.push({
fileName,
url: path.join(process.cwd(), "./print/Input/" + fileName),
url: path.join(
process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName
),
});
});
res.json({
......
......@@ -6,6 +6,13 @@ var request = require("request");
var uuid = require("uuid");
const compressing = require("compressing");
// import store from "@/store/index.js";
let version;
function getCurrentVersion() {
return version;
}
function zip(from, to) {
return new Promise((resolve, reject) => {
let dirName = path.join(to, uuid.v4());
......@@ -49,7 +56,7 @@ export const downloadImage = (list) => {
return new Promise((resolve, reject) => {
try {
// console.log("Formatted Folder Name:", folderName); // 检查替换结果
let dirPath = path.join(process.cwd(), `./print/Input/`);
let dirPath = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath);
......@@ -80,7 +87,10 @@ export const downloadImage = (list) => {
fileName = uuid.v4() + ".png";
type = 2;
}
let p = path.join(process.cwd(), "./print/Input/" + fileName);
let p = path.join(
process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName
);
let stream = fs.createWriteStream(p);
request(list[i].url)
.pipe(stream)
......@@ -141,7 +151,7 @@ export function downloadOtherImage(list) {
.split(".")[0];
let otherTypePath = path.join(
process.cwd(),
`./print/Input/${folderName}`
`./${getCurrentVersion()}/Input/${folderName}`
);
if (!fs.existsSync(otherTypePath)) {
fs.mkdirSync(otherTypePath);
......@@ -210,7 +220,10 @@ export function downloadOtherImage(list) {
// 传递素材给前端
export const sendImg = (filename = "sample.png") => {
let filePath = path.join(process.cwd(), "./print/Input/" + filename);
let filePath = path.join(
process.cwd(),
`./${getCurrentVersion()}/Input/` + filename
);
if (!fs.existsSync(filePath)) {
return false;
}
......@@ -220,18 +233,21 @@ export const sendImg = (filename = "sample.png") => {
};
export const toSend = (body) => {
console.log("999999999", path.join(process.cwd(), getCurrentVersion()));
return new Promise((resolve, reject) => {
exec(
body.cmd,
{ cwd: path.join(process.cwd(), "print"), shell: true },
{ cwd: path.join(process.cwd(), getCurrentVersion()), shell: true },
(err, stdout, stderr) => {
// console.log(stdout, 1);
// console.log(stderr, 2);
console.log("err", err);
if (!err) {
exec(
body.print_cmd,
{ cwd: path.join(process.cwd(), "print"), shell: true },
{ cwd: path.join(process.cwd(), getCurrentVersion()), shell: true },
(err2) => {
console.log(err2);
if (!err2) {
......@@ -240,7 +256,7 @@ export const toSend = (body) => {
fs.unlinkSync(
path.join(
process.cwd(),
"print/Profile/" +
`${getCurrentVersion()}/Profile/` +
body.fileName.replace(".png", "") +
".xml"
)
......@@ -248,7 +264,7 @@ export const toSend = (body) => {
fs.unlinkSync(
path.join(
process.cwd(),
"print/Output/" +
`${getCurrentVersion()}/Output/` +
body.fileName.replace(".png", "") +
".arxp"
)
......@@ -277,8 +293,13 @@ export const toSend = (body) => {
};
export const writeProfileXml = (b) => {
console.log(b);
try {
let p = path.join(process.cwd(), `./print/Profile/${b.byInk}.xml`);
let p = path.join(
process.cwd(),
`./${getCurrentVersion()}/Profile/${b.byInk}.xml`
);
let file = fs.readFileSync(p, { encoding: "utf8" });
file = file.replace(
/<uiCopies>(.*)<\/uiCopies>/i,
......@@ -376,11 +397,11 @@ export const writeProfileXml = (b) => {
fs.writeFileSync(
path.join(
process.cwd(),
`./print/Profile/${b.fileName.replace(".png", "")}.xml`
`./${getCurrentVersion()}/Profile/${b.fileName.replace(".png", "")}.xml`
),
file
);
} catch (err) {
console.log(err);
console.log(404, err);
}
};
......@@ -17,6 +17,7 @@ export default new Vuex.Store({
productDetail: {},
windowWH: { width: 0, height: 0 },
desktopDevice: 1, //1是兄弟,2是其他
desktoVersion: "print", //print2.0是2.0,print4.0是4.0
WHproportion: 1, //宽高比例
defaultProportion: 1,
isPreView: false,
......@@ -91,6 +92,9 @@ export default new Vuex.Store({
changeDesktopDevice(state, value) {
state.desktopDevice = value;
},
changeDesktoVersion(state, value) {
state.desktoVersion = value;
},
setProductDetail(state, value) {
state.productDetail = value;
},
......
<script>
import bus from "@/bus";
import PrintDialog from "./printDialog.vue";
// import PrintDialog from "./printDialog.vue";
import { ipcRenderer } from "electron";
// import { grid } from "../data";
import pkg from "../../../../package.json";
......@@ -14,7 +14,7 @@ const fs = require("fs");
import { mapState } from "vuex";
export default {
components: { PrintDialog, UpdateDialog },
components: { UpdateDialog },
props: {
user: {
default: () => ({
......@@ -29,6 +29,7 @@ export default {
return {
checkList: [],
desktopDevice: 1,
version: "print",
checked: false,
isFirst: true,
cacheList: [
......@@ -101,6 +102,7 @@ export default {
});
},
created() {
this.version = localStorage.getItem("desktoVersion");
if (this.$dataStore.get("setting")) {
this.setting = this.$dataStore.get("setting");
} else {
......@@ -412,18 +414,18 @@ export default {
} catch (error) {
console.error("清理目录时发生错误:", error.msg);
}
if(this.factoryType!=='US'){
if (this.factoryType !== "US") {
const regex = /^[A-Z]{4}_/; //是否以四个大写字母加下划线开头
if (regex.test(this.productionNo)) {
this.productionNo =
this.productionNo.split("_")[0] +
"-" +
this.productionNo.split("_")[this.productionNo.split("_").length - 1];
this.productionNo.split("_")[
this.productionNo.split("_").length - 1
];
}
}
console.log(423, this.productionNo);
try {
......@@ -546,6 +548,7 @@ export default {
this.$store.commit("changeImgList", []);
console.log(347, store.state.desktopDevice);
},
async cutImgFn(arr) {
if (!arr.length) return arr;
console.log(arr);
......@@ -705,6 +708,7 @@ export default {
:show-file-list="false"
multiple
:before-upload="uploadImage"
style="height: 100%;"
>
<el-button style="height: 100%;margin:0 8px" size="small">
<i class="el-icon-picture" style="font-size: 15px;"></i>
......@@ -815,6 +819,9 @@ 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>-->
......@@ -1036,7 +1043,14 @@ export default {
::v-deep {
.el-select .el-input {
max-width: 150px;
max-width: 80px;
}
}
}
::v-deep {
.el-tooltip {
.el-upload--text {
height: 100%;
}
}
}
......
......@@ -249,7 +249,7 @@ export default {
});
},
moreImageCmd(arr) {
moreImageCmd() {
var canvas1 = document.createElement("canvas");
let _canvas = document.getElementsByClassName("sucaitu")[0]; //目标块
var bodyW = parseInt(window.getComputedStyle(_canvas).width);
......@@ -261,7 +261,7 @@ export default {
canvas1.style.background = "transparent";
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
var context = canvas1.getContext("2d");
// var context = canvas1.getContext("2d");
// context.scale(2, 2);
let that = this;
html2canvas(_canvas, {
......@@ -423,6 +423,8 @@ export default {
};
await this.toWritePrintLog(data);
console.log("data", data);
let res = await this.$api.post("/toPrint", data);
this.$message.success(res.msg);
},
......
......@@ -22,6 +22,7 @@ export default {
account: "",
password: "",
},
desktoVersion: "print",
};
},
computed: {
......@@ -96,6 +97,10 @@ 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>
......@@ -105,24 +110,35 @@ export default {
<div class="form-content">
<el-form ref="formRef" :rules="rules" size="small" :model="form">
<el-form-item v-if="userList.length > 0">
<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>
<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-form-item>
<el-form-item prop="factoryCode">
<el-input
......
......@@ -104,6 +104,10 @@ module.exports = {
to: "../print",
},
{
from: "./print4.0/",
to: "../print4.0",
},
{
from: "./logs/",
to: "../logs",
},
......
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