Commit 3d7e6157 by linjinhong

fix:修复前端代码和后端服务得代码文件

parent dc9031c5
......@@ -176,7 +176,7 @@ async function processImages(inputPath, outputPath, options = {}) {
console.log(
`处理失败: ${results.filter((r) => r.status === "error").length} 张图片`,
);
fs.unlinkSync(inputPath);
return results;
} catch (error) {
console.error("处理图片过程中出错:", error);
......
......@@ -13,12 +13,11 @@ import path from "path"; // 引入 path 模块
import axios from "axios";
import { extractValue } from "@/utils/index.js";
const uuid = require("uuid");
const fs = require("fs");
import { mapState } from "vuex";
const {
getVersion,
getHostApi,
setApi,
setDesktopDevice,
getDesktopDevice,
getOrderInfoMap,
......@@ -738,20 +737,7 @@ export default {
this.isFirst = false;
}
},
// // 聚焦资源管理器窗口(Windows)
focusExplorerWindow(path) {
const { exec } = require("child_process");
const fs = require("fs");
const command = `start explorer /select, "${path}"`;
// 检查路径是否存在
if (fs.existsSync(path)) {
exec(`cmd /c "${command}"`, (err) => {
if (err) console.error("激活窗口失败:", err);
});
} else {
console.error("路径不存在:", path);
}
},
classifyField(field) {
// 第一类:以"AAAF-CNPSC"开头
if (field.includes("CN")) {
......@@ -875,7 +861,7 @@ export default {
outputPath: outputPath,
};
const res = await this.$api.post("/processImage", params);
fs.unlinkSync(el.productionFile);
return {
fileName: outputFileName,
productionFile: res.msg[0]?.outputPath,
......@@ -916,42 +902,6 @@ 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;
......
......@@ -5,9 +5,10 @@ import ImgSetting from "./imgSetting.vue";
import bus from "@/bus";
import PrintDialog from "@/views/design/head/printDialog.vue";
import { mmToPx, extractValue } from "@/utils";
const { pathMap } = require("@/config/index.js");
const path = require("path");
const fs = require("fs");
const uuid = require("uuid");
import { mapState } from "vuex";
......@@ -985,7 +986,7 @@ export default {
outputPath: outputPath,
};
const res = await this.$api.post("/processImage", params);
fs.unlinkSync(el.productionFile);
return {
fileName: outputFileName,
productionFile: res.msg[0]?.outputPath,
......@@ -1049,11 +1050,14 @@ export default {
this.$store.commit("setIsPreView", this.isView);
},
async downloadImg(type) {
let res = await this.$api.post("/downloadBySubOrderNumber", {
ids: [this.detail.id],
device: this.newDesktopDevice,
orderType: this.orderType,
});
let res = await this.$api.post(
pathMap["downloadBySubOrderNumber"][this.orderType],
{
ids: [this.detail.id],
device: this.newDesktopDevice,
orderType: this.orderType,
},
);
if (res.data.length === 0) return this.$message.warning("未找到素材图!");
let imgList = [];
res.data.forEach((el) => {
......
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