Skip to content

Commit eb67d67

Browse files
committed
修复v1.14.0出现的备份与恢复功能备份的数据无法恢复的问题
1 parent e12f95f commit eb67d67

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

publish/changeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
### 修复
22

33
- 修复我的列表搜索无法搜索小括号、中括号等字符的问题
4+
- 修复v1.14.0出现的备份与恢复功能备份的数据无法恢复的问题,同时兼容使用v1.14.0导出的存在问题的数据

src/renderer/utils/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,18 @@ export const readLxConfigFile = async path => {
464464
let data = await fs.promises.readFile(path, isJSON ? 'utf8' : 'binary')
465465
if (!data || isJSON) return data
466466
data = await gunzipData(Buffer.from(data, 'binary'))
467-
return data.toString('utf8')
467+
data = JSON.parse(data.toString('utf8'))
468+
469+
// 修复v1.14.0出现的导出数据被序列化两次的问题
470+
if (typeof data != 'object') {
471+
try {
472+
data = JSON.parse(data)
473+
} catch (err) {
474+
return data
475+
}
476+
}
477+
478+
return data
468479
}
469480

470481

src/renderer/views/List.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ export default {
10501050
if (result.canceled) return
10511051
let listData
10521052
try {
1053-
listData = JSON.parse(await readLxConfigFile(result.filePaths[0]))
1053+
listData = await readLxConfigFile(result.filePaths[0])
10541054
} catch (error) {
10551055
return
10561056
}

src/renderer/views/Setting.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ export default {
815815
async importSetting(path) {
816816
let settingData
817817
try {
818-
settingData = JSON.parse(await readLxConfigFile(path))
818+
settingData = await readLxConfigFile(path)
819819
} catch (error) {
820820
return
821821
}
@@ -830,12 +830,12 @@ export default {
830830
type: 'setting',
831831
data: Object.assign({ version: this.settingVersion }, this.setting),
832832
}
833-
saveLxConfigFile(path, JSON.stringify(data))
833+
saveLxConfigFile(path, data)
834834
},
835835
async importPlayList(path) {
836836
let listData
837837
try {
838-
listData = JSON.parse(await readLxConfigFile(path))
838+
listData = await readLxConfigFile(path)
839839
} catch (error) {
840840
return
841841
}
@@ -867,12 +867,12 @@ export default {
867867
if (item.otherSource) delete item.otherSource
868868
}
869869
}
870-
saveLxConfigFile(path, JSON.stringify(data))
870+
saveLxConfigFile(path, data)
871871
},
872872
async importAllData(path) {
873873
let allData
874874
try {
875-
allData = JSON.parse(await readLxConfigFile(path))
875+
allData = await readLxConfigFile(path)
876876
} catch (error) {
877877
return
878878
}
@@ -906,7 +906,7 @@ export default {
906906
if (item.otherSource) delete item.otherSource
907907
}
908908
}
909-
saveLxConfigFile(path, JSON.stringify(allData))
909+
saveLxConfigFile(path, allData)
910910
},
911911
handleImportAllData() {
912912
selectDir({

0 commit comments

Comments
 (0)