fix: 调整智慧分词的本地缓存逻辑

This commit is contained in:
ZiuChen 2022-09-09 10:57:35 +08:00
parent b25abcddbf
commit cea005a9a1
2 changed files with 6 additions and 7 deletions

View File

@ -262,6 +262,5 @@ window.openFileFolder = utools.shellShowItemInFolder
window.getIcon = utools.getFileIcon
window.showNotify = utools.showNotification
window.fetchToken = utools.fetchUserServerTemporaryToken
window.dbStorage = utools.dbStorage
window.focus = focus
window.toTop = toTop

View File

@ -88,7 +88,7 @@ const handleBtnClick = (id) => {
case 'word-split':
// TODO: ()
const key = 'word-break-daily-used'
const val = window.dbStorage.getItem(key)
const val = utools.dbStorage.getItem(key)
if (val >= '\u0035') {
window.showNotify(
'今日使用次数已达5次, 请明日再使用此功能 新插件`超级分词`即将上线, 敬请期待'
@ -149,13 +149,13 @@ const fetchWordBreakResult = async (origin) => {
//
const valueKey = 'word-break-daily-used'
const timeKey = 'last-update'
const val = window.dbStorage.getItem(valueKey)
window.dbStorage.setItem(valueKey, val === null ? 1 : val + 1)
if (new Date(window.dbStorage.getItem(timeKey)).getDay() !== new Date().getDay()) {
const val = utools.dbStorage.getItem(valueKey)
utools.dbStorage.setItem(valueKey, val === null ? 1 : val + 1)
if (new Date(utools.dbStorage.getItem(timeKey)).getDay() !== new Date().getDay()) {
//
window.dbStorage.setItem(valueKey, 0)
utools.dbStorage.setItem(valueKey, 0)
}
window.dbStorage.setItem(timeKey, new Date().valueOf())
utools.dbStorage.setItem(timeKey, new Date().valueOf())
splitWords.value = data.splitWord
.filter((w) => w !== '' && w !== ' ' && w.indexOf('\n') === -1)
.map((item) => ({