diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index a3150490..b2653638 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -26,6 +26,17 @@ import Layout from '@/layout' // 公共路由 export const constantRoutes = [ + { + path: '/redirect', + component: Layout, + hidden: true, + children: [ + { + path: '/redirect/:path*', + component: () => import('@/views/redirect') + } + ] + }, { path: '/login', component: () => import('@/views/login'), @@ -93,8 +104,7 @@ export const constantRoutes = [ meta: { title: '修改生成配置' } } ] - }, - { path: '*', redirect: '/404', hidden: true } + } ] export default new Router({ diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index da937ae5..eb311642 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -20,6 +20,7 @@ const permission = { // 向后端请求路由数据 getRouters().then(res => { const accessedRoutes = filterAsyncRouter(res.data) + accessedRoutes.push({ path: '*', redirect: '/404', hidden: true }) commit('SET_ROUTES', accessedRoutes) resolve(accessedRoutes) }) diff --git a/ruoyi-ui/src/views/redirect.vue b/ruoyi-ui/src/views/redirect.vue new file mode 100644 index 00000000..db4c1d66 --- /dev/null +++ b/ruoyi-ui/src/views/redirect.vue @@ -0,0 +1,12 @@ +