Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
electron-printer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhuzhequan
electron-printer
Commits
b0182596
Commit
b0182596
authored
Jan 30, 2026
by
linjinhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加本地储存功能
parent
e0f5d9e8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
539 additions
and
291 deletions
+539
-291
src/background.js
+6
-8
src/server/entity/function.js
+45
-17
src/server/utils/index.js
+118
-118
src/server/utils/store.js
+123
-3
src/views/design/head/index.vue
+107
-93
src/views/design/main/imgSetting.vue
+22
-2
src/views/design/main/index.vue
+118
-50
No files found.
src/background.js
View file @
b0182596
...
...
@@ -33,14 +33,19 @@ async function createWindow() {
width
:
1500
,
height
:
1000
,
icon
:
"./src/assets/logo.jpg"
,
webPreferences
:
{
webSecurity
:
false
,
nodeIntegration
:
true
,
contextIsolation
:
false
,
// ^1.4.0 版本必须关闭
},
show
:
false
,
});
win
.
once
(
"ready-to-show"
,
()
=>
{
win
.
maximize
();
win
.
show
();
});
win
.
maximize
();
const
template
=
[
{
label
:
"文件"
,
...
...
@@ -430,13 +435,6 @@ async function createWindow() {
if
(
result
.
length
)
{
event
.
reply
(
"select-folder-result"
,
result
[
0
]);
}
// if (!result.canceled && result.filePaths.length > 0) {
// // event.reply:向发送消息的渲染进程返回结果
// event.reply("select-folder-result", result.filePaths[0]);
// } else {
// // 用户取消选择,返回 null
// event.reply("select-folder-result", null);
// }
},
);
});
...
...
src/server/entity/function.js
View file @
b0182596
...
...
@@ -21,12 +21,22 @@ const { app } = require("electron");
let
fileEnv
,
env
,
visionUrl
;
axios
.
defaults
.
timeout
=
12600000
;
const
multiparty
=
require
(
"multiparty"
);
const
{
getVersion
,
setApi
,
getHostApi
}
=
require
(
"@/server/utils/store"
);
const
{
getVersion
,
setApi
,
getHostApi
,
getDesktopDevice
,
}
=
require
(
"@/server/utils/store"
);
//获取当前驱动版本
function
getCurrentVersion
()
{
const
version
=
getVersion
();
return
version
;
}
//获取当前设备类型
function
getCurrentDesktopDevice
()
{
const
version
=
getDesktopDevice
();
return
version
;
}
async
function
readEnv
()
{
let
exePath
,
configPath
;
...
...
@@ -57,6 +67,10 @@ async function readEnv() {
readEnv
();
export
default
{
saveImgByUrl
:
async
(
req
,
res
)
=>
{
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
try
{
const
response
=
await
axios
({
url
:
req
.
body
.
url
,
...
...
@@ -66,7 +80,7 @@ export default {
let
fileName
=
uuid
.
v4
()
+
".png"
;
const
filePath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()
}
/Input/`
+
fileName
,
`./
${
version
}
/Input/`
+
fileName
,
);
const
writer
=
fs
.
createWriteStream
(
filePath
);
...
...
@@ -147,7 +161,7 @@ export default {
files
=
files
.
map
((
el
)
=>
({
url
:
`
${
fileEnv
}${
el
}
`
}));
const
downloadFunc
=
params
.
device
===
1
?
downloadImage
:
downloadOther
Image
;
params
.
device
===
2
?
downloadOtherImage
:
download
Image
;
const
result
=
await
downloadFunc
(
files
);
res
.
setHeader
(
"Request-URL"
,
url
);
...
...
@@ -257,13 +271,17 @@ export default {
downloadByDesignId
:
async
(
req
,
res
)
=>
{
let
q
=
req
.
body
;
try
{
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
let
dir
=
path
.
join
(
os
.
homedir
(),
"/Desktop/"
+
q
.
productionNo
+
".zip"
);
const
zipStream
=
new
compressing
.
zip
.
Stream
();
for
(
let
k
in
q
.
imgList
)
{
const
p
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()
}
/Input/`
+
q
.
imgList
[
k
].
fileName
,
`./
${
version
}
/Input/`
+
q
.
imgList
[
k
].
fileName
,
);
zipStream
.
addEntry
(
p
);
}
...
...
@@ -288,7 +306,11 @@ export default {
},
uploadImage
:
async
(
req
,
res
)
=>
{
try
{
const
p
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
const
p
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
);
let
fileName
=
uuid
.
v4
()
+
".png"
;
// console.log(fileName);
...
...
@@ -303,10 +325,7 @@ export default {
code
:
200
,
data
:
{
fileName
,
url
:
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
+
fileName
,
),
url
:
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
+
fileName
),
},
});
}
...
...
@@ -318,9 +337,13 @@ export default {
},
getPngImg
:
async
(
req
,
res
)
=>
{
try
{
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
const
filePath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()
}
/Input/
${
req
.
body
.
fileName
}
`
,
`./
${
version
}
/Input/
${
req
.
body
.
fileName
}
`
,
);
console
.
log
(
filePath
);
// 给客户端返回一个文件流 type类型
...
...
@@ -449,7 +472,11 @@ export default {
},
//删除图片
cleanDirectorySync
:
async
(
req
,
res
)
=>
{
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input`
);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
let
dirPath
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input`
);
if
(
!
fs
.
existsSync
(
dirPath
))
{
console
.
log
(
`目录不存在:
${
dirPath
}
`
);
res
.
json
({
code
:
500
,
msg
:
`目录不存在:
${
dirPath
}
`
});
...
...
@@ -481,7 +508,11 @@ export default {
},
saveToPng
:
async
(
req
,
res
)
=>
{
try
{
const
p
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
const
p
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
);
const
form
=
new
multiparty
.
Form
({
uploadDir
:
p
});
form
.
parse
(
req
,
function
(
err
,
fields
,
files
)
{
// console.log(367, fields, files, err);
...
...
@@ -494,10 +525,7 @@ export default {
fs
.
renameSync
(
file
.
path
,
path
.
join
(
p
,
fileName
));
list
.
push
({
fileName
,
url
:
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
+
fileName
,
),
url
:
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
+
fileName
),
});
});
res
.
json
({
...
...
src/server/utils/index.js
View file @
b0182596
import
{
exec
}
from
"child_process"
;
var
fs
=
require
(
"fs"
);
var
path
=
require
(
"path"
);
var
request
=
require
(
"request"
);
var
uuid
=
require
(
"uuid"
);
const
compressing
=
require
(
"compressing"
);
const
{
PassThrough
}
=
require
(
"stream"
);
const
{
getVersion
,
getLocation
}
=
require
(
"@/server/utils/store"
);
const
{
getVersion
,
getDesktopDevice
,
}
=
require
(
"@/server/utils/store"
);
//获取当前驱动版本
function
getCurrentVersion
()
{
const
version
=
getVersion
();
// console.log("version", version);
return
version
;
}
//获取当前设备类型
function
getCurrentDesktopDevice
()
{
const
version
=
getDesktopDevice
();
return
version
;
}
...
...
@@ -53,91 +62,14 @@ function zip(from, to) {
});
}
// // 下载素材
// export const downloadImage = (list) => {
// return new Promise((resolve, reject) => {
// try {
// // console.log("Formatted Folder Name:", folderName); // 检查替换结果
// let dirPath = path.join(process.cwd(), `./${getCurrentVersion()}/Input/`);
// console.log(62, dirPath);
// console.log("list", list);
// if (!fs.existsSync(dirPath)) {
// fs.mkdirSync(dirPath);
// }
// let count = 0;
// for (let i = 0; i < list.length; i++) {
// if (list[i].url && list[i].url.includes("http")) {
// let fileName = "";
// let type = 2;
// let flag =
// [
// ".zip",
// ".gzip",
// ".tar",
// ".taz",
// ".rar",
// ".7z",
// ".gz",
// ".bz2",
// ].filter((el) => list[i].url.toLowerCase().includes(el)).length > 0;
// if (flag) {
// fileName = list[i].url.split("/")[
// list[i].url.split("/").length - 1
// ];
// type = 1;
// } else {
// fileName = uuid.v4() + ".png";
// type = 2;
// }
// let p = path.join(
// process.cwd(),
// `./${getCurrentVersion()}/Input/` + fileName
// );
// let stream = fs.createWriteStream(p);
// request(list[i].url)
// .pipe(stream)
// .on("close", async function() {
// if (type === 1) {
// list[i].list = await zip(p, dirPath);
// if (count === list.length - 1) {
// resolve(list);
// }
// } else {
// if (!list[i].list) list[i].list = [];
// const filename = list[i].url.split("/")[
// list[i].url.split("/").length - 1
// ];
// console.log(filename);
// list[i].list.push({
// fileName,
// productionFile: p,
// designId: filename.split("_GCPS")[0],
// });
// }
// if (count === list.length - 1) {
// // console.log(list);
// resolve(list);
// }
// count++;
// });
// }
// }
// } catch (err) {
// console.log(err);
// reject(err);
// }
// });
// };
export
const
downloadImage
=
(
list
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
try
{
const
dirPath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
,
);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
const
dirPath
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
);
// 创建目录(如果不存在)
if
(
!
fs
.
existsSync
(
dirPath
))
{
fs
.
mkdirSync
(
dirPath
,
{
recursive
:
true
});
...
...
@@ -156,8 +88,6 @@ export const downloadImage = (list) => {
// 并行处理所有下载
const
downloadPromises
=
downloadItems
.
map
((
item
)
=>
{
return
new
Promise
(
async
(
itemResolve
)
=>
{
const
downloadPath
=
getLocation
();
let
downloadwriteStream
=
null
;
// 创建分流
const
passThrough
=
new
PassThrough
();
try
{
...
...
@@ -185,10 +115,6 @@ export const downloadImage = (list) => {
const
writeStream
=
fs
.
createWriteStream
(
filePath
);
const
requestStream
=
request
(
item
.
url
);
if
(
downloadPath
)
{
const
downloadFile
=
path
.
join
(
downloadPath
,
fileName
);
downloadwriteStream
=
fs
.
createWriteStream
(
downloadFile
);
}
// 添加超时处理
requestStream
.
on
(
"response"
,
(
response
)
=>
{
...
...
@@ -202,7 +128,6 @@ export const downloadImage = (list) => {
// 使用管道连接请求流和写入流
requestStream
.
pipe
(
passThrough
);
passThrough
.
pipe
(
writeStream
);
downloadwriteStream
&&
passThrough
.
pipe
(
downloadwriteStream
);
// 等待下载完成
await
new
Promise
((
resolveStream
)
=>
{
...
...
@@ -211,13 +136,6 @@ export const downloadImage = (list) => {
console
.
error
(
`下载失败:
${
item
.
url
}
`
,
err
);
resolveStream
();
});
if
(
downloadwriteStream
)
{
downloadwriteStream
.
on
(
"finish"
,
resolveStream
);
downloadwriteStream
.
on
(
"error"
,
(
err
)
=>
{
console
.
error
(
`下载失败:
${
item
.
url
}
`
,
err
);
resolveStream
();
});
}
});
if
(
isArchive
)
{
...
...
@@ -254,6 +172,9 @@ export const downloadImage = (list) => {
export
function
downloadOtherImage
(
list
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
const
currentDate
=
new
Date
();
// 将 UTC 时间转换为中国时间 (UTC + 8小时)
...
...
@@ -274,7 +195,7 @@ export function downloadOtherImage(list) {
.
split
(
"."
)[
0
];
let
otherTypePath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()
}
/Input/
${
folderName
}
`
,
`./
${
version
}
/Input/
${
folderName
}
`
,
);
if
(
!
fs
.
existsSync
(
otherTypePath
))
{
fs
.
mkdirSync
(
otherTypePath
);
...
...
@@ -343,10 +264,10 @@ export function downloadOtherImage(list) {
// 传递素材给前端
export
const
sendImg
=
(
filename
=
"sample.png"
)
=>
{
let
filePath
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Input/`
+
filename
,
);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
let
filePath
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Input/`
+
filename
);
if
(
!
fs
.
existsSync
(
filePath
))
{
return
false
;
}
...
...
@@ -356,12 +277,14 @@ export const sendImg = (filename = "sample.png") => {
};
export
const
toSend
=
(
body
)
=>
{
console
.
log
(
"999999999"
,
path
.
join
(
process
.
cwd
(),
getCurrentVersion
()));
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
body
.
cmd
,
{
cwd
:
path
.
join
(
process
.
cwd
(),
getCurrentVersion
()
),
shell
:
true
},
{
cwd
:
path
.
join
(
process
.
cwd
(),
version
),
shell
:
true
},
(
err
)
=>
{
// console.log(stdout, 1);
// console.log(stderr, 2);
...
...
@@ -370,7 +293,7 @@ export const toSend = (body) => {
if
(
!
err
)
{
exec
(
body
.
print_cmd
,
{
cwd
:
path
.
join
(
process
.
cwd
(),
getCurrentVersion
()
),
shell
:
true
},
{
cwd
:
path
.
join
(
process
.
cwd
(),
version
),
shell
:
true
},
(
err2
)
=>
{
console
.
log
(
err2
);
if
(
!
err2
)
{
...
...
@@ -379,7 +302,7 @@ export const toSend = (body) => {
fs
.
unlinkSync
(
path
.
join
(
process
.
cwd
(),
`
${
getCurrentVersion
()
}
/Profile/`
+
`
${
version
}
/Profile/`
+
body
.
fileName
.
replace
(
".png"
,
""
)
+
".xml"
,
),
...
...
@@ -387,7 +310,7 @@ export const toSend = (body) => {
fs
.
unlinkSync
(
path
.
join
(
process
.
cwd
(),
`
${
getCurrentVersion
()
}
/Output/`
+
`
${
version
}
/Output/`
+
body
.
fileName
.
replace
(
".png"
,
""
)
+
".arxp"
,
),
...
...
@@ -417,12 +340,11 @@ export const toSend = (body) => {
export
const
writeProfileXml
=
(
b
)
=>
{
// console.log(b);
const
desktopDevice
=
getCurrentDesktopDevice
();
const
version
=
desktopDevice
==
3
?
"huiLiCaiImg"
:
getCurrentVersion
();
console
.
log
(
"version"
,
version
);
try
{
let
p
=
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Profile/
${
b
.
byInk
}
.xml`
,
);
let
p
=
path
.
join
(
process
.
cwd
(),
`./
${
version
}
/Profile/
${
b
.
byInk
}
.xml`
);
let
file
=
fs
.
readFileSync
(
p
,
{
encoding
:
"utf8"
});
file
=
file
.
replace
(
/<uiCopies>
(
.*
)
<
\/
uiCopies>/i
,
...
...
@@ -520,10 +442,7 @@ export const writeProfileXml = (b) => {
fs
.
writeFileSync
(
path
.
join
(
process
.
cwd
(),
`./
${
getCurrentVersion
()}
/Profile/
${
b
.
fileName
.
replace
(
".png"
,
""
,
)}
.xml`
,
`./
${
version
}
/Profile/
${
b
.
fileName
.
replace
(
".png"
,
""
)}
.xml`
,
),
file
,
);
...
...
@@ -531,3 +450,84 @@ export const writeProfileXml = (b) => {
console
.
log
(
404
,
err
);
}
};
/**
* 复制单个图片文件到目标文件夹(已知图片完整路径)
* @param {string} sourceImagePath - 源图片的完整绝对路径
* @param {string} targetDir - 目标文件夹路径(只传文件夹,不用传文件名)
* @returns {Promise<void>}
*/
const
fsPromises
=
fs
.
promises
;
// 明确获取 promises 异步 API
export
async
function
copySingleImage
(
sourceImagePath
,
targetDir
)
{
// 先打印传入的原始路径(方便验证是否和预期一致)
// console.log(`传入参数验证:
// 源图片路径:${sourceImagePath}
// 目标文件夹路径:${targetDir}`);
try
{
// 步骤1:路径规范化(修正潜在的分隔符/隐形字符问题)
const
normalizedSourcePath
=
path
.
resolve
(
sourceImagePath
);
const
normalizedTargetDir
=
path
.
resolve
(
targetDir
);
// console.log(`路径规范化后:
// 源图片路径:${normalizedSourcePath}
// 目标文件夹路径:${normalizedTargetDir}`);
// 步骤2:校验源文件是否为有效图片文件
let
fileStat
;
try
{
fileStat
=
await
fsPromises
.
stat
(
normalizedSourcePath
);
}
catch
(
err
)
{
throw
new
Error
(
`获取源文件状态失败:
${
err
.
message
}
(错误码:
${
err
.
code
}
)`
,
);
}
// 2.1 校验是否为文件(非文件夹)
if
(
!
fileStat
.
isFile
())
{
throw
new
Error
(
`源路径不是有效文件,是文件夹:
${
normalizedSourcePath
}
`
);
}
// console.log("校验通过:源路径是有效文件");
// 2.2 校验是否为图片格式(可选,过滤非图片文件)
const
validImageExts
=
[
".jpg"
,
".jpeg"
,
".png"
,
".gif"
,
".bmp"
];
const
fileExt
=
path
.
extname
(
normalizedSourcePath
).
toLowerCase
();
if
(
!
validImageExts
.
includes
(
fileExt
))
{
throw
new
Error
(
`源文件不是有效图片格式,后缀为:
${
fileExt
}
(支持格式:
${
validImageExts
.
join
(
", "
,
)}
)`
,
);
}
// console.log(`校验通过:源文件是图片格式(${fileExt})`);
// 步骤3:获取文件名 + 拼接目标图片完整路径
const
imageFileName
=
path
.
basename
(
normalizedSourcePath
);
const
targetImagePath
=
path
.
join
(
normalizedTargetDir
,
imageFileName
);
// console.log(`拼接目标文件路径:${targetImagePath}`);
// 步骤4:创建目标文件夹(递归创建,已存在则不报错)
try
{
await
fsPromises
.
mkdir
(
normalizedTargetDir
,
{
recursive
:
true
});
// console.log(`目标文件夹创建成功(已存在则跳过):${normalizedTargetDir}`);
}
catch
(
err
)
{
throw
new
Error
(
`创建目标文件夹失败:
${
err
.
message
}
(错误码:
${
err
.
code
}
)`
,
);
}
// 步骤5:复制图片文件(核心操作)
try
{
await
fsPromises
.
copyFile
(
normalizedSourcePath
,
targetImagePath
);
console
.
log
(
`✅ 图片复制成功!`
);
}
catch
(
err
)
{
throw
new
Error
(
`复制文件操作失败:
${
err
.
message
}
(错误码:
${
err
.
code
}
)`
,
);
}
}
catch
(
err
)
{
console
.
error
(
"❌ 单个图片复制失败:"
,
err
.
message
);
throw
err
;
}
}
src/server/utils/store.js
View file @
b0182596
...
...
@@ -2,6 +2,30 @@ const Store = require("electron-store");
const
store
=
new
Store
({
watch
:
true
});
// 导出 store 实例(新增:方便外部获取实例进行监听)
// ===== 新增:私有缓存 Map + 缓存刷新方法 =====
let
orderCacheMap
=
new
Map
();
// 模块内私有缓存,避免重复转换
const
DEFAULT_UNIQUE_KEY
=
"newId"
;
// 刷新缓存:从 electron-store 读取数组,转为 Map 存入缓存
function
refreshOrderCache
(
uniqueKey
=
DEFAULT_UNIQUE_KEY
)
{
const
currentArray
=
store
.
get
(
"orderInfo"
)
||
[];
const
newMap
=
new
Map
();
currentArray
.
forEach
((
item
)
=>
{
if
(
item
&&
item
[
uniqueKey
])
{
newMap
.
set
(
item
[
uniqueKey
],
item
);
}
});
orderCacheMap
=
newMap
;
// 更新缓存 Map
}
// 初始化缓存(模块加载时执行一次)
refreshOrderCache
();
// 辅助工具函数:将 Map 转回对象数组
function
mapToArray
(
dataMap
)
{
return
Array
.
from
(
dataMap
.
values
());
}
module
.
exports
=
{
//存储当前打印驱动版本
setVersion
:
(
version
)
=>
{
...
...
@@ -38,13 +62,109 @@ module.exports = {
},
getBoard
:
()
=>
store
.
get
(
"desktoBoard"
)
||
3
,
//下载位置
setLocation
:
(
version
)
=>
{
store
.
set
(
"downloadLocation"
,
version
);
setLocation
:
(
version
,
locationKey
)
=>
{
store
.
set
(
locationKey
,
version
);
},
getLocation
:
(
)
=>
store
.
get
(
"downloadLocation"
)
||
""
,
getLocation
:
(
locationKey
)
=>
store
.
get
(
locationKey
)
||
""
,
//设备
setDesktopDevice
:
(
version
)
=>
{
store
.
set
(
"desktopDevice"
,
version
);
},
getDesktopDevice
:
()
=>
store
.
get
(
"desktopDevice"
)
||
"1"
,
// ===== 基于缓存 Map 优化的 orderInfo 方法 =====
getOrderInfo
:
()
=>
store
.
get
(
"orderInfo"
)
||
[],
setOrderInfo
:
(
newData
,
uniqueKey
=
DEFAULT_UNIQUE_KEY
)
=>
{
let
newObjArray
=
[];
if
(
newData
instanceof
Map
)
{
newObjArray
=
mapToArray
(
newData
);
}
else
if
(
Array
.
isArray
(
newData
))
{
const
isValidObjArray
=
newData
.
every
(
(
item
)
=>
typeof
item
===
"object"
&&
item
!==
null
,
);
if
(
!
isValidObjArray
)
{
console
.
warn
(
"setOrderInfo 要求数组内所有元素都是对象类型"
);
return
;
}
newObjArray
=
newData
;
}
else
{
console
.
warn
(
"setOrderInfo 要求传入数组或 Map 类型,当前传入值无效"
);
return
;
}
store
.
set
(
"orderInfo"
,
newObjArray
);
// 新增:更新缓存 Map(无需重新从 store 读取,直接转换新数组)
const
newMap
=
new
Map
();
newObjArray
.
forEach
((
item
)
=>
{
if
(
item
&&
item
[
uniqueKey
])
{
newMap
.
set
(
item
[
uniqueKey
],
item
);
}
});
orderCacheMap
=
newMap
;
},
addToOrderInfo
:
(
newOrderObj
,
uniqueKey
=
DEFAULT_UNIQUE_KEY
)
=>
{
if
(
typeof
newOrderObj
!==
"object"
||
newOrderObj
===
null
||
!
newOrderObj
[
uniqueKey
]
)
{
console
.
warn
(
"添加失败:请传入包含唯一标识(默认id)的有效对象"
);
return
;
}
const
uniqueValue
=
newOrderObj
[
uniqueKey
];
// 直接操作缓存 Map(O(1),无需重新转换)
if
(
orderCacheMap
.
has
(
uniqueValue
))
{
console
.
log
(
`该对象(
${
uniqueKey
}
=
${
uniqueValue
}
)已存在,不重复添加`
);
return
;
}
orderCacheMap
.
set
(
uniqueValue
,
newOrderObj
);
// 写入 store 时,仅转换缓存 Map(一次 O(n),而非每次操作都 O(n))
const
newArray
=
mapToArray
(
orderCacheMap
);
store
.
set
(
"orderInfo"
,
newArray
);
},
removeFromOrderInfo
:
(
uniqueValue
,
uniqueKey
=
DEFAULT_UNIQUE_KEY
)
=>
{
// 直接操作缓存 Map(O(1))
if
(
!
orderCacheMap
.
has
(
uniqueValue
))
{
console
.
log
(
`未找到
${
uniqueKey
}
=
${
uniqueValue
}
的对象,删除失败`
);
return
;
}
orderCacheMap
.
delete
(
uniqueValue
);
const
newArray
=
mapToArray
(
orderCacheMap
);
store
.
set
(
"orderInfo"
,
newArray
);
},
// 其他方法(updateOrderInfoItem、getOrderInfoItem)同理,均直接操作 orderCacheMap
updateOrderInfoItem
:
(
uniqueValue
,
newOrderObj
,
uniqueKey
=
DEFAULT_UNIQUE_KEY
,
)
=>
{
if
(
typeof
newOrderObj
!==
"object"
||
newOrderObj
===
null
)
{
console
.
warn
(
"修改失败:请传入有效对象"
);
return
;
}
// 直接操作缓存 Map(O(1) 查找)
const
targetObj
=
orderCacheMap
.
get
(
uniqueValue
);
if
(
!
targetObj
)
{
console
.
log
(
`未找到
${
uniqueKey
}
=
${
uniqueValue
}
的对象,修改失败`
);
return
;
}
const
updatedObj
=
{
...
targetObj
,
...
newOrderObj
};
orderCacheMap
.
set
(
uniqueValue
,
updatedObj
);
const
newArray
=
mapToArray
(
orderCacheMap
);
store
.
set
(
"orderInfo"
,
newArray
);
},
getOrderInfoItem
:
(
uniqueValue
)
=>
{
// 直接操作缓存 Map(O(1) 查找,无需任何转换)
const
targetObj
=
orderCacheMap
.
get
(
uniqueValue
);
return
targetObj
||
null
;
},
};
src/views/design/head/index.vue
View file @
b0182596
<
script
>
import
bus
from
"@/bus"
;
// import PrintDialog from "./printDialog.vue";
import
{
getProductCnByFactorySubOrderNumberApi
}
from
"../../../api/index.js"
;
//
import { getProductCnByFactorySubOrderNumberApi } from "../../../api/index.js";
import
{
ipcRenderer
}
from
"electron"
;
// import { grid } from "../data";
import
pkg
from
"../../../../package.json"
;
...
...
@@ -16,10 +16,13 @@ const {
getVersion
,
getHostApi
,
setApi
,
getLocation
,
setLocation
,
setDesktopDevice
,
getDesktopDevice
,
getOrderInfo
,
getOrderInfoItem
,
addToOrderInfo
,
updateOrderInfoItem
,
removeFromOrderInfo
,
}
=
require
(
"@/server/utils/store"
);
export
default
{
...
...
@@ -74,11 +77,10 @@ export default {
autoPrint
:
false
,
gridSpacing
:
1
,
},
imgList
:
[],
detail
:
null
,
config
:
getHostApi
(),
newApiApiHost
:
""
,
downloadLocation
:
getLocation
(),
selectBgColor
:
"#ececec"
,
predefineColors
:
[
"#ff4500"
,
...
...
@@ -103,7 +105,13 @@ export default {
return
this
.
$store
.
getters
.
getActionList
;
},
...
mapState
([
"defaultProportion"
,
"countryList"
,
"orderType"
,
"grid"
]),
...
mapState
([
"defaultProportion"
,
"countryList"
,
"orderType"
,
"grid"
,
"imgList"
,
]),
},
mounted
()
{
// console.log(pkg, "pkg");
...
...
@@ -112,6 +120,7 @@ export default {
this
.
selectGridIndex
=
0
;
this
.
setting
.
gridValue
=
0
;
});
this
.
$store
.
commit
(
"changeDesktopDevice"
,
getDesktopDevice
());
},
created
()
{
localStorage
.
setItem
(
"desktoVersion"
,
"print"
);
...
...
@@ -139,6 +148,9 @@ export default {
immediate
:
true
,
deep
:
true
,
},
desktopDevice
(
val
)
{
this
.
checked
=
false
;
},
},
methods
:
{
checkUpdate
()
{
...
...
@@ -183,9 +195,18 @@ export default {
}
else
if
(
this
.
orderType
===
"US"
)
{
params
.
podJomallOrderUsId
=
data
.
podJomallOrderUsId
;
}
await
this
.
$api
.
post
(
"/completeDelivery"
,
params
).
then
(()
=>
{});
this
.
$message
.
success
(
"操作成功"
);
const
canCallApi
=
this
.
desktoVersion
!==
3
||
(
data
.
saveImgList
?.
every
((
el
)
=>
el
.
power
)
??
false
);
if
(
canCallApi
)
{
console
.
log
(
"生产完成数据"
,
data
);
console
.
log
(
"本地数据:"
,
getOrderInfo
());
removeFromOrderInfo
(
data
.
newId
);
return
;
await
this
.
$api
.
post
(
"/completeDelivery"
,
params
);
this
.
$message
.
success
(
"操作成功"
);
}
},
async
sureData
()
{
if
(
!
this
.
detail
||
Object
.
keys
(
this
.
detail
).
length
<=
1
)
{
...
...
@@ -306,17 +327,17 @@ export default {
}
return
new
File
([
u8arr
],
fileName
,
{
type
:
"image/png"
});
},
async
downloadImage
()
{
if
(
!
this
.
detail
||
Object
.
keys
(
this
.
detail
).
length
===
0
)
return
this
.
$message
.
warning
(
"请扫描生产单号"
);
let
params
=
{
productionNo
:
this
.
detail
.
factorySubOrderNumber
,
imgList
:
this
.
imgList
,
};
let
res
=
await
this
.
$api
.
post
(
"/downloadByDesignId"
,
params
);
this
.
$message
.
success
(
res
.
msg
);
},
//
async downloadImage() {
//
if (!this.detail || Object.keys(this.detail).length === 0)
//
return this.$message.warning("请扫描生产单号");
//
let params = {
//
productionNo: this.detail.factorySubOrderNumber,
//
imgList: this.imgList,
//
};
//
let res = await this.$api.post("/downloadByDesignId", params);
//
this.$message.success(res.msg);
//
},
async
saveImgByUrl
(
url
)
{
try
{
let
res
=
await
this
.
$api
.
post
(
"/saveImgByUrl"
,
{
url
});
...
...
@@ -325,7 +346,7 @@ export default {
throw
new
Error
(
e
.
message
);
// 或者直接 throw e;
}
},
async
hasDesignImagesCanvasJsonList
(
designImagesCanvasJsonList
)
{
async
hasDesignImagesCanvasJsonList
(
designImagesCanvasJsonList
,
bool
)
{
let
imageResList
=
[];
if
(
!
this
.
checked
&&
...
...
@@ -362,7 +383,7 @@ export default {
// }
}
}
if
(
!
imageResList
.
length
)
{
if
(
!
imageResList
.
length
&&
!
bool
)
{
// console.log(347, this.orderType);
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
...
...
@@ -371,11 +392,17 @@ export default {
device
:
this
.
$store
.
state
.
desktopDevice
,
orderType
:
this
.
orderType
,
});
console
.
log
(
"downloadBySubOrderNumber"
,
res
);
if
(
!
res
.
data
.
length
)
return
this
.
$message
.
warning
(
"未找到素材图!"
);
res
.
data
.
forEach
((
el
)
=>
{
imageResList
=
imageResList
.
concat
(
el
.
list
||
[]);
});
}
else
if
(
bool
)
{
imageResList
=
this
.
detail
?.
saveImgList
||
[];
}
if
(
this
.
checked
)
{
imageResList
=
await
this
.
cutImgFn
(
imageResList
);
imageResList
.
forEach
((
el
)
=>
{
...
...
@@ -384,7 +411,7 @@ export default {
}
// 延迟后强制激活窗口
if
(
this
.
desktopDevice
!==
1
)
{
if
(
this
.
desktopDevice
==
2
)
{
if
(
imageResList
.
length
)
{
let
pathUrl
=
imageResList
[
0
].
productionFile
;
setTimeout
(
async
()
=>
{
...
...
@@ -446,11 +473,29 @@ export default {
height: this.detail.mssHeight,
};
}
if (newImgList.length > 1 && !bool) {
const templateobj = { ...this.detail };
templateobj["
saveImgList
"] = [...newImgList].map((el) => {
el.power = false;
return { ...el };
});
addToOrderInfo(templateobj);
console.log("
本地数据:
", getOrderInfo());
}
bus.$emit("
busEmit
", obj);
}
},
async getDataInfo() {
if (this.detail && this.imgList?.length && this.desktopDevice === 3) {
const item = this.detail?.saveImgList?.find(
(el) => el.fileName == this.imgList[0].fileName,
);
if (item) item.power = true;
updateOrderInfoItem(this.detail.newId, this.detail);
console.log("
本地数据:
", getOrderInfo());
}
if (
this.detail &&
Object.keys(this.detail).length > 0 &&
...
...
@@ -495,45 +540,47 @@ export default {
this.$store.commit("
setOrderType
", str);
}
// console.log(423, this.productionNo);
try {
// const urlArr = {
// CN: {
// field: "
factorySubOrderNumber
",
// fn: getProductCnByFactorySubOrderNumberApi,
// },
// US: {
// field: "
factorySubOrderNumber
",
// fn:
// "
factory
/
podJomallOrderProductUs
/
getProductUsByFactorySubOrderNumber
",
// },
// GC: {
// field: "
thirdSubOrderNumber
",
// fn:
// "
factory
/
podJomallOrderProduct
/
getSubOrderByThirdSubOrderNumber
",
// },
// };
// //查找生产单号信息
// const findByPodProductionNo = getProductCnByFactorySubOrderNumberApi(
// this.productionNo,
// );
// console.log(494, findByPodProductionNo);
const findByPodProductionNo = await this.$api.post(
"
/
findByPodProductionNo
",
{
thirdSubOrderNumber: this.productionNo,
orderType: this.orderType,
},
);
const arr = await getOrderInfo();
const localItem = getOrderInfoItem(this.productionNo);
let findByPodProductionNo;
const apiRequestParams = {
thirdSubOrderNumber: this.productionNo,
orderType: this.orderType,
};
if (this.desktopDevice === 3) {
if (arr.length > 0) {
findByPodProductionNo =
{ data: { ...localItem } } ||
(await this.$api.post(
"
/
findByPodProductionNo
",
apiRequestParams,
));
} else {
findByPodProductionNo = await this.$api.post(
"
/
findByPodProductionNo
",
apiRequestParams,
);
}
} else {
findByPodProductionNo = await this.$api.post(
"
/
findByPodProductionNo
",
apiRequestParams,
);
}
console.log("
findByPodProductionNo
", findByPodProductionNo);
this.detail = findByPodProductionNo.data;
// console.log(491, this.detail)
;
this.detail["
newId
"] = this.productionNo
;
this.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam;
// this.detail.drParam;
await this.hasDesignImagesCanvasJsonList(designImagesCanvasJsonList);
await this.hasDesignImagesCanvasJsonList(
designImagesCanvasJsonList,
this.desktopDevice === 3 ? (localItem ? true : false) : false,
);
this.$store.commit("
setProductDetail
", findByPodProductionNo.data);
ipcRenderer.send("
win
-
subScreen
", findByPodProductionNo.data);
this.$dataStore.set("
production_no
", this.productionNo);
...
...
@@ -651,6 +698,7 @@ export default {
this.selectedOption = command; // 根据选中的项来更新 selectedOption
},
changeDesktopDeviceFn(value) {
console.log("
changeDesktopDeviceFn
", value);
setDesktopDevice(value);
this.$store.commit("
changeDesktopDevice
", value);
this.$store.commit("
changeImgList
", []);
...
...
@@ -766,24 +814,6 @@ export default {
return null;
}
},
changeLocation() {
// setLocation("");
ipcRenderer.send("
request
-
select
-
folder
");
const handleFolderResult = (event, folderPath) => {
// 移除监听(关键:避免多次点击后触发多次回调)
ipcRenderer.removeListener("
select
-
folder
-
result
", handleFolderResult);
// 3. 如果用户未取消选择,赋值给 downloadLocation
if (folderPath) {
this.downloadLocation = folderPath;
// setLocation("");
setLocation(folderPath);
}
};
// 4. 监听主进程返回的结果消息
ipcRenderer.on("
select
-
folder
-
result
", handleFolderResult);
},
},
};
</
script
>
...
...
@@ -956,19 +986,6 @@ export default {
>
检查更新
</el-button>
</el-form-item>
<div>
<el-form-item
label=
"下载位置"
>
<div
style=
"display: flex; "
>
<el-input
:title=
"downloadLocation"
v-model=
"downloadLocation"
:disabled=
"true"
style=
"flex: 1;margin-right: 5px;"
></el-input>
<el-button
@
click=
"changeLocation"
>
浏览
</el-button>
</div>
</el-form-item>
</div>
</el-form>
</div>
<el-tooltip
slot=
"reference"
content=
"设置"
>
...
...
@@ -1007,14 +1024,11 @@ 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=
"isAutoFinish"
>
自动完成上一单
</el-checkbox>
</div>
<div
style=
"margin-left: 10px;"
>
<div
style=
"margin-left: 10px;"
v-show=
"desktopDevice != 3"
>
<el-checkbox
v-model=
"checked"
>
自动裁切
</el-checkbox>
</div>
<!--
<el-button
...
...
src/views/design/main/imgSetting.vue
View file @
b0182596
...
...
@@ -34,6 +34,10 @@ export default {
type
:
Object
,
default
:
()
=>
{},
},
newDesktopDevice
:
{
type
:
[
String
,
Number
],
default
:
"1"
,
},
},
watch
:
{
visible
:
{
...
...
@@ -48,6 +52,20 @@ export default {
if
(
this
.
item
)
{
this
.
getCurrentItem
(
this
.
item
);
}
else
{
this
.
form
=
{
x
:
0
,
rate
:
0
,
sx
:
0
,
zIndex
:
0
,
sh
:
0
,
sw
:
0
,
sy
:
0
,
y
:
0
,
w
:
0
,
h
:
0
,
r
:
0
,
};
}
},
immediate
:
true
,
...
...
@@ -58,7 +76,7 @@ export default {
pxToUnit
,
unitToPx
,
getCurrentItem
(
item
)
{
let
setting
=
this
.
$dataStore
.
get
(
"setting"
);
//
let setting = this.$dataStore.get("setting");
this
.
item
.
y
=
item
.
y
-
item
.
h
/
2
;
this
.
item
.
x
=
item
.
x
-
item
.
w
/
2
;
this
.
$dataStore
.
set
(
...
...
@@ -152,7 +170,7 @@ export default {
<
template
>
<div
class=
"drawer"
>
<div
class=
"img-form"
>
<div
class=
"img-form"
v-show=
"newDesktopDevice != 3"
>
<div
class=
"title"
>
图片编辑(单位:
{{
$dataStore
.
get
(
"setting"
).
unit
}}
)
</div>
...
...
@@ -161,6 +179,7 @@ export default {
:disabled=
"!(item && !isPreView)"
style=
""
:model=
"form"
ref=
"formRef"
label-position=
"left"
label-width=
"30px"
>
...
...
@@ -306,6 +325,7 @@ export default {
.img-form
{
padding
:
5px
10px
;
border
:
1px
solid
#ececec
;
border-bottom
:
none
;
}
::v-deep
{
...
...
src/views/design/main/index.vue
View file @
b0182596
<
script
>
import
VueDragResizeRotate
from
"@minogin/vue-drag-resize-rotate"
;
// import PicScrollbarBox from "../../../components/PicScrollbarBox.vue";
const
{
ipcRenderer
}
=
require
(
"electron"
);
// import { fabric } from "fabric";
import
ImgSetting
from
"./imgSetting.vue"
;
import
bus
from
"@/bus"
;
import
PrintDialog
from
"@/views/design/head/printDialog.vue"
;
...
...
@@ -13,12 +9,16 @@ import { mmToPx, extractValue } from "@/utils";
const
path
=
require
(
"path"
);
const
fs
=
require
(
"fs"
);
const
uuid
=
require
(
"uuid"
);
// import { startLoading, endLoading } from "@/utils/axios
.js";
import
{
copySingleImage
}
from
"@/server/utils/index
.js"
;
import
{
mapState
}
from
"vuex"
;
const
img
=
require
(
"../../../assets/bg_tshirt_shadow.png"
);
const
{
getDesktopDevice
}
=
require
(
"@/server/utils/store"
);
const
{
getDesktopDevice
,
setLocation
,
getLocation
,
}
=
require
(
"@/server/utils/store"
);
export
default
{
components
:
{
...
...
@@ -121,11 +121,15 @@ export default {
},
returnItem
()
{
// console.log(128, this.imgList);
if
(
this
.
selectIndex
<
0
&&
this
.
imgList
.
length
)
{
// this.showImgSetting = false;
this
.
selectIndex
=
0
;
}
let
item
=
this
.
imgList
[
this
.
selectIndex
];
// console.log("item", item);
if
(
item
)
{
item
=
JSON
.
parse
(
JSON
.
stringify
(
item
));
item
.
x
=
Number
(
item
.
x
)
-
Number
(
item
.
w
);
...
...
@@ -203,11 +207,13 @@ export default {
topPosition
:
"52%"
,
currentImgData
:
null
,
newDesktopDevice
:
getDesktopDevice
(),
downloadLocation1
:
getLocation
(
"downloadLocation1"
),
downloadLocation2
:
getLocation
(
"downloadLocation2"
),
};
},
watch
:
{
imgList
:
{
handler
(
newValue
)
{
async
handler
(
newValue
)
{
const
image
=
document
.
getElementById
(
"imgBox"
);
if
(
newValue
.
length
&&
image
)
{
...
...
@@ -217,41 +223,9 @@ export default {
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
(()
=>
{
let
dom
=
document
.
getElementsByClassName
(
"drr"
);
console
.
log
(
228
,
dom
);
this
.
imgList
.
forEach
((
el
,
i
)
=>
{
let
dom_i
=
document
.
getElementsByClassName
(
"drr"
)[
i
];
...
...
@@ -265,7 +239,53 @@ export default {
});
});
});
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`
,
`-------------------------------------------------`
,
];
// if (this.downloadLocation1) {
// }
// console.log(240, newValue);
// if (this.downloadLocation1 && this.newDesktopDevice == 3) {
// try {
// copySingleImage(newValue[0].url, this.downloadLocation1);
// copySingleImage(newValue[0].url, this.downloadLocation2);
// this.$message.success("图片已发送目标文件夹下");
// } catch (error) {
// this.$message.error("发送失败");
// console.log(error);
// }
// }
// 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}`,
// );
}
this
.
$store
.
commit
(
"changeImgList"
,
this
.
imgList
);
},
deep
:
true
,
...
...
@@ -282,12 +302,12 @@ export default {
},
desktopDevice
(
newValue
)
{
this
.
newDesktopDevice
=
getDesktopDevice
();
if (newValue == 2) {
this.imgList = [];
this.selectI
mgList = [];
this.selectIndex = -1
;
this.selectImgIndex = 0
;
}
this
.
detail
=
{};
this
.
i
mgList
=
[];
this
.
selectImgList
=
[]
;
this
.
selectIndex
=
-
1
;
this
.
selectImgIndex
=
0
;
},
desktoVersion
(
newValue
)
{
if
(
newValue
)
{
...
...
@@ -672,6 +692,8 @@ export default {
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
)));
},
outsideClick
(
e
)
{
if
(
this
.
newDesktopDevice
==
3
)
return
;
if
(
!
(
e
.
target
.
className
.
includes
(
"drr"
)
||
...
...
@@ -1183,6 +1205,17 @@ export default {
}
});
},
changeLocation
(
v
)
{
ipcRenderer
.
send
(
"request-select-folder"
);
const
handleFolderResult
=
(
event
,
folderPath
)
=>
{
ipcRenderer
.
removeListener
(
"select-folder-result"
,
handleFolderResult
);
if
(
folderPath
)
{
this
[
v
]
=
folderPath
;
setLocation
(
folderPath
,
v
);
}
};
ipcRenderer
.
on
(
"select-folder-result"
,
handleFolderResult
);
},
},
mounted
()
{
this
.
imgHeight
=
window
.
screen
.
height
+
"px"
;
...
...
@@ -1259,13 +1292,14 @@ export default {
</
script
>
<
template
>
<div
class=
"page-main"
v-if=
"newDesktopDevice != 3"
>
<div
class=
"page-main"
>
<img-setting
ref=
"imgSetting"
@
ev=
"ev"
@
change=
"formChange"
:item=
"returnItem"
@
close=
"close"
:newDesktopDevice=
"newDesktopDevice"
>
<template
#
content
>
<div
class=
"information-content"
>
...
...
@@ -1295,7 +1329,7 @@ export default {
style=
"display: flex;justify-content: space-between;align-items: center;padding: 0 10px;"
>
<div>
素材图
</div>
<div
v-if=
"selectImgList.length"
>
<div
v-if=
"selectImgList.length
&& newDesktopDevice != 3
"
>
<el-button
type=
"primary"
size=
"small"
...
...
@@ -1475,6 +1509,40 @@ export default {
</div>
</div>
</div>
<div
class=
"main"
v-show=
"newDesktopDevice == 3"
style=
"margin-top: 20px;"
>
<el-form>
<el-form-item
label=
"下载位置1"
>
<div
style=
"display: flex; "
>
<el-input
:title=
"downloadLocation1"
v-model=
"downloadLocation1"
:disabled=
"true"
style=
"flex: 1;margin-right: 5px;"
></el-input>
<el-button
@
click=
"changeLocation('downloadLocation1')"
>
浏览
</el-button
>
</div>
</el-form-item>
<el-form-item
label=
"下载位置2"
>
<div
style=
"display: flex; "
>
<el-input
:title=
"downloadLocation2"
v-model=
"downloadLocation2"
:disabled=
"true"
style=
"flex: 1;margin-right: 5px;"
></el-input>
<el-button
@
click=
"changeLocation('downloadLocation2')"
>
浏览
</el-button
>
</div>
</el-form-item>
</el-form>
</div>
</
template
>
</img-setting>
<div
...
...
@@ -1668,7 +1736,7 @@ export default {
:style=
"{ 'z-index': isView ? '0' : '-1' }"
/>
</div>
<div>
<div
v-show=
"newDesktopDevice != 3"
>
<print-dialog
:isDisabled=
"isView"
:visible=
"printDialogShow"
...
...
@@ -1941,7 +2009,7 @@ img {
.information-content
{
border
:
1px
solid
#ececec
;
border-top
:
none
;
//
border-top
:
none
;
width
:
100%
;
box-sizing
:
border-box
;
.main
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment