2025-11-06 14:24:15 +08:00
|
|
|
// src/stores/timeCache.ts
|
|
|
|
|
import { defineStore } from 'pinia'
|
|
|
|
|
import { RouteLocationNormalizedLoaded } from 'vue-router'
|
|
|
|
|
|
2025-11-06 14:55:56 +08:00
|
|
|
// 时间组件的缓存值 用于驾驶舱放大的时候和内部的时间组件同步
|
2025-11-06 14:24:15 +08:00
|
|
|
interface TimeCacheState {
|
|
|
|
|
cache: Map<string, {
|
2025-11-06 14:55:56 +08:00
|
|
|
interval: number | undefined // 时间组件的月份、年份、时间、时间格式的缓存值
|
|
|
|
|
timeValue: any // 时间组件的值
|
2025-11-06 14:24:15 +08:00
|
|
|
}>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|