Commit a327daff by linjinhong

feat:添加删除模式

parent 2c071741
GTXproCMD.exe send -A "D:\sample\Output\pO12.arxp" -P "Brother GTX pro" -D 1
GTXproCMD.exe send -A "Output\pO12.arxp" -P "Brother GTX pro" -D 1
echo %errorlevel%
\ No newline at end of file
......@@ -7,7 +7,7 @@ import { autoUpdater } from "electron-updater";
import path from "path"; // 引入 path 模块
const { exec } = require("child_process");
const { setVersion } = require("@/server/utils/store");
const { setVersion, setDeleteSetting } = require("@/server/utils/store");
Object.defineProperty(app, "isPackaged", {
get() {
......@@ -202,6 +202,11 @@ app.on("ready", async () => {
setVersion(version); // 保存到 electron-store
});
ipcMain.on("update-deleteSetting", (_, version) => {
console.log(72, version);
setDeleteSetting(version); // 保存到 electron-store
});
});
app.on("will-quit", () => {
......
......@@ -144,6 +144,13 @@ export const downloadImage = (list) => {
fs.mkdirSync(dirPath, { recursive: true });
}
try {
await fs.promises.access(dirPath, fs.constants.W_OK);
} catch (error) {
console.error("没有目录写入权限:", dirPath);
// return reject(new Error('没有写入权限'));
}
// 过滤出有效的下载项
const downloadItems = list.filter(
(item) => item.url && item.url.includes("http")
......@@ -153,6 +160,7 @@ export const downloadImage = (list) => {
if (downloadItems.length === 0) {
return resolve(list);
}
// 检查写入权限
// 并行处理所有下载
const downloadPromises = downloadItems.map((item) => {
......@@ -205,7 +213,16 @@ export const downloadImage = (list) => {
if (isArchive) {
// 处理压缩文件
item.list = await zip(filePath, dirPath);
try {
// 添加await确保异步完成
const result = await zip(filePath, dirPath);
// 显式赋值,确保引用正确
item.list = result || [];
console.log("解压完成,文件数量:", item.list.length);
} catch (zipError) {
console.error("解压失败:", zipError);
item.list = [];
}
} else {
// 处理普通图片文件
if (!item.list) item.list = [];
......
......@@ -5,7 +5,11 @@ module.exports = {
setVersion: (version) => {
store.set("desktoVersion", version);
},
setDeleteSetting: (setting) => {
store.set("deleteSetting", setting);
},
getVersion: () => store.get("desktoVersion") || "print",
getDeleteSetting: () => store.get("deleteSetting") || "0",
setBoard: (version) => {
store.set("desktoBoard", version);
console.log("store", store.get("desktoBoard"));
......
......@@ -12,7 +12,7 @@ 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, getDeleteSetting } = require("@/server/utils/store");
export default {
components: { UpdateDialog },
......@@ -31,6 +31,7 @@ export default {
checkList: [],
desktopDevice: 1,
desktoVersion: getVersion(),
deleteSetting: getDeleteSetting(),
checked: false,
isFirst: true,
cacheList: [
......@@ -621,6 +622,24 @@ export default {
this.$store.commit("getNewGrid");
this.command(0);
},
changeDeleteSetting(value) {
const oldValue = this.deleteSetting; // 缓存旧值
console.log(626, oldValue);
// this.$confirm("选择该操作打印后会导致打印记录清空,是否继续?", "警告", {
// confirmButtonText: "确定",
// cancelButtonText: "取消",
// type: "warning",
// })
// .then(() => {
// ipcRenderer.send("update-deleteSetting", value);
// })
// .catch(() => {
// this.deleteSetting = oldValue;
// });
ipcRenderer.send("update-deleteSetting", value);
// console.log(626, this.deleteSetting);
},
async cutImgFn(arr) {
if (!arr.length) return arr;
console.log(arr);
......@@ -717,6 +736,7 @@ export default {
.left-btn {
display: flex;
flex: 1;
}
</style>
<template>
......@@ -727,6 +747,7 @@ export default {
<div>设备类型:</div>
<el-select
class="selectItem"
v-model="desktopDevice"
@change="changeDesktopDeviceFn"
placeholder="请选择设备类型"
......@@ -735,10 +756,12 @@ export default {
<el-option label="其他" :value="2"></el-option>
</el-select>
</div>
<div class="selectInput">
<div>驱动版本:</div>
<el-select
class="selectItem"
v-model="desktoVersion"
@change="changeDesktoVersionFn"
placeholder="请选择版本"
......@@ -748,8 +771,25 @@ export default {
<el-option label="600" value="print600"></el-option>
</el-select>
</div>
<div class="selectInput">
<div>删除模式:</div>
<el-dropdown trigger="click" @command="command" :hide-on-click="false">
<el-select
class="selectDelete"
v-model="deleteSetting"
@change="changeDeleteSetting"
placeholder="请选择"
>
<el-option label="自动删除打印素材(打印后)" value="1"></el-option>
<el-option label="保留打印素材(打印后)" value="0"></el-option>
</el-select>
</div>
<el-dropdown
class="selectInput"
trigger="click"
@command="command"
:hide-on-click="false"
>
<el-button style="height: 100%;margin-right: 0" size="small"
>{{ grid[selectGridIndex]?.label }}
</el-button>
......@@ -760,7 +800,7 @@ export default {
</el-dropdown-menu>
</el-dropdown>
<el-tooltip content="图片">
<el-tooltip class="selectInput" content="图片">
<el-upload
accept=".png"
action=""
......@@ -769,7 +809,7 @@ export default {
:before-upload="uploadImage"
style="height: 100%;"
>
<el-button style="height: 100%;margin:0 8px" size="small">
<el-button style="height: 100%" size="small">
<i class="el-icon-picture" style="font-size: 15px;"></i>
</el-button>
</el-upload>
......@@ -792,7 +832,7 @@ export default {
trigger="click"
placement="bottom"
>
<div class="setting-form">
<div class="setting-form selectInput">
<el-form
:model="setting"
label-position="left"
......@@ -902,20 +942,19 @@ export default {
type="success"
>生产完成
</el-button>
<div class="check">
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox>
</div>
</div>
<div style="margin-left: 10px;">
<el-checkbox v-model="checked">自动裁切素材</el-checkbox>
<div style="margin-left: 8px;">
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox>
</div>
<el-button
<div style="margin-left: 8px;">
<el-checkbox v-model="checked">自动裁切</el-checkbox>
</div>
<!-- <el-button
@click="downloadImage"
size="medium"
style="margin-left: 15px"
style="margin-left: 8px"
type="primary"
>下载素材
</el-button>
</el-button> -->
</div>
<div class="right-user">
<div
......@@ -1019,28 +1058,28 @@ export default {
.center-input {
display: flex;
align-items: center;
justify-content: center;
// justify-content: center;
flex: 1;
flex-shrink: 0;
overflow: hidden;
padding-left: 100px;
// padding-left: 100px;
}
.sure-btn {
width: 300px;
// width: 250px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
::v-deep {
.el-button {
span {
position: relative;
left: -40px;
}
}
}
// ::v-deep {
// .el-button {
// span {
// position: relative;
// left: -40px;
// }
// }
// }
}
.check {
......@@ -1065,12 +1104,15 @@ export default {
.selectInput {
display: flex;
align-items: center;
margin: 0 10px;
margin-right: 5px;
font-size: 14px;
::v-deep {
.el-select .el-input {
.selectItem .el-input {
max-width: 80px;
}
.selectDelete .el-input {
max-width: 110px;
}
}
}
::v-deep {
......
......@@ -7,7 +7,7 @@ import moment from "moment";
import pkg from "../../../../package.json";
import { pxToUnit } from "../../../utils/index";
import { mapState } from "vuex";
const { getVersion } = require("@/server/utils/store");
const { getVersion, getDeleteSetting } = require("@/server/utils/store");
export default {
data() {
return {
......@@ -434,7 +434,7 @@ export default {
let print_cmd = `${printCmd} send -A "Output\\${imgFileName.replace(
".png",
""
)}.arxp" -P "${this.printer}`;
)}.arxp" -P "${this.printer}" -D ${getDeleteSetting()}`;
let data = {
...this.printSetting,
...{
......
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