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
6df3273f
Commit
6df3273f
authored
Mar 23, 2026
by
linjinhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修改下载素材
parent
56907510
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
60 deletions
+61
-60
src/utils/index.js
+5
-0
src/views/design/head/index.vue
+39
-39
src/views/design/main/imgSetting.vue
+1
-0
src/views/design/main/index.vue
+16
-21
No files found.
src/utils/index.js
View file @
6df3273f
...
...
@@ -243,3 +243,8 @@ export function extractValue(str) {
if
(
str
.
includes
(
"_A_"
))
return
"A"
;
if
(
str
.
includes
(
"_B_"
))
return
"B"
;
}
export
function
mmToPxFn
(
mm
)
{
const
px
=
(
Number
(
mm
)
/
25.4
)
*
42
;
return
Number
(
px
.
toFixed
(
1
));
}
src/views/design/head/index.vue
View file @
6df3273f
...
...
@@ -450,45 +450,45 @@ export default {
let
imageResList
=
[];
//当adjustable有值时 直接赋值宽高
if
(
!
this
.
checked
&&
this
.
detail
.
diyId
&&
this
.
detail
.
adjustable
&&
designImagesCanvasJsonList
&&
this
.
desktopDevice
!==
3
)
{
designImagesCanvasJsonList
=
JSON
.
parse
(
designImagesCanvasJsonList
);
if
(
!
designImagesCanvasJsonList
[
0
].
images
)
{
this
.
detail
.
isCustom
=
true
;
let
imageList
=
await
this
.
canvasToImage
(
designImagesCanvasJsonList
);
let
fm
=
new
FormData
();
for
(
let
img
of
imageList
)
{
let
filename
=
uuid
.
v4
().
replace
(
"-"
,
""
)
+
".png"
;
fm
.
append
(
"files"
,
this
.
base64ToFile
(
img
,
filename
));
}
// console.log("fm", fm);
let
Sres
=
await
this
.
$api
.
post
(
"/saveToPng"
,
fm
);
Sres
.
data
.
forEach
((
item
,
i
)
=>
{
item
.
title
=
designImagesCanvasJsonList
[
i
].
options
.
title
;
item
.
productionFile
=
item
.
url
;
item
.
designId
=
item
.
designId
||
i
.
toString
();
});
imageResList
=
Sres
.
data
;
console
.
log
(
"imageResList"
,
imageResList
);
}
else
{
// designImagesCanvasJsonList.forEach((el) => {
// el.images.forEach((item) => {
// imageResList.push({
// productionFile: item,
// title: el.title,
// });
// });
// });
// for (let item of imageResList) {
// item.productionFile = await this.saveImgByUrl(item.productionFile);
// }
}
}
//
if (
//
!this.checked &&
//
this.detail.diyId &&
//
this.detail.adjustable &&
//
designImagesCanvasJsonList &&
//
this.desktopDevice !== 3
//
) {
//
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
//
if (!designImagesCanvasJsonList[0].images) {
//
this.detail.isCustom = true;
//
let imageList = await this.canvasToImage(designImagesCanvasJsonList);
//
let fm = new FormData();
//
for (let img of imageList) {
//
let filename = uuid.v4().replace("-", "") + ".png";
//
fm.append("files", this.base64ToFile(img, filename));
//
}
//
// console.log("fm", fm);
//
let Sres = await this.$api.post("/saveToPng", fm);
//
Sres.data.forEach((item, i) => {
//
item.title = designImagesCanvasJsonList[i].options.title;
//
item.productionFile = item.url;
//
item.designId = item.designId || i.toString();
//
});
//
imageResList = Sres.data;
//
console.log("imageResList", imageResList);
//
} else {
//
// designImagesCanvasJsonList.forEach((el) => {
//
// el.images.forEach((item) => {
//
// imageResList.push({
//
// productionFile: item,
//
// title: el.title,
//
// });
//
// });
//
// });
//
// for (let item of imageResList) {
//
// item.productionFile = await this.saveImgByUrl(item.productionFile);
//
// }
//
}
//
}
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
if
(
!
imageResList
.
length
&&
!
bool
)
{
...
...
src/views/design/main/imgSetting.vue
View file @
6df3273f
...
...
@@ -81,6 +81,7 @@ export default {
unitToPx
,
getCurrentItem
(
item
)
{
// let setting = this.$dataStore.get("setting");
console
.
log
(
84
,
item
);
this
.
item
.
y
=
item
.
y
-
item
.
h
/
2
;
this
.
item
.
x
=
item
.
x
-
item
.
w
/
2
;
...
...
src/views/design/main/index.vue
View file @
6df3273f
...
...
@@ -4,7 +4,7 @@ const { ipcRenderer } = require("electron");
import
ImgSetting
from
"./imgSetting.vue"
;
import
bus
from
"@/bus"
;
import
PrintDialog
from
"@/views/design/head/printDialog.vue"
;
import
{
mmToPx
,
extractValue
}
from
"@/utils"
;
import
{
mmToPx
,
mmToPxFn
,
extractValue
}
from
"@/utils"
;
const
{
checkImageOutsideGrid
}
=
require
(
"../../../server/utils/setImage"
);
const
{
pathMap
}
=
require
(
"@/config/index.js"
);
...
...
@@ -539,7 +539,7 @@ export default {
// this.selectImgIndexList.push(i)
let
item
=
this
.
imgList
.
find
((
img
)
=>
img
.
fileName
===
it
.
fileName
);
if
(
item
)
return
;
this
.
curren
tImgIndex
=
index
;
this
.
selec
tImgIndex
=
index
;
// console.log(this.detail.designImageSize);
let
size
=
null
;
if
(
...
...
@@ -614,7 +614,6 @@ export default {
case
"x_center"
:
this
.
$set
(
this
.
imgList
[
this
.
selectIndex
],
"x"
,
Number
(
w
));
// this.$set(this.imgList[this.selectIndex], "y", 0);
this
.
imgHistoryList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
imgList
)));
break
;
case
"y_center"
:
...
...
@@ -785,6 +784,7 @@ export default {
if
(
size
&&
!
files
[
i
].
isCut
)
{
console
.
log
(
"size"
,
size
);
console
.
log
(
"data"
,
data
);
if
(
this
.
newDesktopDevice
==
3
)
{
const
scale
=
bh
/
data
.
height
;
width_px
=
data
.
width
*
scale
;
...
...
@@ -793,10 +793,10 @@ export default {
y
=
h
;
rate
=
height_px
/
width_px
;
}
else
{
width_px
=
mmToPx
(
size
.
width
);
height_px
=
mmToPx
(
size
.
height
);
width_px
=
mmToPx
Fn
(
size
.
width
);
height_px
=
mmToPx
Fn
(
size
.
height
);
x
=
w
;
y
=
h
;
y
=
h
eight_px
/
2
;
rate
=
height_px
/
width_px
;
}
}
else
{
...
...
@@ -806,13 +806,11 @@ export default {
if
(
rate
>
1
)
{
height_px
=
bh
*
(
7.5
/
10
);
// width_px = height_px / rate > bw ? bw : height_px / rate;
width_px
=
height_px
/
rate
;
x
=
w
;
y
=
height_px
/
2
;
}
else
{
width_px
=
bw
*
(
2
/
3
);
// height_px = width_px * rate > bh ? bh : width_px * rate;
height_px
=
width_px
*
rate
;
x
=
width_px
/
2
;
y
=
height_px
/
2
;
...
...
@@ -837,18 +835,15 @@ export default {
that
.
selectIndex
=
that
.
imgList
.
length
-
1
;
that
.
showImgSetting
=
true
;
if
(
this
.
newDesktopDevice
!=
3
)
{
if
(
size
&&
!
files
[
i
].
isCut
)
{
console
.
log
(
7898
,
this
.
detail
);
this
.
detail
.
isCustom
?
that
.
ev
(
"center"
)
:
that
.
ev
(
"cover"
);
}
else
{
that
.
ev
(
"x_center"
);
}
that
.
ev
(
"x_center"
);
// if (size && !files[i].isCut) {
// console.log(7898, this.detail);
// this.detail.isCustom ? that.ev("center") : that.ev("cover");
// } else {
// that.ev("x_center");
// }
}
// setTimeout(() => {
// that.ev("center");
// }, 1000);
if
(
i
===
files
.
length
-
1
)
{
callback
&&
callback
();
}
...
...
@@ -1790,14 +1785,14 @@ export default {
></div>
</div>
</vue-drag-resize-rotate>
<div
style=
"position: relative;"
>
<
!-- <
div style="position: relative;">
<button @click="checkOutsidePixel" class="detect-btn">
检测超出区域是否有像素
</button>
<div class="result" v-if="detectResult !== null">
检测结果:{{ detectResult ? "有" : "无" }}
</div>
</div>
</div>
-->
<!-- 隐藏的Canvas(用于像素检测) -->
<canvas
ref=
"pixelCanvas"
style=
"display: none"
></canvas>
...
...
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