mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-06 16:07:06 +08:00
🔨 Refactor: use picgo-core's picbed list without using builtin picbed list
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user