提交 fda615ff 作者: 郁骅焌

404页面

上级 03394943
...@@ -41,13 +41,17 @@ export default defineConfig({ ...@@ -41,13 +41,17 @@ export default defineConfig({
], ],
}, },
{ {
path: '/404',
component: './exception/404',
},
{
path: '/', path: '/',
component: '../layouts/SecurityLayout', component: '../layouts/SecurityLayout',
routes: [ routes: [
{ {
path: '/', path: '/',
component: '../layouts/BasicLayout', component: '../layouts/BasicLayout',
authority: ['admin', 'user'], // authority: ['admin', 'user'],
routes: [ routes: [
{ {
path: '/', path: '/',
...@@ -59,12 +63,12 @@ export default defineConfig({ ...@@ -59,12 +63,12 @@ export default defineConfig({
icon: 'smile', icon: 'smile',
component: './Welcome', component: './Welcome',
}, },
{ // {
name: 'list.table-list', // name: 'list.table-list',
icon: 'table', // icon: 'table',
path: '/list', // path: '/list',
component: './ListTableList', // component: './ListTableList',
}, // },
{ {
path: '/system', path: '/system',
name: 'system', name: 'system',
...@@ -109,6 +113,10 @@ export default defineConfig({ ...@@ -109,6 +113,10 @@ export default defineConfig({
}, },
], ],
}, },
{
path: '*',
component: './exception/404',
},
], ],
}, },
], ],
......
export function patchRoutes({ routes }) { export function patchRoutes({ routes }) {
// console.log(JSON.parse(localStorage.menuTree)) // 添加不匹配路由跳转404页面
// console.log(routes) for (let i = 0; i < routes.length; i++) {
if (routes[i].path === '/') {
routes[i].routes[0].routes.forEach(item => {
if (item.routes && item.routes.length !== 0) {
item.routes.push(
{
path: '*',
exact: true,
// redirect: '/404',
component: require('@/pages/exception/404').default,
}
)
}
})
}
}
} }
...@@ -240,7 +240,10 @@ const BasicLayout = (props) => { ...@@ -240,7 +240,10 @@ const BasicLayout = (props) => {
* init variables * init variables
*/ */
console.log(props.children)
return ( return (
<div className={`sage-app-wrapper ${collapsed ? 'hideSidebar' : ''}`}> <div className={`sage-app-wrapper ${collapsed ? 'hideSidebar' : ''}`}>
<div className="sage-sidebar-container"> <div className="sage-sidebar-container">
<div className="sidebar-logo-container"> <div className="sidebar-logo-container">
......
import React from 'react'
import { Link } from 'umi'
import {Result, Button} from 'antd'
export default () => (
<Result status='403' title='403' style={{background: 'none'}} subTitle='抱歉,你无权访问该页面。' extra={
<Link to="/">
<Button type="primary">返回首页</Button>
</Link>
}/>
)
import React from 'react'
import { Link } from 'umi'
import { Result, Button } from 'antd'
export default () => (
<Result status="404" title="404" style={{background: 'none'}} subTitle='抱歉,你访问的页面不存在。' extra={
<Link to="/">
<Button type="primary">返回首页</Button>
</Link>
}
/>
)
import React from 'react'
import { Link } from 'umi'
import {Result, Button} from 'antd'
export default () => (
<Result status="500" title="500" style={{background: 'none'}} subTitle='抱歉,服务器出错了。' extra={
<Link to="/">
<Button type="primary">返回首页</Button>
</Link>
}
/>
)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论