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
6c8146f3
Commit
6c8146f3
authored
Feb 03, 2026
by
linjinhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修改文件上传配置
parent
9d42e007
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
45 deletions
+175
-45
config/env.json
+2
-2
src/server/entity/function.js
+6
-2
src/server/utils/store.js
+153
-41
src/views/design/head/index.vue
+14
-0
No files found.
config/env.json
View file @
6c8146f3
{
"apiApiHost"
:
"https://factory.jomalls.com/api"
,
"fileApiUrl"
:
"https://factory.jomalls.com/upload/factory"
,
"visionUrl"
:
"https://console.jomalls.com"
,
"configPath"
:
"D:
\\
work
\\
electron-printer
\\
config
\\
env.json"
}
\ No newline at end of file
{
"apiApiHost"
:
"https://11factory.jomalls.com/api"
,
"fileApiUrl"
:
"https://11factory.jomalls.com/upload/factory"
,
"visionUrl"
:
"https://console.jomalls.com"
,
"configPath"
:
"D:
\\
work
\\
electron-printer
\\
config
\\
env.json"
}
\ No newline at end of file
src/server/entity/function.js
View file @
6c8146f3
...
...
@@ -132,6 +132,7 @@ export default {
downloadBySubOrderNumber
:
async
(
req
,
res
)
=>
{
env
=
getHostApi
().
apiApiHost
;
fileEnv
=
getHostApi
().
fileApiUrl
;
const
params
=
req
.
body
;
const
token
=
req
.
headers
[
"jwt-token"
];
...
...
@@ -139,11 +140,14 @@ export default {
CN
:
"factory/podJomallOrderProductCn/downloadDesignImages"
,
US
:
"factory/podJomallOrderProductUs/downloadDesignImages"
,
GC
:
"factory/podJomallOrder/downloadByProduction"
,
HLC
:
"factory/podJomallOrderProductUs/downloadCompatibleDesignImages"
,
};
try
{
const
url
=
urlMap
[
params
.
orderType
];
let
url
=
urlMap
[
params
.
orderType
];
if
(
params
.
device
==
3
)
{
url
=
urlMap
[
"HLC"
];
}
const
{
data
}
=
await
axios
.
post
(
`
${
env
}
/
${
url
}
`
,
[...
params
.
ids
],
{
headers
:
{
"jwt-token"
:
token
},
});
...
...
src/server/utils/store.js
View file @
6c8146f3
const
Store
=
require
(
"electron-store"
);
const
store
=
new
Store
({
watch
:
true
});
// 导出 store 实例(新增:方便外部获取实例进行监听)
// =====
新增:
私有缓存 Map + 缓存刷新方法 =====
let
orderCacheMap
=
new
Map
();
// 模块内私有缓存,
避免重复转换
// ===== 私有缓存 Map + 缓存刷新方法 =====
let
orderCacheMap
=
new
Map
();
// 模块内私有缓存,
key是最终唯一newId(如123_1)
const
DEFAULT_UNIQUE_KEY
=
"newId"
;
// 刷新缓存:从 electron-store 读取数组,转为 Map 存入缓存
...
...
@@ -26,30 +25,98 @@ function mapToArray(dataMap) {
return
Array
.
from
(
dataMap
.
values
());
}
// ===== 新增:处理重复 newId 的核心辅助方法(更新后缀为_,适配num固定上限) =====
/**
* 提取原始 newId(去除后缀 _1、_2 等,避免解析原始newId中的-)
* @param {string|number} uniqueValue 最终存储的唯一 newId(如 123_1)
* @returns {string|number} 原始 newId(如 123)
*/
function
getOriginalNewId
(
uniqueValue
)
{
if
(
typeof
uniqueValue
!==
"string"
&&
typeof
uniqueValue
!==
"number"
)
{
return
uniqueValue
;
}
const
strValue
=
String
(
uniqueValue
);
const
suffixIndex
=
strValue
.
lastIndexOf
(
"_"
);
// 改为 _ 分割后缀
// 判断是否是 任意字符_数字 格式的后缀,避免误拆正常包含_的newId
if
(
suffixIndex
>
0
&&
/^
\d
+$/
.
test
(
strValue
.
slice
(
suffixIndex
+
1
)))
{
return
strValue
.
slice
(
0
,
suffixIndex
);
}
return
uniqueValue
;
}
/**
* 统计相同原始 newId 的订单当前已添加数量
* @param {string|number} originalNewId 原始 newId
* @returns {number} 相同原始 newId 的已添加订单数量
*/
function
countSameOriginalNewId
(
originalNewId
)
{
let
count
=
0
;
orderCacheMap
.
forEach
((
item
)
=>
{
const
itemOriginalId
=
getOriginalNewId
(
item
[
DEFAULT_UNIQUE_KEY
]);
if
(
itemOriginalId
===
originalNewId
)
{
count
++
;
}
});
return
count
;
}
/**
* 处理单个订单的重复 newId,生成唯一 newId 并校验 num 上限
* @param {object} orderObj 传入的订单对象(必须携带 num 字段作为上限)
* @returns {object|null} 处理后的订单对象(带唯一 newId),超过上限返回 null
*/
function
handleDuplicateNewId
(
orderObj
)
{
if
(
!
orderObj
||
!
orderObj
[
DEFAULT_UNIQUE_KEY
])
{
console
.
warn
(
"订单无效:缺少必要的 newId 字段"
);
return
null
;
}
// 1. 校验 num 字段(必须是有效数字且大于0)
const
numLimit
=
orderObj
.
num
;
if
(
typeof
numLimit
!==
"number"
||
numLimit
<=
0
||
isNaN
(
numLimit
))
{
console
.
warn
(
"订单无效:num 必须是大于 0 的有效数字(作为添加上限)"
);
return
null
;
}
// 2. 获取原始 newId + 统计当前已添加数量
const
originalNewId
=
orderObj
[
DEFAULT_UNIQUE_KEY
];
const
existingCount
=
countSameOriginalNewId
(
originalNewId
);
// 3. 校验:已添加数量 >= 上限,禁止添加
if
(
existingCount
>=
numLimit
)
{
console
.
warn
(
`添加失败:
${
originalNewId
}
已达到添加上限
${
numLimit
}
,无法继续添加`
,
);
return
null
;
}
// 4. 生成新的唯一 newId(原始Id_序号,序号=已存在数量+1),保留原始 num 上限(固定不修改)
const
newUniqueId
=
`
${
originalNewId
}
_
${
existingCount
+
1
}
`
;
return
{
...
orderObj
,
[
DEFAULT_UNIQUE_KEY
]:
newUniqueId
,
// num: numLimit // 直接保留传入的 num 上限,无需修改
};
}
module
.
exports
=
{
//
存储当前打印驱动版本
//
原有基础方法(保持不变,直接复用)
setVersion
:
(
version
)
=>
{
store
.
set
(
"desktoVersion"
,
version
);
},
getVersion
:
()
=>
store
.
get
(
"desktoVersion"
)
||
"print"
,
//存储当前打印驱动版本
setNowDate
:
(
version
)
=>
{
store
.
set
(
"nowDate"
,
version
);
},
getNowDate
:
()
=>
store
.
get
(
"nowDate"
)
||
""
,
//跳过更新和储存更新
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
);
},
...
...
@@ -60,47 +127,85 @@ module.exports = {
visionUrl
:
"https://console.jomalls.com"
,
configPath
:
""
,
},
//
setBoard
:
(
version
)
=>
{
store
.
set
(
"desktoBoard"
,
version
);
},
getBoard
:
()
=>
store
.
get
(
"desktoBoard"
)
||
3
,
//下载位置
setLocation
:
(
version
,
locationKey
)
=>
{
store
.
set
(
locationKey
,
version
);
},
getLocation
:
(
locationKey
)
=>
store
.
get
(
locationKey
)
||
""
,
//设备
setDesktopDevice
:
(
version
)
=>
{
store
.
set
(
"desktopDevice"
,
version
);
},
getDesktopDevice
:
()
=>
store
.
get
(
"desktopDevice"
)
||
1
,
// ===== 基于缓存 Map 优化的 orderInfo 方法 =====
getOrderInfo
:
()
=>
store
.
get
(
"orderInfo"
)
||
[],
// ===== 基于缓存 Map 优化的 orderInfo 方法(更新后) =====
getOrderInfo
:
()
=>
{
return
store
.
get
(
"orderInfo"
);
},
getOrderInfoMap
:
()
=>
{
return
orderCacheMap
;
},
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
();
// 批量处理重复 newId + 校验 num 上限
const
handledArray
=
[];
const
batchOriginalIdCount
=
new
Map
();
newObjArray
.
forEach
((
item
)
=>
{
if
(
!
item
||
!
item
[
uniqueKey
]
||
typeof
item
.
num
!==
"number"
||
item
.
num
<=
0
)
{
console
.
warn
(
"批量添加跳过无效订单:缺少 newId 或 有效 num 上限"
);
return
;
}
const
originalNewId
=
item
[
uniqueKey
];
const
numLimit
=
item
.
num
;
// 合并缓存中的计数和同批次内的计数
const
cacheCount
=
countSameOriginalNewId
(
originalNewId
);
const
batchCount
=
batchOriginalIdCount
.
get
(
originalNewId
)
||
0
;
const
currentTotalCount
=
cacheCount
+
batchCount
;
// 校验:当前总数量 >= 上限,禁止添加该订单
if
(
currentTotalCount
>=
numLimit
)
{
console
.
warn
(
`批量添加跳过:
${
originalNewId
}
已达到添加上限
${
numLimit
}
`
,
);
return
;
}
// 生成唯一 newId(_ 后缀)
const
newUniqueId
=
`
${
originalNewId
}
_
${
currentTotalCount
+
1
}
`
;
// 更新批次计数
batchOriginalIdCount
.
set
(
originalNewId
,
batchCount
+
1
);
// 存入处理后的数组(保留原始 num 上限)
handledArray
.
push
({
...
item
,
[
uniqueKey
]:
newUniqueId
,
});
});
// 写入 store 和缓存
store
.
set
(
"orderInfo"
,
handledArray
);
const
newMap
=
new
Map
();
handledArray
.
forEach
((
item
)
=>
{
if
(
item
&&
item
[
uniqueKey
])
{
newMap
.
set
(
item
[
uniqueKey
],
item
);
}
...
...
@@ -114,36 +219,39 @@ module.exports = {
newOrderObj
===
null
||
!
newOrderObj
[
uniqueKey
]
)
{
console
.
warn
(
"添加失败:请传入包含
唯一标识(默认id)
的有效对象"
);
console
.
warn
(
"添加失败:请传入包含
newId
的有效对象"
);
return
;
}
const
uniqueValue
=
newOrderObj
[
uniqueKey
];
// 直接操作缓存 Map(O(1),无需重新转换)
if
(
orderCacheMap
.
has
(
uniqueValue
))
{
console
.
log
(
`该对象(
${
uniqueKey
}
=
${
uniqueValue
}
)已存在,不重复添加`
);
return
;
}
// 核心:处理重复 newId + 校验 num 上限,生成唯一标识
const
handledOrder
=
handleDuplicateNewId
(
newOrderObj
);
if
(
!
handledOrder
)
return
;
// 超过上限或无效则直接返回
orderCacheMap
.
set
(
uniqueValue
,
newOrderObj
);
// 写入 store 时,仅转换缓存 Map(一次 O(n),而非每次操作都 O(n))
const
uniqueValue
=
handledOrder
[
uniqueKey
];
// 写入缓存 Map
orderCacheMap
.
set
(
uniqueValue
,
handledOrder
);
// 同步到 electron-store
const
newArray
=
mapToArray
(
orderCacheMap
);
store
.
set
(
"orderInfo"
,
newArray
);
},
removeFromOrderInfo
:
(
uniqueValue
,
uniqueKey
=
DEFAULT_UNIQUE_KEY
)
=>
{
// 直接操作缓存 Map(O(1))
if
(
!
orderCacheMap
.
has
(
uniqueValue
))
{
// 直接操作缓存 Map
const
targetObj
=
orderCacheMap
.
get
(
uniqueValue
);
if
(
!
targetObj
)
{
console
.
log
(
`未找到
${
uniqueKey
}
=
${
uniqueValue
}
的对象,删除失败`
);
return
;
}
// 删除缓存中的对象(无需更新 num,因为 num 是固定上限)
orderCacheMap
.
delete
(
uniqueValue
);
const
newArray
=
mapToArray
(
orderCacheMap
);
store
.
set
(
"orderInfo"
,
newArray
);
console
.
log
(
`成功删除
${
uniqueValue
}
,num 作为固定上限无需更新`
);
},
// 其他方法(updateOrderInfoItem、getOrderInfoItem)同理,均直接操作 orderCacheMap
updateOrderInfoItem
:
(
uniqueValue
,
newOrderObj
,
...
...
@@ -154,21 +262,25 @@ module.exports = {
return
;
}
// 直接操作缓存 Map(O(1) 查找)
const
targetObj
=
orderCacheMap
.
get
(
uniqueValue
);
if
(
!
targetObj
)
{
console
.
log
(
`未找到
${
uniqueKey
}
=
${
uniqueValue
}
的对象,修改失败`
);
return
;
}
const
updatedObj
=
{
...
targetObj
,
...
newOrderObj
};
// 保留唯一 newId 和 原始 num 上限(禁止修改这两个字段,避免冲突)
const
updatedObj
=
{
...
targetObj
,
...
newOrderObj
,
[
uniqueKey
]:
targetObj
[
uniqueKey
],
// 锁定唯一 newId(_ 后缀格式)
num
:
targetObj
.
num
,
// 锁定 num 固定上限,不允许修改
};
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 @
6c8146f3
...
...
@@ -104,6 +104,7 @@ export default {
"hsla(209, 100%, 56%, 0.73)"
,
"#c7158577"
,
],
faceType
:
"1"
,
};
},
computed
:
{
...
...
@@ -1070,6 +1071,16 @@ export default {
</el-tooltip>
</el-popover>
</div>
<div
v-else
>
<div
class=
"selectInput"
>
<div>
当前打印:
</div>
<el-select
v-model=
"faceType"
placeholder=
"请选择"
class=
"FaceType"
>
<el-option
label=
"A面 / 正面"
value=
"1"
></el-option>
<el-option
label=
"B面 / 反面"
value=
"2"
></el-option>
</el-select>
</div>
</div>
</div>
<div
class=
"center-input"
>
<!--
<el-button
...
...
@@ -1271,6 +1282,9 @@ export default {
.
el
-
select
.
el
-
input
{
max
-
width
:
90
px
;
}
.
FaceType
.
el
-
input
{
max
-
width
:
120
px
;
}
}
}
::
v
-
deep
{
...
...
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