Skip to content

Commit f6c5f0d

Browse files
committed
更新[BoxJs]: 修复部分情况下导入空数据产生的问题 (如: 京东没有账号2, 导入后提示账号 2 签到失败问题)
1 parent bb7549a commit f6c5f0d

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎box/release/box.release.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.3.7",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"icon": "https://avatars3.githubusercontent.com/u/29748519",
8+
"repo": "https://github.com/chavyleung",
9+
"notes": [
10+
{
11+
"name": "修复",
12+
"descs": ["部分情况下导入空数据产生的问题 (如: 京东没有账号2, 导入后提示账号 2 签到失败问题)"]
13+
}
14+
]
15+
},
316
{
417
"version": "0.3.6",
518
"tags": ["beta"],

‎chavy.box.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ async function handleApi() {
449449
session.datas.forEach((data) => {
450450
const oldval = $.getdata(data.key)
451451
const newval = data.val
452-
const usesuc = $.setdata(`${newval}`, data.key)
452+
const isNull = (val) => [undefined, null, 'null', 'undefined', ''].includes(val)
453+
const usesuc = $.setdata(isNull(newval) ? '' : `${newval}`, data.key)
453454
$.log(`❕ ${$.name}, 替换数据: ${data.key} ${usesuc ? '成功' : '失败'}!`, `旧值: ${oldval}`, `新值: ${newval}`)
454455
})
455456
curSessions[session.appId] = session.id
@@ -522,7 +523,8 @@ async function handleApi() {
522523
const { chavy_boxjs_sessions, chavy_boxjs_sysCfgs, chavy_boxjs_userCfgs, chavy_boxjs_sysApps, ...datas } = bakobj.bak
523524
$.setdata(JSON.stringify(chavy_boxjs_sessions), $.KEY_sessions)
524525
$.setdata(JSON.stringify(chavy_boxjs_userCfgs), $.KEY_userCfgs)
525-
Object.keys(datas).forEach((datkey) => $.setdata(datas[datkey] ? datas[datkey] : '', datkey))
526+
const isNull = (val) => [undefined, null, 'null', 'undefined', ''].includes(val)
527+
Object.keys(datas).forEach((datkey) => $.setdata(isNull(datas[datkey]) ? '' : `${datas[datkey]}`, datkey))
526528
$.subt = '还原备份: 成功'
527529
$.msg($.name, $.subt, $.desc)
528530
} else {

0 commit comments

Comments
 (0)