ClipboardManager/src/global/readSetting.js

24 lines
734 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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