Skip to content

Commit d5e2752

Browse files
committed
fix: route
1 parent 7a6eaf3 commit d5e2752

File tree

17 files changed

+429
-207
lines changed

17 files changed

+429
-207
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as React from 'react'
2+
3+
export type FixTabPanelProps = React.HTMLAttributes<HTMLDivElement> & {
4+
children?: React.ReactNode
5+
}
6+
7+
declare const FixTabPanel: React.ForwardRefExoticComponent<FixTabPanelProps & React.RefAttributes<HTMLDivElement>>
8+
9+
export default FixTabPanel
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React, { useMemo } from 'react'
2+
import { Result, Button, Typography, Space } from 'antd'
3+
import { useLocation } from 'react-router-dom'
4+
import { HomeOutlined, ArrowLeftOutlined } from '@ant-design/icons'
5+
import useSafeNavigate from '@hooks/useSafeNavigate'
6+
import FixTabPanel from '@stateless/FixTabPanel'
7+
8+
const { Paragraph, Text } = Typography
9+
10+
const SectionNotFound = () => {
11+
const location = useLocation()
12+
const { redirectTo } = useSafeNavigate()
13+
const pathname = location.pathname || '/'
14+
15+
const sectionPath = useMemo(() => {
16+
const segments = pathname.split('/').filter(Boolean)
17+
if (segments.length <= 1) {
18+
return '/'
19+
}
20+
return `/${segments.slice(0, -1).join('/')}`
21+
}, [pathname])
22+
23+
const handleBackToSection = () => {
24+
redirectTo(sectionPath)
25+
}
26+
27+
const handleBackHome = () => {
28+
redirectTo('/')
29+
}
30+
31+
return (
32+
<FixTabPanel>
33+
<Result
34+
status="404"
35+
title="模块子页面不存在"
36+
subTitle={
37+
<Paragraph style={{ marginBottom: 0 }}>
38+
当前路径 <Text code>{pathname}</Text> 不在该模块的有效子路由列表中。
39+
<br />
40+
建议返回 <Text code>{sectionPath}</Text> 查看模块首页,或返回全局首页继续浏览。
41+
</Paragraph>
42+
}
43+
extra={
44+
<Space size="middle">
45+
<Button icon={<ArrowLeftOutlined />} onClick={handleBackToSection}>
46+
返回模块首页
47+
</Button>
48+
<Button type="primary" icon={<HomeOutlined />} onClick={handleBackHome}>
49+
返回首页
50+
</Button>
51+
</Space>
52+
}
53+
/>
54+
</FixTabPanel>
55+
)
56+
}
57+
58+
export default SectionNotFound

