优化交易分类选择时的自动保存功能;重命名清除缓存为刷新网络并更新相关逻辑
This commit is contained in:
@@ -255,6 +255,12 @@ const onSubmit = async () => {
|
|||||||
// 选择分类
|
// 选择分类
|
||||||
const selectClassify = (classify) => {
|
const selectClassify = (classify) => {
|
||||||
editForm.classify = classify
|
editForm.classify = classify
|
||||||
|
|
||||||
|
if(editForm.id > 0 && editForm.type > 0) {
|
||||||
|
// 直接保存
|
||||||
|
onSubmit()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增分类
|
// 新增分类
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<van-cell-group inset>
|
<van-cell-group inset>
|
||||||
<van-cell title="查看日志" is-link @click="handleLogView" />
|
<van-cell title="查看日志" is-link @click="handleLogView" />
|
||||||
<van-cell title="清除缓存" is-link @click="handleClearCache" />
|
<van-cell title="清除缓存" is-link @click="handleReloadFromNetwork" />
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
|
|
||||||
<div class="detail-header" style="padding-bottom: 5px;">
|
<div class="detail-header" style="padding-bottom: 5px;">
|
||||||
@@ -63,6 +63,7 @@ import { showLoadingToast, showSuccessToast, showToast, closeToast, showConfirmD
|
|||||||
import { uploadBillFile } from '@/api/billImport'
|
import { uploadBillFile } from '@/api/billImport'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/stores/auth'
|
||||||
import { getVapidPublicKey, subscribe, testNotification } from '@/api/notification'
|
import { getVapidPublicKey, subscribe, testNotification } from '@/api/notification'
|
||||||
|
import { updateServiceWorker } from '@/registerServiceWorker'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
@@ -265,25 +266,28 @@ const handleLogView = () => {
|
|||||||
router.push({ name: 'log' })
|
router.push({ name: 'log' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClearCache = async () => {
|
const handleReloadFromNetwork = async () => {
|
||||||
try {
|
try {
|
||||||
await showConfirmDialog({
|
await showConfirmDialog({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
message: '确定要清除缓存吗?此操作不可撤销。',
|
message: '确定要刷新网络吗?此操作不可撤销。',
|
||||||
})
|
})
|
||||||
|
|
||||||
// PWA程序强制页面更新到最新版本
|
// PWA程序强制页面更新到最新版本
|
||||||
if ('serviceWorker' in navigator && navigator.serviceWorker.controller) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.controller.postMessage({ type: 'SKIP_WAITING' });
|
updateServiceWorker()
|
||||||
|
showSuccessToast('正在更新,请稍候...')
|
||||||
|
// 延迟刷新页面以加载新版本
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload()
|
||||||
|
}, 1500)
|
||||||
} else {
|
} else {
|
||||||
showToast('当前未使用缓存,无需清除')
|
showToast('当前环境不支持此操作')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
showSuccessToast('缓存已清除')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('取消清除缓存:', error)
|
console.error('取消刷新网络:', error)
|
||||||
showToast('已取消清除缓存')
|
showToast('已取消刷新网络')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user