Browse Source

修复Mutation数据成功后,invalidateQueries的传参

main
dark 7 months ago
parent
commit
528d8a7f79
  1. 4
      src/pages/system/menus/store.ts
  2. 6
      src/pages/system/roles/index.tsx
  3. 2
      src/pages/system/roles/store.ts
  4. 1
      src/store/user.ts

4
src/pages/system/menus/store.ts

@ -70,7 +70,7 @@ export const saveOrUpdateMenuAtom = atomWithMutation<IApiResult<IMenu>>((get) =>
//更新列表 //更新列表
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore fix // @ts-ignore fix
get(queryClientAtom).invalidateQueries([ 'menus', get(menuPageAtom) ]).then()
get(queryClientAtom).invalidateQueries({ queryKey: [ 'menus', get(menuPageAtom) ]}).then()
} }
} }
}) })
@ -86,7 +86,7 @@ export const deleteMenuAtom = atomWithMutation((get) => {
onSuccess: () => { onSuccess: () => {
message.success(t('message.deleteSuccess', '删除成功')) message.success(t('message.deleteSuccess', '删除成功'))
store.set(batchIdsAtom, []) store.set(batchIdsAtom, [])
get(queryClientAtom).invalidateQueries([ 'menus', get(menuPageAtom) ]).then()
get(queryClientAtom).invalidateQueries({ queryKey: [ 'menus', get(menuPageAtom) ]}).then()
} }
} }
}) })

6
src/pages/system/roles/index.tsx

@ -7,7 +7,7 @@ import {
} from '@ant-design/pro-components' } from '@ant-design/pro-components'
import { createLazyFileRoute } from '@tanstack/react-router' import { createLazyFileRoute } from '@tanstack/react-router'
import { useStyle } from './style.ts' import { useStyle } from './style.ts'
import { useEffect, useMemo, useRef, useState } from 'react'
import { memo, useEffect, useMemo, useRef, useState } from 'react'
import { useAtom, useAtomValue, useSetAtom } from 'jotai' import { useAtom, useAtomValue, useSetAtom } from 'jotai'
import { pageAtom, roleAtom, rolesAtom, saveOrUpdateRoleAtom, searchAtom } from './store.ts' import { pageAtom, roleAtom, rolesAtom, saveOrUpdateRoleAtom, searchAtom } from './store.ts'
import { useTranslation } from '@/i18n.ts' import { useTranslation } from '@/i18n.ts'
@ -38,7 +38,7 @@ const MenuTree = (props: any) => {
} }
const Roles = () => {
const Roles = memo(() => {
const { t } = useTranslation() const { t } = useTranslation()
const { styles } = useStyle() const { styles } = useStyle()
@ -196,7 +196,7 @@ const Roles = () => {
columns={columns}/> columns={columns}/>
</PageContainer> </PageContainer>
) )
}
})
export const Route = createLazyFileRoute('/system/roles')({ export const Route = createLazyFileRoute('/system/roles')({
component: Roles component: Roles

2
src/pages/system/roles/store.ts

@ -49,7 +49,7 @@ export const saveOrUpdateRoleAtom = atomWithMutation<IApiResult<IRole>>((get) =>
//更新列表 //更新列表
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore fix // @ts-ignore fix
get(queryClientAtom).invalidateQueries([ 'roles', get(searchAtom) ]).then()
get(queryClientAtom).invalidateQueries({ queryKey: [ 'roles', get(searchAtom) ] })
return res return res
} }

1
src/store/user.ts

@ -54,5 +54,6 @@ export const userMenuDataAtom = atomWithQuery<any, MenuItem[]>((get) => ({
select: (data: AxiosResponse) => { select: (data: AxiosResponse) => {
return formatMenuData(data.data.rows as any ?? []) return formatMenuData(data.data.rows as any ?? [])
}, },
cacheTime: 1000 * 60,
retry: false, retry: false,
})) }))
Loading…
Cancel
Save