parent
bfdf02f065
commit
997e4a1edd
@ -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);
|
||||
};
|
||||
@ -0,0 +1,19 @@
|
||||
import { getActiveStatus, setActiveStatus } from '@/atoms/tab-active';
|
||||
|
||||
const tabsMap = {
|
||||
resources: 'resources'
|
||||
};
|
||||
|
||||
export default function useTabActive() {
|
||||
const setTabActive = (key: string, value: any) => {
|
||||
setActiveStatus(key, value);
|
||||
};
|
||||
const getTabActive = (key: string) => {
|
||||
return getActiveStatus(key);
|
||||
};
|
||||
return {
|
||||
setTabActive,
|
||||
getTabActive,
|
||||
tabsMap
|
||||
};
|
||||
}
|
||||
Loading…
Reference in new issue