PicList/src/main/migrate/index.ts

27 lines
614 B
TypeScript
Raw Normal View History

2019-12-19 06:17:21 -05:00
import DB from '#/datastore'
2019-09-10 02:38:08 -04:00
// from v2.1.2
const updateShortKeyFromVersion212 = (db: typeof DB, shortKeyConfig: IShortKeyConfigs | IOldShortKeyConfigs) => {
2019-09-10 02:38:08 -04:00
let needUpgrade = false
if (shortKeyConfig.upload) {
needUpgrade = true
2019-12-19 06:17:21 -05:00
// @ts-ignore
shortKeyConfig['picgo:upload'] = {
enable: true,
key: shortKeyConfig.upload,
name: 'upload',
label: '快捷上传'
2019-09-10 02:38:08 -04:00
}
delete shortKeyConfig.upload
}
2019-09-10 02:38:08 -04:00
if (needUpgrade) {
2019-09-11 07:30:08 -04:00
db.set('settings.shortKey', shortKeyConfig)
2019-09-10 02:38:08 -04:00
return shortKeyConfig
} else {
return false
}
}
export {
updateShortKeyFromVersion212
}