mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-06 21:34:08 +08:00
fix: 修复会员用户由于数据同步导致的问题 根据设备ID确定数据库路径
This commit is contained in:
parent
d03657a1fe
commit
8e1f573996
@ -9,7 +9,7 @@ const {
|
||||
clipboard,
|
||||
time
|
||||
} = window.exports
|
||||
import { copy, paste, createFile } from '../utils'
|
||||
import { copy, paste, createFile, getNativeId } from '../utils'
|
||||
import setting from './readSetting'
|
||||
|
||||
export default function initPlugin() {
|
||||
@ -161,7 +161,10 @@ export default function initPlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
const db = new DB(setting.database.path)
|
||||
// 根据当前设备id读取不同路径 若为旧版本则迁移数据
|
||||
const nativeId = getNativeId()
|
||||
console.log(setting.database.path[nativeId])
|
||||
const db = new DB(setting.database.path[nativeId] || setting.database.path)
|
||||
db.init()
|
||||
|
||||
const remove = (item) => db.removeItemViaId(item.id)
|
||||
@ -228,7 +231,7 @@ export default function initPlugin() {
|
||||
if (!utools.isMacOs()) {
|
||||
// 首次启动插件 即开启监听
|
||||
registerClipEvent(listener)
|
||||
listener.startListening(setting.database.path)
|
||||
listener.startListening(setting.database.path[nativeId])
|
||||
} else {
|
||||
// macos 由于无法执行 clipboard-event-handler-mac 所以使用旧方法
|
||||
addCommonListener()
|
||||
@ -238,7 +241,7 @@ export default function initPlugin() {
|
||||
if (!listener.listening && !utools.isMacOs()) {
|
||||
// 进入插件后 如果监听已关闭 则重新开启监听
|
||||
registerClipEvent(listener)
|
||||
listener.startListening(setting.database.path)
|
||||
listener.startListening(setting.database.path[nativeId])
|
||||
}
|
||||
toTop()
|
||||
resetNav()
|
||||
|
@ -1,5 +1,16 @@
|
||||
import restoreSetting 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
|
||||
}
|
||||
// 将设置更新到数据库
|
||||
utools.dbStorage.setItem('setting', setting)
|
||||
}
|
||||
|
||||
export default setting
|
||||
|
@ -1,14 +1,17 @@
|
||||
import defaultSetting from '../data/setting.json'
|
||||
import { pointToObj } from '../utils'
|
||||
import { pointToObj, getNativeId } from '../utils'
|
||||
const { utools } = window.exports
|
||||
|
||||
const defaultPath = `${utools.isMacOs() ? utools.getPath('userData') : utools.getPath('home')}${
|
||||
window.exports.sep
|
||||
}_utools_clipboard_manager_storage`
|
||||
|
||||
const nativeId = getNativeId()
|
||||
|
||||
export default function restoreSetting() {
|
||||
// 将defaultSetting的key点语法转换为对象
|
||||
const setting = pointToObj(defaultSetting)
|
||||
setting.database.path = defaultPath
|
||||
setting.database.path[nativeId] = defaultPath // 根据不同设备设置不同的默认路径
|
||||
utools.dbStorage.setItem('setting', setting)
|
||||
return setting
|
||||
}
|
||||
|
@ -83,4 +83,8 @@ const createFile = (item) => {
|
||||
}
|
||||
}
|
||||
|
||||
export { dateFormat, pointToObj, copy, paste, createFile }
|
||||
const getNativeId = () => {
|
||||
return utools.getNativeId()
|
||||
}
|
||||
|
||||
export { dateFormat, pointToObj, copy, paste, createFile, getNativeId }
|
||||
|
@ -80,11 +80,13 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import setting from '../global/readSetting'
|
||||
import restoreSetting from '../global/restoreSetting'
|
||||
import defaultOperation from '../data/operation.json'
|
||||
import { getNativeId } from '../utils'
|
||||
|
||||
const emit = defineEmits(['back'])
|
||||
const { database, operation } = setting
|
||||
const nativeId = getNativeId()
|
||||
|
||||
const path = ref(database.path)
|
||||
const path = ref(database.path[nativeId])
|
||||
const maxsize = ref(database.maxsize)
|
||||
const maxage = ref(database.maxage)
|
||||
|
||||
@ -136,7 +138,10 @@ const handleSaveBtnClick = () => {
|
||||
JSON.parse(
|
||||
JSON.stringify({
|
||||
database: {
|
||||
path: path.value,
|
||||
path: {
|
||||
...database.path,
|
||||
[nativeId]: path.value
|
||||
},
|
||||
maxsize: maxsize.value,
|
||||
maxage: maxage.value
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user