fix: 修正读取数据库路径时代码执行细节

This commit is contained in:
ZiuChen 2022-10-30 10:48:42 +08:00
parent a2c3a578e1
commit 3ef8a933da
3 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"database.path": "",
"database.path": {},
"database.maxsize": 800,
"database.maxage": 14,
"operation.shown": ["copy", "view", "collect", "un-collect", "remove"],

View File

@ -1,4 +1,5 @@
import restoreSetting from './restoreSetting'
import { defaultPath } from './restoreSetting'
import { getNativeId } from '../utils'
const setting = utools.dbStorage.getItem('setting') || restoreSetting()
@ -9,8 +10,14 @@ if (typeof setting.database.path === 'string') {
setting.database.path = {
[nativeId]: setting.database.path
}
// 将设置更新到数据库
utools.dbStorage.setItem('setting', setting)
} else {
// 新版本的setting中path是对象但是没有当前平台的路径
if (!setting.database.path[nativeId]) {
setting.database.path[nativeId] = defaultPath
}
}
// 将设置更新到数据库
utools.dbStorage.setItem('setting', setting)
export default setting

View File

@ -15,3 +15,5 @@ export default function restoreSetting() {
utools.dbStorage.setItem('setting', setting)
return setting
}
export { defaultPath }