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