fix: 修复清空本地数据时内存数据未及时清空的问题

This commit is contained in:
ZiuChen 2022-10-10 19:07:23 +08:00
parent 85291cd2cf
commit 1e408a5770
2 changed files with 10 additions and 11 deletions

View File

@ -22,6 +22,11 @@ export default function initPlugin() {
this.dataBase = {}
this.createTime = d.getTime()
this.updateTime = d.getTime()
this.defaultDB = {
data: [],
createTime: this.createTime,
updateTime: this.updateTime
}
}
init() {
const isExist = existsSync(this.path)
@ -46,13 +51,8 @@ export default function initPlugin() {
}
return
}
const defaultDB = {
data: [],
createTime: this.createTime,
updateTime: this.updateTime
}
this.dataBase = defaultDB
this.updateDataBaseLocal(defaultDB)
this.dataBase = this.defaultDB
this.updateDataBaseLocal(this.defaultDB)
}
watchDataBaseUpdate() {
watch(this.path, (eventType, filename) => {
@ -101,9 +101,8 @@ export default function initPlugin() {
this.updateDataBaseLocal()
}
emptyDataBase() {
this.dataBase.data = []
this.updateDataBase()
this.updateDataBaseLocal()
window.db.dataBase.data = []
this.updateDataBaseLocal(this.defaultDB)
}
filterDataBaseViaId(id) {
return this.dataBase.data.filter((item) => item.id === id)

View File

@ -169,7 +169,7 @@ const updateShowList = (type, toTop = true) => {
const restoreDataBase = () => {
//
ElMessageBox.confirm('确定要清空剪贴板记录吗', '提示', {
ElMessageBox.confirm('即将清空剪贴板记录(包括收藏内容)', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'