Skip to content

Commit

Permalink
修复:
Browse files Browse the repository at this point in the history
1、登录失效无跳转
2、table二次请求额外数据丢失
3、菜单修改后无法立即生效
  • Loading branch information
qq958691165 committed Dec 31, 2024
1 parent 0f889f8 commit 13def02
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@quansitech/antd-admin",
"version": "1.1.23",
"version": "1.1.24",
"type": "module",
"files": [
"dist"
Expand Down
43 changes: 33 additions & 10 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,9 @@ export default function (props: any) {
const layoutProps = e.detail.page.props.layoutProps as LayoutProps

assignProps({
...layoutProps,
metaTitle: layoutProps?.metaTitle || '',
})
if (layoutProps?.title) {
assignProps({
title: layoutProps?.title
})
}
if (layoutProps?.menuActiveKey) {
assignProps({
menuActiveKey: layoutProps?.menuActiveKey
})
}
}

document.addEventListener('inertia:navigate', listener)
Expand All @@ -83,6 +74,38 @@ export default function (props: any) {
}
}, []);

useEffect(() => {
const listener = (e: GlobalEvent<'invalid'>) => {
if (!e.detail.response.headers['content-type'].includes('json')) {
return
}
e.preventDefault()
const {data} = e.detail.response

const goto = () => {
if (!data.url) {
return
}
window.location.href = data.url as string
}

if (data.info) {
global.notification.warning({message: data.info})
setTimeout(() => {
goto()
})
} else {
goto()
}

}

document.addEventListener('inertia:invalid', listener)
return () => {
document.removeEventListener('inertia:invalid', listener)
}
}, []);

return <>
<Head title={layoutProps.metaTitle + ' | ' + layoutProps.title + ' 后台管理'}></Head>

Expand Down
25 changes: 20 additions & 5 deletions src/components/Layout/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,25 @@ export default function ({children, pageTitle, siteTitle, setDarkMode}: {
}

const [openKeys, setOpenKeys] = useState<string[]>([])
const route = useMemo(() => {
return {
const [route, setRoute] = useState<any>({
key: '/',
routes: layoutContext.props.menuList?.map(menu => {
return {
name: menu.name,
key: menu.key,
children: menu.children?.map(child => {
return {
name: child.name,
key: child.key
}
})
}
})
})
useEffect(() => {
setRoute({
key: '/',
routes: layoutProps.menuList?.map(menu => {
routes: layoutContext.props.menuList?.map(menu => {
return {
name: menu.name,
key: menu.key,
Expand All @@ -52,8 +67,8 @@ export default function ({children, pageTitle, siteTitle, setDarkMode}: {
})
}
})
}
}, [layoutProps.menuList])
})
}, [layoutContext.props.menuList])

useEffect(() => {
function findKeyPath(key: string, list: MenuDataItem[]): string[] {
Expand Down
1 change: 1 addition & 0 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default function (props: TableProps) {
}

setDataSource(postData(props.dataSource))
setExtraRenderValues(props.extraRenderValues)
setPagination(props.pagination)
},
onFinish: () => {
Expand Down

0 comments on commit 13def02

Please sign in to comment.