Files
admin-govern/src/stores/timeCache.ts

33 lines
711 B
TypeScript
Raw Normal View History

2025-11-06 14:24:15 +08:00
// 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)
}
}
})