src/config/menu.config.jsx

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,39 @@ const rawMainLayoutMenu = [
6161
{ label: 'Profile', key: '/profile', icon: <UserOutlined /> },
6262
{ label: 'Contact', key: '/contact', icon: <ContactsOutlined /> },
6363
{
64-
label: '技术栈',
65-
key: '/tech',
64+
label: '前端技术栈',
65+
key: '/tech/frontend',
6666
icon: <DeploymentUnitOutlined />,
6767
children: [
68+
{ label: 'React', key: '/tech/frontend/react', icon: <CodeOutlined /> },
6869
{
69-
label: '前端技术栈',
70-
key: '/tech/frontend',
71-
icon: <Html5Outlined />,
70+
label: 'Vue',
71+
key: '/tech/frontend/vue',
72+
icon: <CodeOutlined />,
7273
children: [
7374
{
74-
label: '框架生态',
75-
key: '/tech/frontend/framework',
75+
label: 'Vue 插件',
76+
key: '/tech/frontend/plugins',
7677
icon: <AppstoreOutlined />,
7778
children: [
78-
{
79-
label: 'Vue',
80-
key: '/tech/frontend/vue',
81-
icon: <CodeOutlined />,
82-
children: [
83-
{
84-
label: 'Vue 插件',
85-
key: '/tech/frontend/vue/plugins',
86-
icon: <AppstoreOutlined />,
87-
children: [
88-
{ label: 'Vue3 API', key: '/tech/frontend/vue/plugins/vue3', icon: <FileTextOutlined /> },
89-
{ label: '性能优化', key: '/tech/frontend/vue/plugins/perf', icon: <ThunderboltOutlined /> },
90-
],
91-
},
92-
],
93-
},
94-
{ label: 'Angular', key: '/tech/frontend/angular', icon: <Html5Outlined /> },
79+
{ label: 'Vue3 API', key: '/tech/frontend/plugins/vue3', icon: <FileTextOutlined /> },
80+
{ label: '性能优化', key: '/tech/frontend/plugins/perf', icon: <ThunderboltOutlined /> },
9581
],
9682
},
9783
],
9884
},
99-
{
100-
label: '后端技术栈',
101-
key: '/tech/backend',
102-
icon: <CloudServerOutlined />,
103-
},
85+
{ label: 'Angular', key: '/tech/frontend/angular', icon: <Html5Outlined /> },
86+
{ label: 'Node', key: '/tech/frontend/node', icon: <CloudServerOutlined /> },
87+
],
88+
},
89+
{
90+
label: '后端技术栈',
91+
key: '/tech/backend',
92+
icon: <CloudServerOutlined />,
93+
children: [
94+
{ label: 'Node', key: '/tech/backend/node', icon: <CodeOutlined /> },
95+
{ label: 'Java', key: '/tech/backend/java', icon: <CodeOutlined /> },
96+
{ label: 'Go', key: '/tech/backend/go', icon: <CodeOutlined /> },
10497
],
10598
},
10699
{

src/mock/permission.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ export const routePermissionMap: Record<string, PermissionCode> = {
160160
'/tech/frontend': 'tech:read',
161161
'/tech/frontend/react': 'tech:read',
162162
'/build/webpack': 'build:read',
163-
'/tech/frontend/vue': 'tech:read',
164-
'/tech/frontend/vue/plugins': 'tech:read',
165-
'/tech/frontend/vue/plugins/vue3': 'tech:read',
166-
'/tech/frontend/vue/plugins/perf': 'tech:read',
163+
'/tech/frontend/plugins': 'tech:read',
164+
'/tech/frontend/plugins/vue3': 'tech:read',
165+
'/tech/frontend/plugins/perf': 'tech:read',
167166
'/tech/frontend/angular': 'tech:read',
168167
'/tech/frontend/angular/:id': 'tech:read',
169168
'/tech/frontend/node': 'tech:read',

src/pages/product/add/index.jsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/pages/product/edit/index.jsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/pages/product/home/index.jsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/pages/product/index.jsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/pages/tech/backend/index.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import useSafeNavigate from '@hooks/useSafeNavigate'
33
import { Button } from 'antd'
44
import FixTabPanel from '@stateless/FixTabPanel'
55

6-
const BackendPage = () => {
6+
const BackendStack = () => {
77
const { redirectTo } = useSafeNavigate()
88

99
return (
1010
<FixTabPanel>
11-
<Button type="primary" style={{ margin: 10 }} onClick={() => redirectTo('/')}>
12-
Home
11+
<Button type="primary" onClick={() => redirectTo('/tech/backend/node')} style={{ margin: 10 }}>
12+
Node
1313
</Button>
14-
<Button style={{ margin: 10 }} onClick={() => redirectTo('/tech/frontend')}>
15-
Go to Frontend
14+
<Button onClick={() => redirectTo('/tech/backend/java')} style={{ margin: 10 }}>
15+
Java
16+
</Button>
17+
<Button onClick={() => redirectTo('/tech/backend/go')} type="dashed" style={{ margin: 10 }}>
18+
Go
1619
</Button>
1720
</FixTabPanel>
1821
)
1922
}
2023

21-
export default BackendPage
24+
export default BackendStack

src/pages/tech/demos/vue/plugins/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const VuePlugins = () => {
66
<FixTabPanel>
77
<div style={{ padding: 16 }}>
88
<h2>Vue Plugins</h2>
9-
<p>这是用于测试的五级菜单页面:/tech/frontend/vue/plugins</p>
9+
<p>这是用于测试的菜单页面:/tech/frontend/plugins</p>
1010
<p>此页面用于展示插件列表与深层菜单展开行为。</p>
1111
</div>
1212
</FixTabPanel>

0 commit comments

Comments
 (0)