Commit b411806e by linjinhong

fix:添加工厂域名和跳过更新

parent 29646a5c
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict"; "use strict";
import { ipcMain } from "electron"; import { ipcMain, shell } from "electron";
import { app, protocol, BrowserWindow, globalShortcut } from "electron"; import { app, protocol, BrowserWindow, globalShortcut } from "electron";
import { createProtocol } from "vue-cli-plugin-electron-builder/lib"; import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
import { createServer } from "@/server/index.js"; import { createServer } from "@/server/index.js";
...@@ -69,6 +69,34 @@ async function createWindow() { ...@@ -69,6 +69,34 @@ async function createWindow() {
if (newWindow) newWindow.webContents.send("getProductionNoInfo", v); if (newWindow) newWindow.webContents.send("getProductionNoInfo", v);
}); });
ipcMain.on("open-file", async (event, filePath) => {
try {
// shell.openPath 会用系统默认应用打开文件
const result = await shell.openItem(filePath);
console.log(result);
return { success: true };
} catch (error) {
return {
success: false,
error: error.message,
};
}
});
// 在文件夹中显示并选中文件
ipcMain.on("show-file-in-folder", async (event, filePath) => {
try {
shell.showItemInFolder(filePath);
return { success: true };
} catch (error) {
return {
success: false,
error: error.message,
};
}
});
if (process.env.WEBPACK_DEV_SERVER_URL) { if (process.env.WEBPACK_DEV_SERVER_URL) {
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL); await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
if (!process.env.IS_TEST) win.webContents.openDevTools(); if (!process.env.IS_TEST) win.webContents.openDevTools();
...@@ -153,7 +181,7 @@ async function createWindow() { ...@@ -153,7 +181,7 @@ async function createWindow() {
path.dirname(app.getPath("exe")), path.dirname(app.getPath("exe")),
"resources", "resources",
"scripts", "scripts",
"script.ps1" "script.ps1",
); );
} }
...@@ -188,6 +216,8 @@ app.on("activate", async () => { ...@@ -188,6 +216,8 @@ app.on("activate", async () => {
app.on("ready", async () => { app.on("ready", async () => {
await createWindow(); await createWindow();
console.log("winURL", winURL);
// 获取当前窗口的尺寸 // 获取当前窗口的尺寸
const { width, height } = win.getBounds(); const { width, height } = win.getBounds();
win.webContents.send("window-size", { width, height }); win.webContents.send("window-size", { width, height });
......
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
}, },
rotating(data, item) { rotating(data, item) {
console.log(data); // console.log(data);
this.$set(item, "r", data.angle); this.$set(item, "r", data.angle);
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
}, },
......
...@@ -21,31 +21,37 @@ const { app } = require("electron"); ...@@ -21,31 +21,37 @@ const { app } = require("electron");
let fileEnv, env, visionUrl; let fileEnv, env, visionUrl;
axios.defaults.timeout = 12600000; axios.defaults.timeout = 12600000;
const multiparty = require("multiparty"); const multiparty = require("multiparty");
const { getVersion } = require("@/server/utils/store"); const { getVersion, setApi, getHostApi } = require("@/server/utils/store");
function getCurrentVersion() { function getCurrentVersion() {
const version = getVersion(); const version = getVersion();
console.log("version", version); // console.log("version", version);
return version; return version;
} }
function readEnv() { async function readEnv() {
let exePath, configPath; let exePath, configPath;
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
configPath = path.join(__dirname, "../config/env.json"); configPath = path.join(__dirname, "../config/env.json");
} else { } else {
exePath = path.dirname(app.getPath("exe")).replace(/\\/g, "/"); exePath = path.dirname(app.getPath("exe")).replace(/\\/g, "/");
console.log("exePath", exePath);
configPath = `${exePath}/config/env.json`; configPath = `${exePath}/config/env.json`;
} }
console.log(configPath, __dirname); console.log("configPath", configPath);
fs.readFile(configPath, "utf-8", (err, data) => { await fs.readFile(configPath, "utf-8", async (err, data) => {
if (err) { if (err) {
console.error("读取配置文件失败:", err); console.error("读取配置文件失败:", err);
return; return;
} }
const config = JSON.parse(data); const config = JSON.parse(data);
config.configPath = configPath;
await setApi(config);
console.log(53, config);
fileEnv = config.fileApiUrl; fileEnv = config.fileApiUrl;
env = config.apiApiHost; env = config.apiApiHost;
visionUrl = config.visionUrl; visionUrl = config.visionUrl;
...@@ -63,7 +69,7 @@ export default { ...@@ -63,7 +69,7 @@ export default {
let fileName = uuid.v4() + ".png"; let fileName = uuid.v4() + ".png";
const filePath = path.join( const filePath = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName `./${getCurrentVersion()}/Input/` + fileName,
); );
const writer = fs.createWriteStream(filePath); const writer = fs.createWriteStream(filePath);
...@@ -95,7 +101,7 @@ export default { ...@@ -95,7 +101,7 @@ export default {
let body = req.body; let body = req.body;
let p = path.join(returnLogFilePath(), "print.json"); let p = path.join(returnLogFilePath(), "print.json");
p = p.replace("\\api.log", ""); p = p.replace("\\api.log", "");
console.log(p); // console.log(p);
let data = []; let data = [];
if (!fs.existsSync(p)) { if (!fs.existsSync(p)) {
fs.writeFileSync(p, "[]"); fs.writeFileSync(p, "[]");
...@@ -168,6 +174,7 @@ export default { ...@@ -168,6 +174,7 @@ export default {
// } // }
// }, // },
downloadBySubOrderNumber: async (req, res) => { downloadBySubOrderNumber: async (req, res) => {
env = getHostApi().apiApiHost;
const params = req.body; const params = req.body;
const token = req.headers["jwt-token"]; const token = req.headers["jwt-token"];
...@@ -200,6 +207,7 @@ export default { ...@@ -200,6 +207,7 @@ export default {
const downloadFunc = const downloadFunc =
params.device === 1 ? downloadImage : downloadOtherImage; params.device === 1 ? downloadImage : downloadOtherImage;
const result = await downloadFunc(files); const result = await downloadFunc(files);
res.setHeader("X-Backend-Request-URL", url);
res.json({ code: 200, data: result }); res.json({ code: 200, data: result });
} catch (err) { } catch (err) {
...@@ -209,6 +217,7 @@ export default { ...@@ -209,6 +217,7 @@ export default {
} }
}, },
findByPodProductionNo: async (req, res) => { findByPodProductionNo: async (req, res) => {
env = getHostApi().apiApiHost;
const token = req.headers["jwt-token"]; const token = req.headers["jwt-token"];
const params = req.body; const params = req.body;
...@@ -231,15 +240,18 @@ export default { ...@@ -231,15 +240,18 @@ export default {
}; };
let url = urlArr[params.orderType].url; let url = urlArr[params.orderType].url;
let paramsField = urlArr[params.orderType].field; let paramsField = urlArr[params.orderType].field;
console.log("url", url); // console.log("url", url);
console.log("paramsField", paramsField); // console.log("paramsField", paramsField);
console.log("thirdSubOrderNumber", params.thirdSubOrderNumber); // console.log("thirdSubOrderNumber", params.thirdSubOrderNumber);
console.log(`187,${env}/${url}`);
let { data } = await axios.get(`${env}/${url}`, { let { data } = await axios.get(`${env}/${url}`, {
params: { params: {
[paramsField]: params.thirdSubOrderNumber, [paramsField]: params.thirdSubOrderNumber,
}, },
headers: { "jwt-token": token }, headers: { "jwt-token": token },
}); });
res.setHeader("X-Backend-Request-URL", url);
res.json(data); res.json(data);
} catch (err) { } catch (err) {
res.json({ code: 500, msg: err }); res.json({ code: 500, msg: err });
...@@ -248,16 +260,18 @@ export default { ...@@ -248,16 +260,18 @@ export default {
getCompanyList: async (req, res) => { getCompanyList: async (req, res) => {
try { try {
let { data } = await axios.get( let { data } = await axios.get(
"https://platform.jomalls.com/api/tools/getCompanyList" "https://platform.jomalls.com/api/tools/getCompanyList",
); );
res.setHeader("X-Backend-Request-URL", "api/tools/getCompanyList");
res.send(data); res.send(data);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
res.json({ code: 500, msg: err }); res.json({ code: 500, msg: err });
} }
}, },
commitApply: async () => { }, commitApply: async () => {},
completeDelivery: async (req, res) => { completeDelivery: async (req, res) => {
env = getHostApi().apiApiHost;
const token = req.headers["jwt-token"]; const token = req.headers["jwt-token"];
const params = req.body; const params = req.body;
const urlArr = { const urlArr = {
...@@ -283,13 +297,15 @@ export default { ...@@ -283,13 +297,15 @@ export default {
let url = urlArr[params.orderType].url; let url = urlArr[params.orderType].url;
let postData = urlArr[params.orderType].data; let postData = urlArr[params.orderType].data;
console.log("postData", postData); // console.log("postData", postData);
console.log("240url", url); // console.log("240url", url);
try { try {
let { data } = await axios.post(`${env}/${url}`, postData, { let { data } = await axios.post(`${env}/${url}`, postData, {
headers: { "jwt-token": token }, headers: { "jwt-token": token },
}); });
res.setHeader("X-Backend-Request-URL", url);
res.send(data); res.send(data);
} catch (err) { } catch (err) {
console.log(err); console.log(err);
...@@ -305,7 +321,7 @@ export default { ...@@ -305,7 +321,7 @@ export default {
for (let k in q.imgList) { for (let k in q.imgList) {
const p = path.join( const p = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` + q.imgList[k].fileName `./${getCurrentVersion()}/Input/` + q.imgList[k].fileName,
); );
zipStream.addEntry(p); zipStream.addEntry(p);
} }
...@@ -314,7 +330,7 @@ export default { ...@@ -314,7 +330,7 @@ export default {
zipStream zipStream
.pipe(destStream) .pipe(destStream)
.on("finish", () => { .on("finish", () => {
console.log("success"); // console.log("success");
res.json({ res.json({
code: 200, code: 200,
msg: q.productionNo + ".zip" + "已下载到桌面", msg: q.productionNo + ".zip" + "已下载到桌面",
...@@ -332,11 +348,11 @@ export default { ...@@ -332,11 +348,11 @@ export default {
try { try {
const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`); const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
let fileName = uuid.v4() + ".png"; let fileName = uuid.v4() + ".png";
console.log(fileName); // console.log(fileName);
const form = new multiparty.Form({ uploadDir: p }); const form = new multiparty.Form({ uploadDir: p });
form.parse(req, function (err, fields, files) { form.parse(req, function(err, fields, files) {
console.log(fields, files, err); // console.log(fields, files, err);
if (err) { if (err) {
res.send({ code: 500, err }); res.send({ code: 500, err });
} else { } else {
...@@ -347,7 +363,7 @@ export default { ...@@ -347,7 +363,7 @@ export default {
fileName, fileName,
url: path.join( url: path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName `./${getCurrentVersion()}/Input/` + fileName,
), ),
}, },
}); });
...@@ -362,7 +378,7 @@ export default { ...@@ -362,7 +378,7 @@ export default {
try { try {
const filePath = path.join( const filePath = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/${req.body.fileName}` `./${getCurrentVersion()}/Input/${req.body.fileName}`,
); );
console.log(filePath); console.log(filePath);
// 给客户端返回一个文件流 type类型 // 给客户端返回一个文件流 type类型
...@@ -371,10 +387,10 @@ export default { ...@@ -371,10 +387,10 @@ export default {
let responseData = []; //存储文件流 let responseData = []; //存储文件流
if (stream) { if (stream) {
//判断状态 //判断状态
stream.on("data", function (chunk) { stream.on("data", function(chunk) {
responseData.push(chunk); responseData.push(chunk);
}); });
stream.on("end", function () { stream.on("end", function() {
const finalData = Buffer.concat(responseData); const finalData = Buffer.concat(responseData);
res.write(finalData); res.write(finalData);
res.end(); res.end();
...@@ -439,7 +455,7 @@ export default { ...@@ -439,7 +455,7 @@ export default {
console.log(req.body.url, "下载zip地址"); console.log(req.body.url, "下载zip地址");
request(req.body.url) request(req.body.url)
.pipe(stream) .pipe(stream)
.on("close", function () { .on("close", function() {
compressing.zip compressing.zip
.uncompress(from, dirName, { zipFileNameEncoding: "gbk" }) .uncompress(from, dirName, { zipFileNameEncoding: "gbk" })
.then(() => { .then(() => {
...@@ -523,8 +539,8 @@ export default { ...@@ -523,8 +539,8 @@ export default {
try { try {
const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`); const p = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
const form = new multiparty.Form({ uploadDir: p }); const form = new multiparty.Form({ uploadDir: p });
form.parse(req, function (err, fields, files) { form.parse(req, function(err, fields, files) {
console.log(367, fields, files, err); // console.log(367, fields, files, err);
if (err) { if (err) {
res.send({ code: 500, err }); res.send({ code: 500, err });
} else { } else {
...@@ -536,7 +552,7 @@ export default { ...@@ -536,7 +552,7 @@ export default {
fileName, fileName,
url: path.join( url: path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` + fileName `./${getCurrentVersion()}/Input/` + fileName,
), ),
}); });
}); });
......
...@@ -10,7 +10,7 @@ const { getVersion } = require("@/server/utils/store"); ...@@ -10,7 +10,7 @@ const { getVersion } = require("@/server/utils/store");
function getCurrentVersion() { function getCurrentVersion() {
const version = getVersion(); const version = getVersion();
console.log("version", version); // console.log("version", version);
return version; return version;
} }
...@@ -18,7 +18,7 @@ function getCurrentVersion() { ...@@ -18,7 +18,7 @@ function getCurrentVersion() {
function zip(from, to) { function zip(from, to) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let dirName = path.join(to, uuid.v4()); let dirName = path.join(to, uuid.v4());
console.log(dirName); // console.log(dirName);
if (!fs.existsSync(dirName)) { if (!fs.existsSync(dirName)) {
fs.mkdirSync(dirName); fs.mkdirSync(dirName);
} }
...@@ -136,7 +136,7 @@ export const downloadImage = (list) => { ...@@ -136,7 +136,7 @@ export const downloadImage = (list) => {
try { try {
const dirPath = path.join( const dirPath = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` `./${getCurrentVersion()}/Input/`,
); );
// 创建目录(如果不存在) // 创建目录(如果不存在)
...@@ -146,7 +146,7 @@ export const downloadImage = (list) => { ...@@ -146,7 +146,7 @@ export const downloadImage = (list) => {
// 过滤出有效的下载项 // 过滤出有效的下载项
const downloadItems = list.filter( const downloadItems = list.filter(
(item) => item.url && item.url.includes("http") (item) => item.url && item.url.includes("http"),
); );
// 如果没有需要下载的项,直接返回 // 如果没有需要下载的项,直接返回
...@@ -169,7 +169,7 @@ export const downloadImage = (list) => { ...@@ -169,7 +169,7 @@ export const downloadImage = (list) => {
".bz2", ".bz2",
]; ];
const isArchive = archiveExtensions.some((ext) => const isArchive = archiveExtensions.some((ext) =>
item.url.toLowerCase().includes(ext) item.url.toLowerCase().includes(ext),
); );
const fileName = isArchive const fileName = isArchive
...@@ -245,7 +245,7 @@ export function downloadOtherImage(list) { ...@@ -245,7 +245,7 @@ export function downloadOtherImage(list) {
// 将当前中国时间格式化为ISO字符串 // 将当前中国时间格式化为ISO字符串
let isoString = chinaTime.toISOString(); let isoString = chinaTime.toISOString();
console.log("Original China Time ISO String:", isoString); // 检查格式 // console.log("Original China Time ISO String:", isoString); // 检查格式
// 替换掉时间中的 ':' 字符 // 替换掉时间中的 ':' 字符
const folderName = const folderName =
...@@ -257,7 +257,7 @@ export function downloadOtherImage(list) { ...@@ -257,7 +257,7 @@ export function downloadOtherImage(list) {
.split(".")[0]; .split(".")[0];
let otherTypePath = path.join( let otherTypePath = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/${folderName}` `./${getCurrentVersion()}/Input/${folderName}`,
); );
if (!fs.existsSync(otherTypePath)) { if (!fs.existsSync(otherTypePath)) {
fs.mkdirSync(otherTypePath); fs.mkdirSync(otherTypePath);
...@@ -328,7 +328,7 @@ export function downloadOtherImage(list) { ...@@ -328,7 +328,7 @@ export function downloadOtherImage(list) {
export const sendImg = (filename = "sample.png") => { export const sendImg = (filename = "sample.png") => {
let filePath = path.join( let filePath = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Input/` + filename `./${getCurrentVersion()}/Input/` + filename,
); );
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
return false; return false;
...@@ -364,23 +364,23 @@ export const toSend = (body) => { ...@@ -364,23 +364,23 @@ export const toSend = (body) => {
process.cwd(), process.cwd(),
`${getCurrentVersion()}/Profile/` + `${getCurrentVersion()}/Profile/` +
body.fileName.replace(".png", "") + body.fileName.replace(".png", "") +
".xml" ".xml",
) ),
); );
fs.unlinkSync( fs.unlinkSync(
path.join( path.join(
process.cwd(), process.cwd(),
`${getCurrentVersion()}/Output/` + `${getCurrentVersion()}/Output/` +
body.fileName.replace(".png", "") + body.fileName.replace(".png", "") +
".arxp" ".arxp",
) ),
); );
resolve("操作成功"); resolve("操作成功");
} else { } else {
const errorDetails = `打印命令失败: ${err2.message}`; const errorDetails = `打印命令失败: ${err2.message}`;
return reject(`打印机错误: ${errorDetails}`); return reject(`打印机错误: ${errorDetails}`);
} }
} },
); );
} else { } else {
// const errorCode = err.code || "UNKNOWN_ERROR"; // const errorCode = err.code || "UNKNOWN_ERROR";
...@@ -393,119 +393,122 @@ export const toSend = (body) => { ...@@ -393,119 +393,122 @@ export const toSend = (body) => {
const errorDetails = "未匹配到对应版本的驱动,请检查驱动"; const errorDetails = "未匹配到对应版本的驱动,请检查驱动";
return reject(errorDetails); return reject(errorDetails);
} }
} },
); );
}); });
}; };
export const writeProfileXml = (b) => { export const writeProfileXml = (b) => {
console.log(b); // console.log(b);
try { try {
let p = path.join( let p = path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Profile/${b.byInk}.xml` `./${getCurrentVersion()}/Profile/${b.byInk}.xml`,
); );
let file = fs.readFileSync(p, { encoding: "utf8" }); let file = fs.readFileSync(p, { encoding: "utf8" });
file = file.replace( file = file.replace(
/<uiCopies>(.*)<\/uiCopies>/i, /<uiCopies>(.*)<\/uiCopies>/i,
`<uiCopies>${b.printNum}</uiCopies>` `<uiCopies>${b.printNum}</uiCopies>`,
); );
file = file.replace( file = file.replace(
/<byPlatenSize>(.*)<\/byPlatenSize>/i, /<byPlatenSize>(.*)<\/byPlatenSize>/i,
`<byPlatenSize>${b.byPlatenSize}</byPlatenSize>` `<byPlatenSize>${b.byPlatenSize}</byPlatenSize>`,
); );
file = file.replace( file = file.replace(
/<bEcoMode>(.*)<\/bEcoMode>/i, /<bEcoMode>(.*)<\/bEcoMode>/i,
`<bEcoMode>${b.bEcoMode}</bEcoMode>` `<bEcoMode>${b.bEcoMode}</bEcoMode>`,
); );
file = file.replace( file = file.replace(
/<bMaterialBlack>(.*)<\/bMaterialBlack>/i, /<bMaterialBlack>(.*)<\/bMaterialBlack>/i,
`<bMaterialBlack>${b.bMaterialBlack}</bMaterialBlack>` `<bMaterialBlack>${b.bMaterialBlack}</bMaterialBlack>`,
); );
file = file.replace( file = file.replace(
/<byHighlight>(.*)<\/byHighlight>/i, /<byHighlight>(.*)<\/byHighlight>/i,
`<byHighlight>${b.byHighlight}</byHighlight>` `<byHighlight>${b.byHighlight}</byHighlight>`,
); );
file = file.replace( file = file.replace(
/<byMask>(.*)<\/byMask>/i, /<byMask>(.*)<\/byMask>/i,
`<byMask>${b.byMask}</byMask>` `<byMask>${b.byMask}</byMask>`,
); );
file = file.replace( file = file.replace(
/<bTransColor>(.*)<\/bTransColor>/i, /<bTransColor>(.*)<\/bTransColor>/i,
`<bTransColor>${b.bTransColor}</bTransColor>` `<bTransColor>${b.bTransColor}</bTransColor>`,
); );
file = file.replace( file = file.replace(
/<bPause>(.*)<\/bPause>/i, /<bPause>(.*)<\/bPause>/i,
`<bPause>${b.bPause}</bPause>` `<bPause>${b.bPause}</bPause>`,
); );
file = file.replace( file = file.replace(
/<bDivide>(.*)<\/bDivide>/i, /<bDivide>(.*)<\/bDivide>/i,
`<bDivide>${b.bDivide}</bDivide>` `<bDivide>${b.bDivide}</bDivide>`,
); );
file = file.replace( file = file.replace(
/<byChoke>(.*)<\/byChoke>/i, /<byChoke>(.*)<\/byChoke>/i,
`<byChoke>${b.byChoke}</byChoke>` `<byChoke>${b.byChoke}</byChoke>`,
); );
file = file.replace(/<byInk>(.*)<\/byInk>/i, `<byInk>${b.byInk}</byInk>`); file = file.replace(/<byInk>(.*)<\/byInk>/i, `<byInk>${b.byInk}</byInk>`);
file = file.replace( file = file.replace(
/<bFastMode>(.*)<\/bFastMode>/i, /<bFastMode>(.*)<\/bFastMode>/i,
`<bFastMode>${b.bFastMode}</bFastMode>` `<bFastMode>${b.bFastMode}</bFastMode>`,
); );
file = file.replace( file = file.replace(
/<byResolution>(.*)<\/byResolution>/i, /<byResolution>(.*)<\/byResolution>/i,
`<byResolution>${1}</byResolution>` `<byResolution>${1}</byResolution>`,
); );
file = file.replace( file = file.replace(
/<byInkVolume>(.*)<\/byInkVolume>/i, /<byInkVolume>(.*)<\/byInkVolume>/i,
`<byInkVolume>${b.byInkVolume}</byInkVolume>` `<byInkVolume>${b.byInkVolume}</byInkVolume>`,
); );
file = file.replace( file = file.replace(
/<byDoublePrint>(.*)<\/byDoublePrint>/i, /<byDoublePrint>(.*)<\/byDoublePrint>/i,
`<byDoublePrint>${b.byDoublePrint}</byDoublePrint>` `<byDoublePrint>${b.byDoublePrint}</byDoublePrint>`,
); );
file = file.replace( file = file.replace(
/<bMultiple>(.*)<\/bMultiple>/i, /<bMultiple>(.*)<\/bMultiple>/i,
`<bMultiple>${b.bMultiple}</bMultiple>` `<bMultiple>${b.bMultiple}</bMultiple>`,
); );
file = file.replace( file = file.replace(
/<bySaturation>(.*)<\/bySaturation>/i, /<bySaturation>(.*)<\/bySaturation>/i,
`<bySaturation>${b.bySaturation}</bySaturation>` `<bySaturation>${b.bySaturation}</bySaturation>`,
); );
file = file.replace( file = file.replace(
/<byBrightness>(.*)<\/byBrightness>/i, /<byBrightness>(.*)<\/byBrightness>/i,
`<byBrightness>${b.byBrightness}</byBrightness>` `<byBrightness>${b.byBrightness}</byBrightness>`,
); );
file = file.replace( file = file.replace(
/<byContrast>(.*)<\/byContrast>/i, /<byContrast>(.*)<\/byContrast>/i,
`<byContrast>${b.byContrast}</byContrast>` `<byContrast>${b.byContrast}</byContrast>`,
); );
file = file.replace( file = file.replace(
/<iCyanBalance>(.*)<\/iCyanBalance>/i, /<iCyanBalance>(.*)<\/iCyanBalance>/i,
`<iCyanBalance>${b.iCyanBalance}</iCyanBalance>` `<iCyanBalance>${b.iCyanBalance}</iCyanBalance>`,
); );
file = file.replace( file = file.replace(
/<iMagentaBalance>(.*)<\/iMagentaBalance>/i, /<iMagentaBalance>(.*)<\/iMagentaBalance>/i,
`<iMagentaBalance>${b.iMagentaBalance}</iMagentaBalance>` `<iMagentaBalance>${b.iMagentaBalance}</iMagentaBalance>`,
); );
file = file.replace( file = file.replace(
/<iYellowBalance>(.*)<\/iYellowBalance>/i, /<iYellowBalance>(.*)<\/iYellowBalance>/i,
`<iYellowBalance>${b.iYellowBalance}</iYellowBalance>` `<iYellowBalance>${b.iYellowBalance}</iYellowBalance>`,
); );
file = file.replace( file = file.replace(
/<iBlackBalance>(.*)<\/iBlackBalance>/i, /<iBlackBalance>(.*)<\/iBlackBalance>/i,
`<iBlackBalance>${b.iBlackBalance}</iBlackBalance>` `<iBlackBalance>${b.iBlackBalance}</iBlackBalance>`,
); );
file = file.replace( file = file.replace(
/<bUniPrint>(.*)<\/bUniPrint>/i, /<bUniPrint>(.*)<\/bUniPrint>/i,
`<bUniPrint>${b.bUniPrint}</bUniPrint>` `<bUniPrint>${b.bUniPrint}</bUniPrint>`,
); );
fs.writeFileSync( fs.writeFileSync(
path.join( path.join(
process.cwd(), process.cwd(),
`./${getCurrentVersion()}/Profile/${b.fileName.replace(".png", "")}.xml` `./${getCurrentVersion()}/Profile/${b.fileName.replace(
".png",
"",
)}.xml`,
), ),
file file,
); );
} catch (err) { } catch (err) {
console.log(404, err); console.log(404, err);
......
...@@ -30,8 +30,8 @@ async function cropImageTransparentEdges(inputPath, outputPath, options = {}) { ...@@ -30,8 +30,8 @@ async function cropImageTransparentEdges(inputPath, outputPath, options = {}) {
.toBuffer({ resolveWithObject: true }); .toBuffer({ resolveWithObject: true });
const { width, height, channels } = info; const { width, height, channels } = info;
console.log("width", width); // console.log("width", width);
console.log("height", height); // console.log("height", height);
// 找到图片的边界 // 找到图片的边界
let topmost = height; let topmost = height;
...@@ -68,8 +68,8 @@ async function cropImageTransparentEdges(inputPath, outputPath, options = {}) { ...@@ -68,8 +68,8 @@ async function cropImageTransparentEdges(inputPath, outputPath, options = {}) {
// 计算裁切区域 // 计算裁切区域
const cropWidth = rightmost - leftmost + 1; const cropWidth = rightmost - leftmost + 1;
const cropHeight = bottommost - topmost + 1; const cropHeight = bottommost - topmost + 1;
console.log("metadatawidth", metadata.width); // console.log("metadatawidth", metadata.width);
console.log("metadataheight", metadata.height); // console.log("metadataheight", metadata.height);
// 裁切并保存图片 // 裁切并保存图片
await sharp(inputPath) await sharp(inputPath)
.extract({ .extract({
...@@ -164,15 +164,17 @@ async function processImages(inputPath, outputPath, options = {}) { ...@@ -164,15 +164,17 @@ async function processImages(inputPath, outputPath, options = {}) {
console.log("处理完成!"); console.log("处理完成!");
console.log( console.log(
`成功处理: ${results.filter((r) => r.status === "cropped").length} 张图片` `成功处理: ${
results.filter((r) => r.status === "cropped").length
} 张图片`,
); );
console.log( console.log(
`保持不变: ${ `保持不变: ${
results.filter((r) => r.status === "unchanged").length results.filter((r) => r.status === "unchanged").length
} 张图片` } 张图片`,
); );
console.log( console.log(
`处理失败: ${results.filter((r) => r.status === "error").length} 张图片` `处理失败: ${results.filter((r) => r.status === "error").length} 张图片`,
); );
return results; return results;
...@@ -265,11 +267,11 @@ async function cropImage(inputPath, outputPath, options = {}) { ...@@ -265,11 +267,11 @@ async function cropImage(inputPath, outputPath, options = {}) {
// 计算裁剪区域 // 计算裁剪区域
const cropWidth = Math.min( const cropWidth = Math.min(
width - bounds.left, width - bounds.left,
bounds.right - bounds.left + 1 bounds.right - bounds.left + 1,
); );
const cropHeight = Math.min( const cropHeight = Math.min(
height - bounds.top, height - bounds.top,
bounds.bottom - bounds.top + 1 bounds.bottom - bounds.top + 1,
); );
if (cropWidth <= 0 || cropHeight <= 0) { if (cropWidth <= 0 || cropHeight <= 0) {
...@@ -373,7 +375,7 @@ async function processInStreamMode(inputPath, bounds, options) { ...@@ -373,7 +375,7 @@ async function processInStreamMode(inputPath, bounds, options) {
// 调试信息 // 调试信息
if (debug && y % (stripHeight * 10) === 0) { if (debug && y % (stripHeight * 10) === 0) {
console.log( console.log(
`流式处理进度: ${y}/${height} (${Math.round((y / height) * 100)}%)` `流式处理进度: ${y}/${height} (${Math.round((y / height) * 100)}%)`,
); );
} }
} }
......
...@@ -2,13 +2,38 @@ const Store = require("electron-store"); ...@@ -2,13 +2,38 @@ const Store = require("electron-store");
const store = new Store({ watch: false }); const store = new Store({ watch: false });
module.exports = { module.exports = {
//存储当前打印驱动版本
setVersion: (version) => { setVersion: (version) => {
store.set("desktoVersion", version); store.set("desktoVersion", version);
}, },
getVersion: () => store.get("desktoVersion") || "print", getVersion: () => store.get("desktoVersion") || "print",
//跳过更新和储存更新
setSkip: (value) => {
store.set("skipValue", value);
},
getSkipValue: () => store.get("skipValue") || 2,
setSkipVersion: (value) => {
store.set("skipVersion", value);
},
getSkipVersion: () => store.get("skipVersion") || "1.0",
//储存env环境域名
setApi: (value) => {
store.set("hostApi", value);
},
getHostApi: () =>
store.get("hostApi") || {
apiApiHost: "https://factory.jomalls.com/api",
fileApiUrl: "https://factory.jomalls.com/upload/factory",
visionUrl: "https://console.jomalls.com",
configPath: "",
},
//
setBoard: (version) => { setBoard: (version) => {
store.set("desktoBoard", version); store.set("desktoBoard", version);
console.log("store", store.get("desktoBoard"));
}, },
getBoard: () => store.get("desktoBoard") || 3, getBoard: () => store.get("desktoBoard") || 3,
}; };
import store from "@/store"; import store from "@/store";
import Vue from "vue";
//px转换mm
export function pxToUnit(px, unit) { export function pxToUnit(px, unit) {
const setting = this.$dataStore.get("setting"); const setting = this.$dataStore.get("setting");
if (!unit) { if (!unit) {
...@@ -118,7 +119,7 @@ export const cutArea = (canvasEl, mousewheel) => { ...@@ -118,7 +119,7 @@ export const cutArea = (canvasEl, mousewheel) => {
canvasEl.maskDiv.appendChild(mask_img); canvasEl.maskDiv.appendChild(mask_img);
insertAfter( insertAfter(
canvasEl.maskDiv, canvasEl.maskDiv,
document.getElementById(canvasEl.cutCanvas.id) document.getElementById(canvasEl.cutCanvas.id),
); );
} }
......
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
} },
).then(() => { ).then(() => {
this.setData(); this.setData();
}); });
...@@ -184,7 +184,7 @@ export default { ...@@ -184,7 +184,7 @@ export default {
]); ]);
} }
const result = []; const result = [];
console.log(arr); // console.log(arr);
arr = arr.filter((el) => el.url); arr = arr.filter((el) => el.url);
arr = arr.map((el) => { arr = arr.map((el) => {
return { return {
...@@ -201,7 +201,7 @@ export default { ...@@ -201,7 +201,7 @@ export default {
result.push(arr.slice(i, i + 2)); result.push(arr.slice(i, i + 2));
} }
d.imgList = result; d.imgList = result;
console.log(d.imgList, "this.detail.imgList "); // console.log(d.imgList, "this.detail.imgList ");
this.detail = d; this.detail = d;
// 自动下载素材 // 自动下载素材
// if (this.isDownloadImage) { // if (this.isDownloadImage) {
...@@ -270,7 +270,7 @@ export default { ...@@ -270,7 +270,7 @@ export default {
@click=" @click="
downloadAllWe( downloadAllWe(
it.title && it.title === '正面' ? 1 : 2, it.title && it.title === '正面' ? 1 : 2,
it.id it.id,
) )
" "
v-if="it.id" v-if="it.id"
......
...@@ -90,27 +90,27 @@ export default { ...@@ -90,27 +90,27 @@ export default {
this.$dataStore.set("default-print-setting", this.printSetting); this.$dataStore.set("default-print-setting", this.printSetting);
this.getPrintSettingList(() => { this.getPrintSettingList(() => {
let select = this.$dataStore.get("print-setting-select"); let select = this.$dataStore.get("print-setting-select");
console.log(this.$dataStore, "select"); // console.log(this.$dataStore, "select");
if (select) { if (select) {
this.printSettingSelectLabel = select; this.printSettingSelectLabel = select;
let index = this.printSettingList.findIndex( let index = this.printSettingList.findIndex(
(el) => el.label === select (el) => el.label === select,
); );
if (index >= 0) { if (index >= 0) {
this.printSettingVal = index; this.printSettingVal = index;
this.printSetting = JSON.parse( this.printSetting = JSON.parse(
JSON.stringify(this.printSettingList[index].value) JSON.stringify(this.printSettingList[index].value),
); );
} else { } else {
this.printSettingVal = 0; this.printSettingVal = 0;
this.printSetting = JSON.parse( this.printSetting = JSON.parse(
JSON.stringify(this.printSettingList[0].value) JSON.stringify(this.printSettingList[0].value),
); );
} }
} else { } else {
this.printSettingVal = 0; this.printSettingVal = 0;
this.printSetting = JSON.parse( this.printSetting = JSON.parse(
JSON.stringify(this.printSettingList[0].value) JSON.stringify(this.printSettingList[0].value),
); );
} }
}); });
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
pxToUnit, pxToUnit,
getWHproportion(data) { getWHproportion(data) {
const { gridValue } = this.$dataStore.get("setting"); const { gridValue } = this.$dataStore.get("setting");
console.log(152, this.grid[gridValue].col); // console.log(152, this.grid[gridValue].col);
if (this.grid[gridValue].col == 8) { if (this.grid[gridValue].col == 8) {
return data + 1.8; return data + 1.8;
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
type: "warning", type: "warning",
}).then(() => { }).then(() => {
this.$dataStore.delete( this.$dataStore.delete(
this.printSettingList[this.printSettingVal].label + "-print-setting" this.printSettingList[this.printSettingVal].label + "-print-setting",
); );
this.getPrintSettingList(); this.getPrintSettingList();
this.printSettingVal = 0; this.printSettingVal = 0;
...@@ -195,7 +195,7 @@ export default { ...@@ -195,7 +195,7 @@ export default {
let label = this.printSettingList[v].label; let label = this.printSettingList[v].label;
this.$dataStore.set("print-setting-select", label); this.$dataStore.set("print-setting-select", label);
this.printSetting = JSON.parse( this.printSetting = JSON.parse(
JSON.stringify(this.printSettingList[v].value) JSON.stringify(this.printSettingList[v].value),
); );
}, },
saveSetting() { saveSetting() {
...@@ -207,7 +207,7 @@ export default { ...@@ -207,7 +207,7 @@ export default {
} }
this.$dataStore.set( this.$dataStore.set(
`${this.settingName}-print-setting`, `${this.settingName}-print-setting`,
this.printSetting this.printSetting,
); );
this.showPopover = false; this.showPopover = false;
this.printSettingVal = this.printSettingList.length; this.printSettingVal = this.printSettingList.length;
...@@ -247,7 +247,7 @@ export default { ...@@ -247,7 +247,7 @@ export default {
} }
// 不足四位前面用0补齐 // 不足四位前面用0补齐
console.log(str); // console.log(str);
return str; return str;
}, },
...@@ -302,7 +302,7 @@ export default { ...@@ -302,7 +302,7 @@ export default {
let w_mm = Number((canvas1.width * 0.84183).toFixed(1)); let w_mm = Number((canvas1.width * 0.84183).toFixed(1));
let h_mm = Number((canvas1.height * 0.84183).toFixed(1)); let h_mm = Number((canvas1.height * 0.84183).toFixed(1));
let size = `${that.singleStr(Number(w_mm).toFixed(1))}${that.singleStr( let size = `${that.singleStr(Number(w_mm).toFixed(1))}${that.singleStr(
Number(h_mm).toFixed(1) Number(h_mm).toFixed(1),
)}`; )}`;
await that.sendCmd(data.fileName, size, "00000000", 0); await that.sendCmd(data.fileName, size, "00000000", 0);
//canvas转换成url,然后利用a标签的download属性,直接下载,绕过上传服务器再下载 //canvas转换成url,然后利用a标签的download属性,直接下载,绕过上传服务器再下载
...@@ -318,8 +318,8 @@ export default { ...@@ -318,8 +318,8 @@ export default {
// 使用getBoundingClientRect获取更精确的位置信息 // 使用getBoundingClientRect获取更精确的位置信息
const imageRect = image.getBoundingClientRect(); const imageRect = image.getBoundingClientRect();
const lineRect = line.getBoundingClientRect(); const lineRect = line.getBoundingClientRect();
console.log("lineRect", lineRect); // console.log("lineRect", lineRect);
console.log("imageRect", imageRect); // console.log("imageRect", imageRect);
// 计算image相对于line的坐标位置 // 计算image相对于line的坐标位置
const relativeX = imageRect.left - lineRect.left; const relativeX = imageRect.left - lineRect.left;
...@@ -327,19 +327,19 @@ export default { ...@@ -327,19 +327,19 @@ export default {
// 获取图片的宽高 // 获取图片的宽高
let w = image.clientWidth / this.getWHproportion(this.WHproportion); // 图片宽 let w = image.clientWidth / this.getWHproportion(this.WHproportion); // 图片宽
let h = image.clientHeight / this.getWHproportion(this.WHproportion); // 图片高 let h = image.clientHeight / this.getWHproportion(this.WHproportion); // 图片高
console.log(w, h, "w,h"); // console.log(w, h, "w,h");
const x = relativeX / this.getWHproportion(this.WHproportion); const x = relativeX / this.getWHproportion(this.WHproportion);
const y = relativeY / this.getWHproportion(this.WHproportion); const y = relativeY / this.getWHproportion(this.WHproportion);
let r = this.imgList[0].r; let r = this.imgList[0].r;
console.log(x, y, "x,y"); // console.log(x, y, "x,y");
const x_mm = this.pxToUnit(x, "mm"); const x_mm = this.pxToUnit(x, "mm");
const y_mm = this.pxToUnit(y, "mm"); const y_mm = this.pxToUnit(y, "mm");
const w_mm = this.pxToUnit(w, "mm"); const w_mm = this.pxToUnit(w, "mm");
const h_mm = this.pxToUnit(h, "mm"); const h_mm = this.pxToUnit(h, "mm");
console.log("x_mm", x_mm); // console.log("x_mm", x_mm);
console.log("y_mm", y_mm); // console.log("y_mm", y_mm);
console.log("w_mm", w_mm); // console.log("w_mm", w_mm);
console.log("h_mm", h_mm); // console.log("h_mm", h_mm);
if (r < 0) { if (r < 0) {
r = 360 - Math.abs(r); r = 360 - Math.abs(r);
} }
...@@ -396,7 +396,7 @@ export default { ...@@ -396,7 +396,7 @@ export default {
y = this.numberToStr4(y); y = this.numberToStr4(y);
w = this.numberToStr4(w); w = this.numberToStr4(w);
h = this.numberToStr4(h); h = this.numberToStr4(h);
console.log("print", w, h); // console.log("print", w, h);
// //
// if (w > 4200 || h > 4700) { // if (w > 4200 || h > 4700) {
// return this.$message.warning( // return this.$message.warning(
...@@ -414,26 +414,25 @@ export default { ...@@ -414,26 +414,25 @@ export default {
} }
size = `${w}${h}`; size = `${w}${h}`;
console.log(position, size);
await this.sendCmd(imgFileName, size, position, r); await this.sendCmd(imgFileName, size, position, r);
}, },
async sendCmd(imgFileName, size, position, r) { async sendCmd(imgFileName, size, position, r) {
console.log(402, getVersion()); // console.log(402, getVersion());
const printCmd = const printCmd =
getVersion() === "print600" ? "GTX6CMD.exe" : "GTXproCMD.exe"; getVersion() === "print600" ? "GTX6CMD.exe" : "GTXproCMD.exe";
const whitePrint = [1, 2].includes(this.printSetting.byInk) ? 1 : 0; // 白色打印 const whitePrint = [1, 2].includes(this.printSetting.byInk) ? 1 : 0; // 白色打印
let cmd = `${printCmd} print -X "${`Profile\\${imgFileName.replace( let cmd = `${printCmd} print -X "${`Profile\\${imgFileName.replace(
".png", ".png",
"" "",
)}.xml`}" -I "${"Input\\" + )}.xml`}" -I "${"Input\\" +
imgFileName}" -A "Output\\${imgFileName.replace( imgFileName}" -A "Output\\${imgFileName.replace(
".png", ".png",
"" "",
)}.arxp" -S ${size} -L ${position} -D ${r} -W ${whitePrint}`; )}.arxp" -S ${size} -L ${position} -D ${r} -W ${whitePrint}`;
let print_cmd = `${printCmd} send -A "Output\\${imgFileName.replace( let print_cmd = `${printCmd} send -A "Output\\${imgFileName.replace(
".png", ".png",
"" "",
)}.arxp" -P "${this.printer}`; )}.arxp" -P "${this.printer}`;
let data = { let data = {
...this.printSetting, ...this.printSetting,
...@@ -446,7 +445,7 @@ export default { ...@@ -446,7 +445,7 @@ export default {
}; };
await this.toWritePrintLog(data); await this.toWritePrintLog(data);
console.log("data", data); // console.log("data", data);
let res = await this.$api.post("/toPrint", data); let res = await this.$api.post("/toPrint", data);
this.$message.success(res.msg); this.$message.success(res.msg);
...@@ -476,7 +475,7 @@ export default { ...@@ -476,7 +475,7 @@ export default {
async getPrinter() { async getPrinter() {
ipcRenderer.send("allPrint"); ipcRenderer.send("allPrint");
ipcRenderer.once("printName", (event, data) => { ipcRenderer.once("printName", (event, data) => {
console.log(data, 996); // data就是返回的打印机数据列表 // console.log(data, 996); // data就是返回的打印机数据列表
this.printerList = data; this.printerList = data;
if (this.printerList.length > 0) { if (this.printerList.length > 0) {
this.printer = this.printerList[0].name; this.printer = this.printerList[0].name;
......
...@@ -17,9 +17,9 @@ export default { ...@@ -17,9 +17,9 @@ export default {
if (this.user.factory && this.user.factory.countryCode) { if (this.user.factory && this.user.factory.countryCode) {
this.factoryType = this.user.factory.countryCode; this.factoryType = this.user.factory.countryCode;
} }
console.log(17, this.user); // console.log(17, this.user);
this.$refs.updateDialog.checkUpdate().then((data) => { this.$refs.updateDialog.checkUpdate().then((data) => {
console.log(17, data); // console.log(17, data);
if (data) { if (data) {
// 有新版本更新 // 有新版本更新
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
}, },
item: { item: {
handler() { handler() {
console.log(789, this.item); // console.log(789, this.item);
if (this.item) { if (this.item) {
this.getCurrentItem(this.item); this.getCurrentItem(this.item);
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
this.item.x = item.x - item.w / 2; this.item.x = item.x - item.w / 2;
this.$dataStore.set( this.$dataStore.set(
"position_before_px", "position_before_px",
JSON.parse(JSON.stringify(this.item)) JSON.parse(JSON.stringify(this.item)),
); );
// console.log("setting", setting); // console.log("setting", setting);
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
this.form.r = this.item.r; this.form.r = this.item.r;
this.$dataStore.set( this.$dataStore.set(
`position_after_px`, `position_after_px`,
JSON.parse(JSON.stringify(this.form)) JSON.parse(JSON.stringify(this.form)),
); );
}, },
formChange(t) { formChange(t) {
...@@ -126,8 +126,8 @@ export default { ...@@ -126,8 +126,8 @@ export default {
this.formChange(); this.formChange();
}, },
reduceValue(f) { reduceValue(f) {
console.log(this.item); // console.log(this.item);
console.log(this.isPreView); // console.log(this.isPreView);
if (!(this.item != null && !this.isPreView)) { if (!(this.item != null && !this.isPreView)) {
return; return;
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";
import pkg from "../../../package.json"; import pkg from "../../../package.json";
import axios from "@/utils/axios"; import axios from "@/utils/axios";
const {
setSkip,
getSkipValue,
setSkipVersion,
getSkipVersion,
} = require("@/server/utils/store");
export default { export default {
data() { data() {
return { return {
...@@ -11,7 +18,8 @@ export default { ...@@ -11,7 +18,8 @@ export default {
percent: 0, percent: 0,
loading: false, loading: false,
speed: 0, speed: 0,
item: {} item: {},
skipVersion: "",
}; };
}, },
created() { created() {
...@@ -33,6 +41,7 @@ export default { ...@@ -33,6 +41,7 @@ export default {
that.loading = false; that.loading = false;
that.download(); that.download();
}); });
// this.getSkipVersionFn();
}, },
methods: { methods: {
async checkUpdate() { async checkUpdate() {
...@@ -40,10 +49,10 @@ export default { ...@@ -40,10 +49,10 @@ export default {
try { try {
axios axios
.get(`/checkUpdate?version=${this.version}`) .get(`/checkUpdate?version=${this.version}`)
.then(res => { .then((res) => {
resolve(res.data); resolve(res.data);
}) })
.catch(err => { .catch((err) => {
reject(err); reject(err);
}); });
} catch (err) { } catch (err) {
...@@ -57,7 +66,7 @@ export default { ...@@ -57,7 +66,7 @@ export default {
cancelButtonText: "取消", cancelButtonText: "取消",
showCancelButton: this.item.forcedUpdate === 0, showCancelButton: this.item.forcedUpdate === 0,
showClose: this.item.forcedUpdate === 0, showClose: this.item.forcedUpdate === 0,
type: "success" type: "success",
}) })
.then(() => { .then(() => {
ipcRenderer.send("install"); ipcRenderer.send("install");
...@@ -71,7 +80,7 @@ export default { ...@@ -71,7 +80,7 @@ export default {
showCancelButton: this.item.forcedUpdate === 0, showCancelButton: this.item.forcedUpdate === 0,
showClose: this.item.forcedUpdate === 0, showClose: this.item.forcedUpdate === 0,
cancelButtonText: "取消", cancelButtonText: "取消",
type: "success" type: "success",
}) })
.then(() => { .then(() => {
window.location.reload(); window.location.reload();
...@@ -100,7 +109,7 @@ export default { ...@@ -100,7 +109,7 @@ export default {
try { try {
this.loading = false; this.loading = false;
await this.$api.post("/incrementalUpdates", { await this.$api.post("/incrementalUpdates", {
url: this.item.fileList[0].fileUrl.replace("/data", "") url: this.item.fileList[0].fileUrl.replace("/data", ""),
}); });
this.incrementalUpdates(); this.incrementalUpdates();
} catch (e) { } catch (e) {
...@@ -109,15 +118,35 @@ export default { ...@@ -109,15 +118,35 @@ export default {
} }
}, },
open(data) { open(data) {
// console.log("更新", data);
this.item = data; this.item = data;
this.visible = true; this.visible = true;
if (this.version == this.item.version) {
setSkip(2);
setSkipVersion("1.0");
} }
} },
skipUpdate() {
setSkip(1);
setSkipVersion(this.item.version);
this.visible = false;
},
getSkipValueFn() {
const isSkip = getSkipValue();
const version = getSkipVersion();
// console.log({ isSkip, version });
return { isSkip, version };
},
},
}; };
</script> </script>
<template> <template>
<el-dialog <el-dialog
v-if="
getSkipValueFn().isSkip === 2 && getSkipValueFn().version !== item.version
"
:show-close="item.forcedUpdate === 0" :show-close="item.forcedUpdate === 0"
destroy-on-close destroy-on-close
:close-on-press-escape="false" :close-on-press-escape="false"
...@@ -129,16 +158,17 @@ export default { ...@@ -129,16 +158,17 @@ export default {
<pre>{{ item.content }}</pre> <pre>{{ item.content }}</pre>
<!-- <el-progress :text-inside="true" :stroke-width="26" :percentage="percent"></el-progress>--> <!-- <el-progress :text-inside="true" :stroke-width="26" :percentage="percent"></el-progress>-->
<template slot="footer"> <template slot="footer">
<div style="display: flex;justify-content: space-between;">
<div>
<el-button @click="skipUpdate" size="small">跳过更新 </el-button>
</div>
<div>
<el-button <el-button
@click="visible = false" @click="visible = false"
v-if="item.forcedUpdate === 0" v-if="item.forcedUpdate === 0"
size="small" size="small"
>关闭 >关闭
</el-button> </el-button>
<!-- <el-button @click="toUpdate(1)" size="small" type="warning"-->
<!-- >后台更新-->
<!-- </el-button-->
<!-- >-->
<el-button <el-button
@click="toUpdate(2)" @click="toUpdate(2)"
size="small" size="small"
...@@ -147,6 +177,8 @@ export default { ...@@ -147,6 +177,8 @@ export default {
> >
{{ loading ? `正在下载中(${percent}%)` : "确定更新" }} {{ loading ? `正在下载中(${percent}%)` : "确定更新" }}
</el-button> </el-button>
</div>
</div>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
......
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
...data.sysUser, ...data.sysUser,
...{ token: data.token }, ...{ token: data.token },
}); });
console.log(this.$dataStore); // console.log(this.$dataStore);
if (this.remember) { if (this.remember) {
let userList = this.$dataStore.get("userList"); let userList = this.$dataStore.get("userList");
...@@ -78,7 +78,8 @@ export default { ...@@ -78,7 +78,8 @@ export default {
if ( if (
!userList.find( !userList.find(
(el) => (el) =>
el.account === f.account && el.factoryCode === f.factoryCode el.account === f.account &&
el.factoryCode === f.factoryCode,
) )
) { ) {
userList.push(f); userList.push(f);
......
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