|
@ -1,7 +1,7 @@ |
|
|
import { atomWithQuery } from 'jotai-tanstack-query' |
|
|
import { atomWithQuery } from 'jotai-tanstack-query' |
|
|
import systemServ from '../service/system.ts' |
|
|
import systemServ from '../service/system.ts' |
|
|
import { MenuItem } from '../types' |
|
|
|
|
|
import { getIcon } from '../components/icon' |
|
|
|
|
|
|
|
|
import { MenuItem } from '@/types' |
|
|
|
|
|
import { getIcon } from '@/components/icon' |
|
|
import { atom } from 'jotai/index' |
|
|
import { atom } from 'jotai/index' |
|
|
|
|
|
|
|
|
// 格式化菜单数据, 把children转换成routes
|
|
|
// 格式化菜单数据, 把children转换成routes
|
|
@ -34,13 +34,13 @@ export const menuDataAtom = atomWithQuery(() => ({ |
|
|
select: data => formatMenuData(data.data ?? []), |
|
|
select: data => formatMenuData(data.data ?? []), |
|
|
})) |
|
|
})) |
|
|
|
|
|
|
|
|
export const selectedMenuIdAtom = atom<string | number>(0) |
|
|
|
|
|
export const selectedMenuAtom = atom<MenuItem>({}) |
|
|
|
|
|
|
|
|
export const selectedMenuIdAtom = atom<number>(0) |
|
|
|
|
|
export const selectedMenuAtom = atom<MenuItem | unknown>(undefined) |
|
|
export const byIdMenuAtom = atomWithQuery((get) => ({ |
|
|
export const byIdMenuAtom = atomWithQuery((get) => ({ |
|
|
queryKey: [ 'selectedMenu', get(selectedMenuIdAtom) ], |
|
|
queryKey: [ 'selectedMenu', get(selectedMenuIdAtom) ], |
|
|
queryFn: async ({ queryKey: [ , id ] }) => { |
|
|
queryFn: async ({ queryKey: [ , id ] }) => { |
|
|
|
|
|
|
|
|
return await systemServ.menus.info(id) |
|
|
|
|
|
|
|
|
return await systemServ.menus.info(id as number) |
|
|
}, |
|
|
}, |
|
|
select: data => data.data, |
|
|
select: data => data.data, |
|
|
})) |
|
|
})) |