33 lines
711 B
TypeScript
33 lines
711 B
TypeScript
|
|
// 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)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|