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"
......
...@@ -6,13 +6,12 @@ import { ipcRenderer } from "electron"; ...@@ -6,13 +6,12 @@ import { ipcRenderer } from "electron";
import pkg from "../../../../package.json"; import pkg from "../../../../package.json";
import UpdateDialog from "@/views/design/updateDialog.vue"; import UpdateDialog from "@/views/design/updateDialog.vue";
import path from "path"; // 引入 path 模块 import path from "path"; // 引入 path 模块
import store from "@/store/index.js";
import axios from "axios"; import axios from "axios";
import { extractValue } from "@/utils/index.js"; import { extractValue } from "@/utils/index.js";
const uuid = require("uuid"); const uuid = require("uuid");
const fs = require("fs"); const fs = require("fs");
import { mapState } from "vuex"; import { mapState } from "vuex";
const { getVersion } = require("@/server/utils/store"); const { getVersion, getHostApi, setApi } = require("@/server/utils/store");
export default { export default {
components: { UpdateDialog }, components: { UpdateDialog },
...@@ -68,7 +67,8 @@ export default { ...@@ -68,7 +67,8 @@ export default {
}, },
imgList: [], imgList: [],
detail: null, detail: null,
config: getHostApi(),
newApiApiHost: "",
selectBgColor: "#ececec", selectBgColor: "#ececec",
predefineColors: [ predefineColors: [
"#ff4500", "#ff4500",
...@@ -110,6 +110,7 @@ export default { ...@@ -110,6 +110,7 @@ export default {
} else { } else {
this.$dataStore.set("setting", this.setting); this.$dataStore.set("setting", this.setting);
} }
// console.log(this.getDomainFromUrl(getHostApi().apiApiHost));
}, },
watch: { watch: {
setting: { setting: {
...@@ -120,6 +121,14 @@ export default { ...@@ -120,6 +121,14 @@ export default {
deep: true, deep: true,
}, },
config: {
handler(val) {
// console.log(99999999, val);\
this.newApiApiHost = this.getDomainFromUrl(val.apiApiHost);
},
immediate: true,
deep: true,
},
}, },
methods: { methods: {
checkUpdate() { checkUpdate() {
...@@ -193,7 +202,7 @@ export default { ...@@ -193,7 +202,7 @@ export default {
for (let k of this.checkList) { for (let k of this.checkList) {
if (k === "print-setting" || k === "deviceId") { if (k === "print-setting" || k === "deviceId") {
let list = Object.keys(this.$dataStore.store).filter((el) => let list = Object.keys(this.$dataStore.store).filter((el) =>
el.includes(k) el.includes(k),
); );
list.forEach((el) => { list.forEach((el) => {
this.$dataStore.delete(el); this.$dataStore.delete(el);
...@@ -271,7 +280,7 @@ export default { ...@@ -271,7 +280,7 @@ export default {
} }
resolve(imageList); resolve(imageList);
} catch (e) { } catch (e) {
console.log(e); // console.log(e);
reject(e); reject(e);
} }
}); });
...@@ -344,7 +353,7 @@ export default { ...@@ -344,7 +353,7 @@ export default {
} }
} }
if (!imageResList.length) { if (!imageResList.length) {
console.log(347, this.orderType); // console.log(347, this.orderType);
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示 // 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/downloadBySubOrderNumber", { let res = await this.$api.post("/downloadBySubOrderNumber", {
...@@ -415,7 +424,7 @@ export default { ...@@ -415,7 +424,7 @@ export default {
type: "sendFile", type: "sendFile",
value: [...newImgList], value: [...newImgList],
}; };
console.log(387, obj); // console.log(387, obj);
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -457,12 +466,12 @@ export default { ...@@ -457,12 +466,12 @@ export default {
if (pscPart) { if (pscPart) {
this.$store.commit( this.$store.commit(
"setOrderType", "setOrderType",
this.classifyField(this.productionNo) this.classifyField(this.productionNo),
); );
} else { } else {
this.$store.commit( this.$store.commit(
"setOrderType", "setOrderType",
this.classifyField(this.productionNo) this.classifyField(this.productionNo),
); );
} }
} else { } else {
...@@ -476,7 +485,7 @@ export default { ...@@ -476,7 +485,7 @@ export default {
this.$store.commit("setOrderType", str); this.$store.commit("setOrderType", str);
} }
console.log(423, this.productionNo); // console.log(423, this.productionNo);
try { try {
//查找生产单号信息 //查找生产单号信息
...@@ -485,10 +494,10 @@ export default { ...@@ -485,10 +494,10 @@ export default {
{ {
thirdSubOrderNumber: this.productionNo, thirdSubOrderNumber: this.productionNo,
orderType: this.orderType, orderType: this.orderType,
} },
); );
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
console.log(491, this.detail); // console.log(491, this.detail);
this.imgList = []; this.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam; let designImagesCanvasJsonList = this.detail.drParam;
...@@ -503,7 +512,7 @@ export default { ...@@ -503,7 +512,7 @@ export default {
console.log(err); console.log(err);
if (!err.data) { if (!err.data) {
this.$message.error( this.$message.error(
"未使用英文输入法输入/扫码,或该生产单号未拣胚或已完成" "未使用英文输入法输入/扫码,或该生产单号未拣胚或已完成",
); );
} }
this.productionNo = ""; this.productionNo = "";
...@@ -549,7 +558,7 @@ export default { ...@@ -549,7 +558,7 @@ export default {
if (index === 0) return; if (index === 0) return;
this.actionIndex = this.actionIndex - 1; this.actionIndex = this.actionIndex - 1;
} }
console.log(this.actionIndex, 88); // console.log(this.actionIndex, 88);
bus.$emit("busEmit", { type: "index", value: this.actionIndex }); bus.$emit("busEmit", { type: "index", value: this.actionIndex });
this.$store.commit("changeActionIndex", this.actionIndex); this.$store.commit("changeActionIndex", this.actionIndex);
}, },
...@@ -613,10 +622,10 @@ export default { ...@@ -613,10 +622,10 @@ export default {
changeDesktopDeviceFn(value) { changeDesktopDeviceFn(value) {
this.$store.commit("changeDesktopDevice", value); this.$store.commit("changeDesktopDevice", value);
this.$store.commit("changeImgList", []); this.$store.commit("changeImgList", []);
console.log(347, store.state.desktopDevice); // console.log(347, store.state.desktopDevice);
}, },
changeDesktoVersionFn(value) { changeDesktoVersionFn(value) {
console.log(553, value); // console.log(553, value);
this.selectGridIndex = 0; this.selectGridIndex = 0;
this.$store.commit("changeDesktoVersion", value); this.$store.commit("changeDesktoVersion", value);
ipcRenderer.send("update-version", value); ipcRenderer.send("update-version", value);
...@@ -648,13 +657,13 @@ export default { ...@@ -648,13 +657,13 @@ export default {
} catch (error) { } catch (error) {
console.error(`处理失败: ${el.productionFile}`, error); console.error(`处理失败: ${el.productionFile}`, error);
} }
}) }),
); );
// 等待所有异步操作完成 // 等待所有异步操作完成
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
const newMap = new Map(processQueue.map((el) => [el.designId, el])); const newMap = new Map(processQueue.map((el) => [el.designId, el]));
console.log("newMap", newMap); // console.log("newMap", newMap);
processQueue.forEach((el) => { processQueue.forEach((el) => {
if (newMap.has(el.designId)) { if (newMap.has(el.designId)) {
...@@ -662,7 +671,7 @@ export default { ...@@ -662,7 +671,7 @@ export default {
el.productionFile = newMap.get(el.designId).productionFile; el.productionFile = newMap.get(el.designId).productionFile;
} }
}); });
console.log("processQueue", processQueue); // console.log("processQueue", processQueue);
return processQueue; return processQueue;
} catch (error) { } catch (error) {
console.error("错误", error); console.error("错误", error);
...@@ -679,6 +688,52 @@ export default { ...@@ -679,6 +688,52 @@ export default {
return ""; return "";
}, },
changeApi(v) {
const configPath = getHostApi()?.configPath;
console.log(692, this.config);
fs.readFile(configPath, "utf-8", (err, data) => {
if (err) {
console.error("读取配置文件失败:", err);
return;
}
try {
let configObj = JSON.parse(data);
console.log(700, configObj);
configObj.apiApiHost = `https://${v}/api`;
configObj.fileApiUrl = `https://${v}/upload/factory`;
configObj.configPath = configPath;
const newData = JSON.stringify(configObj); // 使用2个空格缩进
// console.log("修改后的数据:", newData);
// 4. 写回文件
fs.writeFile(configPath, newData, "utf-8", (writeErr) => {
if (writeErr) {
console.error("写入配置文件失败:", writeErr);
this.$message.error(`写入配置文件失败: ${writeErr.message}`);
return;
}
console.log("配置文件更新成功", configObj);
setApi(configObj);
});
} catch (parseError) {
console.error("解析 JSON 失败:", parseError);
this.$message.error(`配置文件格式错误: ${parseError.message}`);
}
});
},
getDomainFromUrl(url) {
try {
return new URL(url).host;
} catch (e) {
console.error("Invalid URL:", url);
return null;
}
},
// async cleanDirectorySync() { // async cleanDirectorySync() {
// let dirPath = path.join(process.cwd(), `./print/Input`); // let dirPath = path.join(process.cwd(), `./print/Input`);
// if (!fs.existsSync(dirPath)) { // if (!fs.existsSync(dirPath)) {
...@@ -789,7 +844,7 @@ export default { ...@@ -789,7 +844,7 @@ export default {
</el-tooltip> </el-tooltip>
<el-popover <el-popover
width="320" width="350"
:offset="-120" :offset="-120"
trigger="click" trigger="click"
placement="bottom" placement="bottom"
...@@ -798,11 +853,12 @@ export default { ...@@ -798,11 +853,12 @@ export default {
<el-form <el-form
:model="setting" :model="setting"
label-position="left" label-position="left"
label-width="80px" label-width="70px"
size="small" size="small"
> >
<el-form-item prop="setting" label="网格显示"> <el-form-item prop="setting" label="网格显示">
<el-select <el-select
style="width:100%"
@change="(e) => settingChange('gridShow', e)" @change="(e) => settingChange('gridShow', e)"
clearable clearable
v-model="setting.gridShow" v-model="setting.gridShow"
...@@ -813,6 +869,7 @@ export default { ...@@ -813,6 +869,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="gridSpacing" label="单位"> <el-form-item prop="gridSpacing" label="单位">
<el-select <el-select
style="width:100%"
@change="(e) => settingChange('unit', e)" @change="(e) => settingChange('unit', e)"
clearable clearable
v-model="setting.unit" v-model="setting.unit"
...@@ -823,6 +880,7 @@ export default { ...@@ -823,6 +880,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="gridSpacing" label="网格间隔"> <el-form-item prop="gridSpacing" label="网格间隔">
<el-select <el-select
style="width:100%"
@change="(e) => settingChange('gridSpacing', e)" @change="(e) => settingChange('gridSpacing', e)"
clearable clearable
v-model="setting.gridSpacing" v-model="setting.gridSpacing"
...@@ -851,6 +909,7 @@ export default { ...@@ -851,6 +909,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="language" label="语言设置"> <el-form-item prop="language" label="语言设置">
<el-select <el-select
style="width:100%"
@change="(e) => settingChange('language', e)" @change="(e) => settingChange('language', e)"
clearable clearable
v-model="setting.language" v-model="setting.language"
...@@ -867,6 +926,14 @@ export default { ...@@ -867,6 +926,14 @@ export default {
>检查更新 >检查更新
</el-button> </el-button>
</el-form-item> </el-form-item>
<div>
<el-form-item label="工厂域名">
<el-input
v-model="newApiApiHost"
@input="changeApi"
></el-input>
</el-form-item>
</div>
</el-form> </el-form>
</div> </div>
<el-tooltip slot="reference" content="设置"> <el-tooltip slot="reference" content="设置">
...@@ -930,7 +997,7 @@ export default { ...@@ -930,7 +997,7 @@ export default {
{{ {{
user.factory.countryCode user.factory.countryCode
? `${user.factory.countryCode}${getCountryName( ? `${user.factory.countryCode}${getCountryName(
user.factory.countryCode user.factory.countryCode,
)}` )}`
: "CN(中国)" : "CN(中国)"
}} }}
......
...@@ -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;
......
...@@ -200,12 +200,52 @@ export default { ...@@ -200,12 +200,52 @@ export default {
imgDom: null, imgDom: null,
leftPosition: "22%", leftPosition: "22%",
topPosition: "52%", topPosition: "52%",
currentImgData: null,
}; };
}, },
watch: { watch: {
imgList: { imgList: {
handler() { handler(newValue) {
// console.log(169, newValue); const image = document.getElementById("imgBox");
if (newValue.length && image) {
const w = newValue[0]?.w / this.getWHproportion(this.WHproportion);
const h = newValue[0]?.h / this.getWHproportion(this.WHproportion);
let bw = document.getElementById("line");
let bh = bw.clientHeight;
bw = bw.clientWidth;
const output = [
`-------------------------------------------------`,
`生产单号:${this.detail.factorySubOrderNumber}`,
`当前图片:宽度--${newValue[0]?.w}px,高度--${newValue[0]?.h}px`,
`当前图片地址:${newValue[0]?.url}`,
`扩大比例:${this.WHproportion}`,
`压板尺寸:${bh}px*${bw}px`,
`实际打印尺寸(当前图片/扩大比例):宽度--${w}px,高度--${h}px`,
`计算公式毫米(mm:((px * 0.84183).toFixed(1)`,
`打印尺寸毫米(mm:宽度--${Number(
(w * 0.84183).toFixed(1),
)}mm,高度--${Number((h * 0.84183).toFixed(1))}mm`,
`-------------------------------------------------`,
];
console.log(output.join("\n"));
console.log(`后端返回图片大小:\n`, this.currentImgData);
console.log(`当前网格大小:\n`, this.gridSpacing);
console.log(
`当前整体数据:\n`,
newValue[0],
`\n`,
`rate由后端返回图片高度除以宽度得出\n`,
`如果高度大于宽度则 height_px = 压板高度 * (7.5 / 10)\n`,
`如果宽度度大于高度则 width_px = 压板宽度 * (2 / 3)\n`,
`剩下的高度或宽度则由(height_px或者width_px)/rate\n`,
);
console.log(
`获取当前图片在压板中的大小公式:\n 宽度:${image?.clientWidth}(image.clientWidth)px /${this.WHproportion}(扩大比例)=${w}\n 高度:${image?.clientHeight}(image.clientHeight)px /${this.WHproportion}(扩大比例)=${h}`,
);
}
if (this.imgList.length > 0) { if (this.imgList.length > 0) {
this.$nextTick(() => { this.$nextTick(() => {
...@@ -227,7 +267,7 @@ export default { ...@@ -227,7 +267,7 @@ export default {
this.$store.commit("changeImgList", this.imgList); this.$store.commit("changeImgList", this.imgList);
}, },
deep: true, deep: true,
immediate: true, // immediate: true,
}, },
selectIndex() { selectIndex() {
if (this.selectIndex >= 0) { if (this.selectIndex >= 0) {
...@@ -282,7 +322,7 @@ export default { ...@@ -282,7 +322,7 @@ export default {
return 0; return 0;
}); });
console.log(249, this.detail.imageAry); // console.log(249, this.detail.imageAry);
}, },
col: { col: {
handler(newValue) { handler(newValue) {
...@@ -316,7 +356,7 @@ export default { ...@@ -316,7 +356,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.drrDom = document.getElementsByClassName("drr")[0]; this.drrDom = document.getElementsByClassName("drr")[0];
this.imgDom = document.getElementById("imgBox"); this.imgDom = document.getElementById("imgBox");
console.log(257, this.imgDom); // console.log(257, this.imgDom);
if (this.imgDom) if (this.imgDom)
this.imgDom.style.webkitClipPath = this.oldImgStyle; this.imgDom.style.webkitClipPath = this.oldImgStyle;
}); });
...@@ -335,6 +375,12 @@ export default { ...@@ -335,6 +375,12 @@ export default {
}, },
deep: true, deep: true,
}, },
selectImgList: {
handler(value) {
console.log(value);
},
deep: true,
},
}, },
methods: { methods: {
// 重构为可手动触发的方法 // 重构为可手动触发的方法
...@@ -347,7 +393,7 @@ export default { ...@@ -347,7 +393,7 @@ export default {
e.stopPropagation(); e.stopPropagation();
//阻止浏览器默认打开文件的操作 //阻止浏览器默认打开文件的操作
e.preventDefault(); e.preventDefault();
console.log(e); // console.log(e);
const files = e.dataTransfer.files; const files = e.dataTransfer.files;
if (files.length === 0) return; if (files.length === 0) return;
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
...@@ -374,7 +420,7 @@ export default { ...@@ -374,7 +420,7 @@ export default {
e.dataTransfer.dropEffect = "copy"; e.dataTransfer.dropEffect = "copy";
}, },
keyup(e) { keyup(e) {
console.log(e); // console.log(e);
if (e.keyCode == 90 && e.ctrlKey) { if (e.keyCode == 90 && e.ctrlKey) {
let i = this.imgHistoryList.length - (2 + this.imgHistoryIndex); let i = this.imgHistoryList.length - (2 + this.imgHistoryIndex);
if (this.imgHistoryList[i]) { if (this.imgHistoryList[i]) {
...@@ -388,7 +434,7 @@ export default { ...@@ -388,7 +434,7 @@ export default {
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"y", "y",
Number(this.imgList[this.selectIndex].y) - 1 Number(this.imgList[this.selectIndex].y) - 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} }
...@@ -397,7 +443,7 @@ export default { ...@@ -397,7 +443,7 @@ export default {
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"y", "y",
Number(this.imgList[this.selectIndex].y) + 1 Number(this.imgList[this.selectIndex].y) + 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} }
...@@ -406,7 +452,7 @@ export default { ...@@ -406,7 +452,7 @@ export default {
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"x", "x",
Number(this.imgList[this.selectIndex].x) - 1 Number(this.imgList[this.selectIndex].x) - 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} }
...@@ -415,7 +461,7 @@ export default { ...@@ -415,7 +461,7 @@ export default {
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"x", "x",
Number(this.imgList[this.selectIndex].x) + 1 Number(this.imgList[this.selectIndex].x) + 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} }
...@@ -433,7 +479,7 @@ export default { ...@@ -433,7 +479,7 @@ export default {
}, },
indexChange(v) { indexChange(v) {
console.log(v); // console.log(v);
if (this.imgList.length === 0) return; if (this.imgList.length === 0) return;
let index = !this.imgList[this.selectIndex] ? 0 : this.selectIndex; let index = !this.imgList[this.selectIndex] ? 0 : this.selectIndex;
...@@ -464,12 +510,12 @@ export default { ...@@ -464,12 +510,12 @@ export default {
setDesignImg(title) { setDesignImg(title) {
let img = this.selectImgList.find((it) => it.title === title); let img = this.selectImgList.find((it) => it.title === title);
if (img) { if (img) {
console.log(this.detail.designImageSize, "this.detail.size"); // console.log(this.detail.designImageSize, "this.detail.size");
this.getBackFile( this.getBackFile(
{ files: [img], size: this.detail.designImageSize }, { files: [img], size: this.detail.designImageSize },
() => { () => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} },
); );
} }
}, },
...@@ -482,7 +528,7 @@ export default { ...@@ -482,7 +528,7 @@ export default {
let item = this.imgList.find((img) => img.fileName === it.fileName); let item = this.imgList.find((img) => img.fileName === it.fileName);
if (item) return; if (item) return;
this.currentImgIndex = index; this.currentImgIndex = index;
console.log(this.detail.designImageSize); // console.log(this.detail.designImageSize);
let size = null; let size = null;
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -537,7 +583,7 @@ export default { ...@@ -537,7 +583,7 @@ export default {
} else { } else {
// // 高度铺满,宽度自适应 // // 高度铺满,宽度自适应
let r = gh / imgH; let r = gh / imgH;
console.log("比例", r); // console.log("比例", r);
this.$set(this.imgList[this.selectIndex], "h", gh); this.$set(this.imgList[this.selectIndex], "h", gh);
this.$set(this.imgList[this.selectIndex], "w", imgW * r); this.$set(this.imgList[this.selectIndex], "w", imgW * r);
...@@ -563,21 +609,21 @@ export default { ...@@ -563,21 +609,21 @@ export default {
break; break;
case "add_index": case "add_index":
dom.style.zIndex = Number(z_index) + 1; dom.style.zIndex = Number(z_index) + 1;
console.log(dom.style.zIndex); // console.log(dom.style.zIndex);
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"zIndex", "zIndex",
this.imgList[this.selectIndex].zIndex + 1 this.imgList[this.selectIndex].zIndex + 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
break; break;
case "reduce_index": case "reduce_index":
dom.style.zIndex = Number(z_index) - 1; dom.style.zIndex = Number(z_index) - 1;
console.log(dom.style.zIndex); // console.log(dom.style.zIndex);
this.$set( this.$set(
this.imgList[this.selectIndex], this.imgList[this.selectIndex],
"zIndex", "zIndex",
this.imgList[this.selectIndex].zIndex - 1 this.imgList[this.selectIndex].zIndex - 1,
); );
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
break; break;
...@@ -656,7 +702,7 @@ export default { ...@@ -656,7 +702,7 @@ export default {
this.selectIndex = -1; this.selectIndex = -1;
}, },
delImg(index) { delImg(index) {
console.log(index, "index"); // console.log(index, "index");
this.imgList.splice(index, 1); this.imgList.splice(index, 1);
if (this.imgList.length > 0) { if (this.imgList.length > 0) {
this.selectIndex = 0; this.selectIndex = 0;
...@@ -688,14 +734,14 @@ export default { ...@@ -688,14 +734,14 @@ export default {
}, },
getComputedName(title) { getComputedName(title) {
let img = this.selectImgList.find( let img = this.selectImgList.find(
(it) => it.title === title || it.title.includes(title) (it) => it.title === title || it.title.includes(title),
); );
return img?.designId; return img?.designId;
}, },
getComputedTitle(title) { getComputedTitle(title) {
console.log(this.selectImgList, "this.selectImgList"); // console.log(this.selectImgList, "this.selectImgList");
let img = this.selectImgList.find( let img = this.selectImgList.find(
(it) => it.title === title || it.title.includes(title) (it) => it.title === title || it.title.includes(title),
); );
return img?.productionFile; return img?.productionFile;
}, },
...@@ -712,17 +758,20 @@ export default { ...@@ -712,17 +758,20 @@ export default {
let w = bw / 2; let w = bw / 2;
let h = bh / 2; let h = bh / 2;
let width_px, height_px, rate, x, y; let width_px, height_px, rate, x, y;
let data = await that.getImageSize(files[i].url);
if (size && !files[i].isCut) { if (size && !files[i].isCut) {
// console.log("size", size);
width_px = that.WHproportion * mmToPx(size.width); width_px = that.WHproportion * mmToPx(size.width);
height_px = that.WHproportion * mmToPx(size.height); height_px = that.WHproportion * mmToPx(size.height);
x = w * that.WHproportion; x = w * that.WHproportion;
y = (height_px / 2) * that.WHproportion; y = (height_px / 2) * that.WHproportion;
rate = height_px / width_px; rate = height_px / width_px;
} else { } else {
let data = await that.getImageSize(files[i].url); // console.log("data", data);
rate = data.height / data.width; rate = data.height / data.width;
console.log(679, rate); // console.log(679, rate);
if (rate > 1) { if (rate > 1) {
height_px = bh * (7.5 / 10); height_px = bh * (7.5 / 10);
...@@ -738,6 +787,7 @@ export default { ...@@ -738,6 +787,7 @@ export default {
y = height_px / 2; y = height_px / 2;
} }
} }
this.currentImgData = { ...data };
that.imgList = []; that.imgList = [];
that.imgList.push({ that.imgList.push({
url: files[i].url, url: files[i].url,
...@@ -750,6 +800,7 @@ export default { ...@@ -750,6 +800,7 @@ export default {
h: height_px, h: height_px,
r: 0, r: 0,
}); });
that.selectIndex = that.imgList.length - 1; that.selectIndex = that.imgList.length - 1;
that.showImgSetting = true; that.showImgSetting = true;
that.$nextTick(() => { that.$nextTick(() => {
...@@ -784,7 +835,7 @@ export default { ...@@ -784,7 +835,7 @@ export default {
h: bw * (2 / 3) * rate, h: bw * (2 / 3) * rate,
r: 0, r: 0,
}); });
console.log(570, that.imgList); // console.log(570, that.imgList);
that.selectIndex = that.imgList.length - 1; that.selectIndex = that.imgList.length - 1;
that.showImgSetting = true; that.showImgSetting = true;
callback && callback(file); callback && callback(file);
...@@ -875,19 +926,19 @@ export default { ...@@ -875,19 +926,19 @@ export default {
}, },
async cutImgFn() { async cutImgFn() {
console.log("detail", this.detail); // console.log("detail", this.detail);
if (this.detail.diyId) { if (this.detail.diyId) {
await this.downloadImg(1); await this.downloadImg(1);
} }
this.checkList = JSON.parse(JSON.stringify(this.selectImgList)); this.checkList = JSON.parse(JSON.stringify(this.selectImgList));
try { try {
console.log("checkList", this.checkList); // console.log("checkList", this.checkList);
const processQueue = await Promise.all( const processQueue = await Promise.all(
this.checkList.map(async (el) => { this.checkList.map(async (el) => {
try { try {
const outputDir = path.dirname(el.productionFile); const outputDir = path.dirname(el.productionFile);
console.log(outputDir); // console.log(outputDir);
const outputFileName = `${uuid.v4()}.png`; const outputFileName = `${uuid.v4()}.png`;
const outputPath = path.join(outputDir, outputFileName); const outputPath = path.join(outputDir, outputFileName);
...@@ -905,14 +956,14 @@ export default { ...@@ -905,14 +956,14 @@ export default {
} catch (error) { } catch (error) {
console.error(`处理失败: ${el.productionFile}`, error); console.error(`处理失败: ${el.productionFile}`, error);
} }
}) }),
); );
console.log("processQueue", processQueue); // console.log("processQueue", processQueue);
// 等待所有异步操作完成 // 等待所有异步操作完成
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
const newMap = new Map(processQueue.map((el) => [el.designId, el])); const newMap = new Map(processQueue.map((el) => [el.designId, el]));
console.log("newMap", newMap); // console.log("newMap", newMap);
this.selectImgList.forEach((el) => { this.selectImgList.forEach((el) => {
if (newMap.has(el.designId)) { if (newMap.has(el.designId)) {
...@@ -922,11 +973,11 @@ export default { ...@@ -922,11 +973,11 @@ export default {
el.productionFile = newMap.get(el.designId).productionFile; el.productionFile = newMap.get(el.designId).productionFile;
} }
}); });
console.log("selectImgList", this.selectImgList); // console.log("selectImgList", this.selectImgList);
if (this.imgList.length) { if (this.imgList.length) {
const fileNameExists = this.checkList.some( const fileNameExists = this.checkList.some(
(el) => el.fileName === this.imgList[0].fileName (el) => el.fileName === this.imgList[0].fileName,
); );
if (fileNameExists) { if (fileNameExists) {
this.imgList = []; this.imgList = [];
...@@ -986,7 +1037,7 @@ export default { ...@@ -986,7 +1037,7 @@ export default {
return el; return el;
}); });
this.selectImgList = [...res.data]; this.selectImgList = [...res.data];
console.log(823, this.selectImgList); // console.log(823, this.selectImgList);
if (type == 1) return; if (type == 1) return;
this.imgList = []; this.imgList = [];
this.selectIndex = -1; this.selectIndex = -1;
...@@ -1039,52 +1090,52 @@ export default { ...@@ -1039,52 +1090,52 @@ export default {
let left = ((newLeft + newWidth) / newWidth) * 100; let left = ((newLeft + newWidth) / newWidth) * 100;
if (isOverRight && isOverTop && isOverLeft && isOverBottom) { if (isOverRight && isOverTop && isOverLeft && isOverBottom) {
console.log("四面"); // console.log("四面");
gradient = this.getInset(top, right, bottom, left); gradient = this.getInset(top, right, bottom, left);
} else if (isOverRight && isOverTop && isOverLeft) { } else if (isOverRight && isOverTop && isOverLeft) {
console.log("左右上"); // console.log("左右上");
gradient = this.getInset(top, right, 0, left); gradient = this.getInset(top, right, 0, left);
} else if (isOverRight && isOverBottom && isOverLeft) { } else if (isOverRight && isOverBottom && isOverLeft) {
console.log("左右下"); // console.log("左右下");
gradient = this.getInset(100, right, bottom, left); gradient = this.getInset(100, right, bottom, left);
} else if (isOverTop && isOverBottom && isOverLeft) { } else if (isOverTop && isOverBottom && isOverLeft) {
console.log("左上下"); // console.log("左上下");
gradient = this.getInset(top, 0, bottom, left); gradient = this.getInset(top, 0, bottom, left);
} else if (isOverTop && isOverBottom && isOverRight) { } else if (isOverTop && isOverBottom && isOverRight) {
console.log("右上下"); // console.log("右上下");
gradient = this.getInset(top, right, bottom, 100); gradient = this.getInset(top, right, bottom, 100);
} else if (isOverRight && isOverTop) { } else if (isOverRight && isOverTop) {
console.log("右上"); // console.log("右上");
gradient = this.getInset(top, right); gradient = this.getInset(top, right);
} else if (isOverRight && isOverBottom) { } else if (isOverRight && isOverBottom) {
console.log("右下"); // console.log("右下");
gradient = this.getInset(100, right, bottom); gradient = this.getInset(100, right, bottom);
} else if (isOverTop && isOverLeft) { } else if (isOverTop && isOverLeft) {
console.log("左上"); // console.log("左上");
gradient = this.getInset(top, 0, 0, left); gradient = this.getInset(top, 0, 0, left);
} else if (isOverLeft && isOverBottom) { } else if (isOverLeft && isOverBottom) {
console.log("左下"); // console.log("左下");
gradient = this.getInset(100, 0, bottom, left); gradient = this.getInset(100, 0, bottom, left);
} else if (isOverLeft && isOverRight) { } else if (isOverLeft && isOverRight) {
console.log("左右"); // console.log("左右");
gradient = this.getInset(100, right, 0, left); gradient = this.getInset(100, right, 0, left);
} else if (isOverTop && isOverBottom) { } else if (isOverTop && isOverBottom) {
console.log("上下"); // console.log("上下");
gradient = this.getInset(top, 0, bottom, 100); gradient = this.getInset(top, 0, bottom, 100);
} else if (isOverRight) { } else if (isOverRight) {
console.log("右"); // console.log("右");
gradient = this.getInset(100, right); gradient = this.getInset(100, right);
} else if (isOverBottom) { } else if (isOverBottom) {
console.log("下"); // console.log("下");
gradient = this.getInset(100, 0, bottom); gradient = this.getInset(100, 0, bottom);
} else if (isOverTop) { } else if (isOverTop) {
console.log("上"); // console.log("上");
gradient = this.getInset(top); gradient = this.getInset(top);
} else if (isOverLeft) { } else if (isOverLeft) {
console.log("左"); // console.log("左");
gradient = this.getInset(100, 0, 0, left); gradient = this.getInset(100, 0, 0, left);
} else { } else {
console.log("中间"); // console.log("中间");
} }
this.imgDom.style.webkitClipPath = gradient; this.imgDom.style.webkitClipPath = gradient;
}, },
...@@ -1119,7 +1170,7 @@ export default { ...@@ -1119,7 +1170,7 @@ export default {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
} },
).then(async () => { ).then(async () => {
try { try {
this.imgList = []; this.imgList = [];
...@@ -1168,23 +1219,23 @@ export default { ...@@ -1168,23 +1219,23 @@ export default {
case "sendFile": case "sendFile":
this.hasSize = !!size; this.hasSize = !!size;
this.detail.designImageSize = size; this.detail.designImageSize = size;
console.log(this.detail, "this.detail"); // console.log(this.detail, "this.detail");
this.imgList = []; this.imgList = [];
this.selectImgList = []; this.selectImgList = [];
this.selectIndex = -1; this.selectIndex = -1;
if (value.length > 0) { if (value.length > 0) {
this.selectImgList = value; this.selectImgList = value;
console.log(816, this.selectImgList); // console.log(816, this.selectImgList);
console.log(99999, value); // console.log(99999, value);
this.selectImgIndex = 0; this.selectImgIndex = 0;
this.getBackFile( this.getBackFile(
{ files: [value[0]], size: this.detail.designImageSize || null }, { files: [value[0]], size: this.detail.designImageSize || null },
() => { () => {
this.imgHistoryList.push( this.imgHistoryList.push(
JSON.parse(JSON.stringify(this.imgList)) JSON.parse(JSON.stringify(this.imgList)),
); );
} },
); );
// this.addFile([value[0].file]) // this.addFile([value[0].file])
} }
...@@ -1392,13 +1443,13 @@ export default { ...@@ -1392,13 +1443,13 @@ export default {
mm:&nbsp;(&nbsp; w: mm:&nbsp;(&nbsp; w:
{{ {{
((Number(detail.mssWidth) * WHproportion * 10) / 10).toFixed( ((Number(detail.mssWidth) * WHproportion * 10) / 10).toFixed(
1 1,
) )
}} }}
&nbsp; h: &nbsp; h:
{{ {{
((Number(detail.mssHeight) * WHproportion * 10) / 10).toFixed( ((Number(detail.mssHeight) * WHproportion * 10) / 10).toFixed(
1 1,
) )
}}&nbsp;) }}&nbsp;)
</div> </div>
......
...@@ -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