动态加载路由 页面刷新问题
This commit is contained in:
parent
b70024487a
commit
9f5ed82cdf
@ -26,6 +26,17 @@ import Layout from '@/layout'
|
|||||||
|
|
||||||
// 公共路由
|
// 公共路由
|
||||||
export const constantRoutes = [
|
export const constantRoutes = [
|
||||||
|
{
|
||||||
|
path: '/redirect',
|
||||||
|
component: Layout,
|
||||||
|
hidden: true,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '/redirect/:path*',
|
||||||
|
component: () => import('@/views/redirect')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
component: () => import('@/views/login'),
|
component: () => import('@/views/login'),
|
||||||
@ -93,8 +104,7 @@ export const constantRoutes = [
|
|||||||
meta: { title: '修改生成配置' }
|
meta: { title: '修改生成配置' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
{ path: '*', redirect: '/404', hidden: true }
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export default new Router({
|
export default new Router({
|
||||||
|
@ -20,6 +20,7 @@ const permission = {
|
|||||||
// 向后端请求路由数据
|
// 向后端请求路由数据
|
||||||
getRouters().then(res => {
|
getRouters().then(res => {
|
||||||
const accessedRoutes = filterAsyncRouter(res.data)
|
const accessedRoutes = filterAsyncRouter(res.data)
|
||||||
|
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
||||||
commit('SET_ROUTES', accessedRoutes)
|
commit('SET_ROUTES', accessedRoutes)
|
||||||
resolve(accessedRoutes)
|
resolve(accessedRoutes)
|
||||||
})
|
})
|
||||||
|
12
ruoyi-ui/src/views/redirect.vue
Normal file
12
ruoyi-ui/src/views/redirect.vue
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
created() {
|
||||||
|
const { params, query } = this.$route
|
||||||
|
const { path } = params
|
||||||
|
this.$router.replace({ path: '/' + path, query })
|
||||||
|
},
|
||||||
|
render: function(h) {
|
||||||
|
return h() // avoid warning message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user