From 9f5ed82cdfe812662e96d164db1e43b6a06958c8 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 03 十二月 2019 18:02:35 +0800
Subject: [PATCH] 动态加载路由 页面刷新问题
---
ruoyi-ui/src/views/redirect.vue | 12 ++++++++++++
ruoyi-ui/src/store/modules/permission.js | 1 +
ruoyi-ui/src/router/index.js | 14 ++++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js
index a315049..b265363 100644
--- a/ruoyi-ui/src/router/index.js
+++ b/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({
diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js
index da937ae..eb31164 100644
--- a/ruoyi-ui/src/store/modules/permission.js
+++ b/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)
})
diff --git a/ruoyi-ui/src/views/redirect.vue b/ruoyi-ui/src/views/redirect.vue
new file mode 100644
index 0000000..db4c1d6
--- /dev/null
+++ b/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>
--
Gitblit v1.9.3