🔨 Refactor: use picgo-core's picbed list without using builtin picbed list

This commit is contained in:
PiEgg
2022-08-21 10:54:30 +08:00
parent 428ffc7ef1
commit d50ad3a592
28 changed files with 127 additions and 1097 deletions
+6 -3
View File
@@ -37,9 +37,12 @@ class ConfigStore {
this.read()
}
read (flush = false) {
// if flush -> true, read origin file again
this.db.read(flush)
flush () {
this.db = new JSONStore(CONFIG_PATH)
}
read () {
this.db.read()
return this.db
}
+8 -3
View File
@@ -2,6 +2,7 @@ import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
import pkg from 'root/package.json'
import { PicGo } from 'picgo'
import db from 'apis/core/datastore'
import debounce from 'lodash/debounce'
const CONFIG_PATH = dbPathChecker()
@@ -18,12 +19,16 @@ picgo.GUI_VERSION = global.PICGO_GUI_VERSION
const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
function flushDB () {
db.flush()
}
const debounced = debounce(flushDB, 1000)
picgo.saveConfig = (config: IStringKeyMap) => {
originPicGoSaveConfig(config)
// flush electron's db
setTimeout(() => {
db.read(true)
}, 0)
debounced()
}
export default picgo