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
// @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: () => {
message.success(t('message.deleteSuccess', '删除成功'))
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'
import { createLazyFileRoute } from '@tanstack/react-router'
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 { pageAtom, roleAtom, rolesAtom, saveOrUpdateRoleAtom, searchAtom } from './store.ts'
import { useTranslation } from '@/i18n.ts'
@ -38,7 +38,7 @@ const MenuTree = (props: any) => {
}
const Roles = () => {
const Roles = memo(() => {
const { t } = useTranslation()
const { styles } = useStyle()
@ -196,7 +196,7 @@ const Roles = () => {
columns={columns}/>
</PageContainer>
)
}
})
export const Route = createLazyFileRoute('/system/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
// @ts-ignore fix
get(queryClientAtom).invalidateQueries([ 'roles', get(searchAtom) ]).then()
get(queryClientAtom).invalidateQueries({ queryKey: [ 'roles', get(searchAtom) ] })
return res
}

1
src/store/user.ts

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