| | |
| | | import { PATH_ICON } from '../../../common'; |
| | | import { ChartTypeEnum } from '../../../types'; |
| | | import { axisLabelFormatter } from '/@/utils/chart'; |
| | | import { Local } from '/@/utils/storage'; |
| | | import { LocalPlus } from '/@/utils/storage'; |
| | | |
| | | const props = defineProps({ |
| | | data: { |
| | |
| | | const storeCols = (colList: any[]) => { |
| | | const key = colList.map((item) => item.label).join(','); |
| | | if (!key) return; |
| | | Local.set(key, colList); |
| | | LocalPlus.set(key, colList, 7); |
| | | }; |
| | | const colList = ref([]); |
| | | const getStoreCols = (colList: any[]) => { |
| | | if (colList.length === 0) return colList; |
| | | const key = colList.map((item) => item.label).join(','); |
| | | if (!key) return colList; |
| | | const storeValue = Local.get(key); |
| | | const storeValue = LocalPlus.get(key); |
| | | |
| | | if (!storeValue) { |
| | | return colList; |
| | |
| | | }, |
| | | }; |
| | | |
| | | //#region ====================== 缓存带时间 ====================== |
| | | type CacheValue<T> = { |
| | | // 过期时间,时间戳 |
| | | expiredTime: number; |
| | | value: T; |
| | | }; |
| | | export const LocalPlus = { |
| | | // 设置 |
| | | set<T>(key: string, val: T, expireDay: number) { |
| | | const expireMs = expireDay * 24 * 60 * 60 * 1000; |
| | | const cacheValue: CacheValue<T> = { |
| | | expiredTime: new Date().getTime() + expireMs, |
| | | value: val, |
| | | }; |
| | | Local.set(key, cacheValue); |
| | | }, |
| | | // 获取,过期则清除 |
| | | get(key: string) { |
| | | const cacheValue: CacheValue<any> = Local.get(key); |
| | | if (new Date().getTime() > cacheValue.expiredTime) { |
| | | Local.remove(key); |
| | | return null; |
| | | } |
| | | return cacheValue.value; |
| | | }, |
| | | }; |
| | | |
| | | |
| | | //#endregion |
| | | |
| | | /** |
| | | * window.sessionStorage 浏览器临时缓存 |
| | | * @method set 设置临时缓存 |