From 5ed81132fb1ad7e490fcc3662fecab15a7c900bc Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 13 Mar 2021 14:35:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/store.js | 20 +++++++++++++------- src/main/rendererEvents/playList.js | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/common/store.js b/src/common/store.js index e9bd17ac..3b3f5060 100644 --- a/src/common/store.js +++ b/src/common/store.js @@ -12,24 +12,30 @@ const stores = {} * @param {*} isIgnoredError 是否忽略错误 * @returns Store */ -module.exports = (name, isIgnoredError = true) => { +module.exports = (name, isIgnoredError = true, isShowErrorAlert = true) => { if (stores[name]) return stores[name] let store try { store = stores[name] = new Store({ name, clearInvalidConfig: false }) } catch (error) { log.error(error) + if (!isIgnoredError) throw error + const backPath = path.join(app.getPath('userData'), name + '.json.bak') fs.copyFileSync(path.join(app.getPath('userData'), name + '.json'), backPath) - dialog.showMessageBoxSync({ - type: 'error', - message: name + ' data load error', - detail: `We have helped you back up the old ${name} file to: ${backPath}\nYou can try to repair and restore it manually\n\nError detail: ${error.message}`, - }) - store = new Store({ name, clearInvalidConfig: true }) shell.showItemInFolder(backPath) + if (isShowErrorAlert) { + dialog.showMessageBoxSync({ + type: 'error', + message: name + ' data load error', + detail: `We have helped you back up the old ${name} file to: ${backPath}\nYou can try to repair and restore it manually\n\nError detail: ${error.message}`, + }) + } + + + store = new Store({ name, clearInvalidConfig: true }) } return store } diff --git a/src/main/rendererEvents/playList.js b/src/main/rendererEvents/playList.js index 655c360f..3eb0aed3 100644 --- a/src/main/rendererEvents/playList.js +++ b/src/main/rendererEvents/playList.js @@ -3,7 +3,7 @@ const getStore = require('@common/store') mainHandle(ipcMainWindowNames.get_playlist, async(event, isIgnoredError = false) => { - const electronStore_list = getStore('playList', isIgnoredError) + const electronStore_list = getStore('playList', isIgnoredError, false) return { defaultList: electronStore_list.get('defaultList'),