chore: cache resources active tab

This commit is contained in:
jialin
2025-03-26 17:31:31 +08:00
parent bfdf02f065
commit 997e4a1edd
5 changed files with 48 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
import { getDefaultStore } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
export const tabActiveAtom = atomWithStorage<Map<string, any>>(
'tabActiveStatus',
new Map()
);
export const setActiveStatus = (key: string, value: any) => {
const store = getDefaultStore();
const cache = store.get(tabActiveAtom);
cache.set(key, value);
store.set(tabActiveAtom, cache);
};
export const getActiveStatus = (key: string) => {
const store = getDefaultStore();
const cache = store.get(tabActiveAtom);
return cache.get(key);
};