内部时间组件设置默认值

This commit is contained in:
stt
2025-11-06 14:24:15 +08:00
parent b5aff1a837
commit 593f2e2c66
4 changed files with 205 additions and 19 deletions

33
src/stores/timeCache.ts Normal file
View File

@@ -0,0 +1,33 @@
// src/stores/timeCache.ts
import { defineStore } from 'pinia'
import { RouteLocationNormalizedLoaded } from 'vue-router'
interface TimeCacheState {
cache: Map<string, {
interval: number | undefined
timeValue: any
}>
}
export const useTimeCacheStore = defineStore('timeCache', {
state: (): TimeCacheState => ({
cache: new Map()
}),
actions: {
setCache(routePath: string, interval: number | undefined, timeValue: any) {
this.cache.set(routePath, {
interval,
timeValue
})
},
getCache(routePath: string) {
return this.cache.get(routePath)
},
hasCache(routePath: string) {
return this.cache.has(routePath)
}
}
})