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