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