RuoYi
2019-12-03 9f5ed82cdfe812662e96d164db1e43b6a06958c8
动态加载路由 页面刷新问题
已修改2个文件
已添加1个文件
27 ■■■■■ 文件已修改
ruoyi-ui/src/router/index.js 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/store/modules/permission.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/redirect.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/router/index.js
@@ -27,6 +27,17 @@
// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
@@ -93,8 +104,7 @@
        meta: { title: '修改生成配置' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
  }
]
export default new Router({
ruoyi-ui/src/store/modules/permission.js
@@ -20,6 +20,7 @@
        // 向后端请求路由数据
        getRouters().then(res => {
          const accessedRoutes = filterAsyncRouter(res.data)
          accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
          commit('SET_ROUTES', accessedRoutes)
          resolve(accessedRoutes)
        })
ruoyi-ui/src/views/redirect.vue
对比新文件
@@ -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>