mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-09-27 13:53:21 +08:00
fix: 修复多端同步内存数据更新失效的问题
This commit is contained in:
@@ -4,6 +4,7 @@ const {
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
mkdirSync,
|
||||
watch,
|
||||
crypto,
|
||||
listener,
|
||||
clipboard,
|
||||
@@ -53,6 +54,23 @@ export default function initPlugin() {
|
||||
this.dataBase = defaultDB
|
||||
this.updateDataBaseLocal(defaultDB)
|
||||
}
|
||||
watchDataBaseUpdate() {
|
||||
watch(this.path, (eventType, filename) => {
|
||||
if (eventType === 'change') {
|
||||
// 更新内存中的数据
|
||||
const data = readFileSync(this.path, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
try {
|
||||
const dataBase = JSON.parse(data)
|
||||
this.dataBase = dataBase
|
||||
} catch (err) {
|
||||
utools.showNotification('读取剪切板出错: ' + err)
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
updateDataBase() {
|
||||
// 更新内存数据
|
||||
this.dataBase.updateTime = new Date().getTime()
|
||||
|
Reference in New Issue
Block a user