内部时间组件设置默认值
This commit is contained in:
33
src/stores/timeCache.ts
Normal file
33
src/stores/timeCache.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user