diff --git a/src/libs/route/addRoutes.js b/src/libs/route/addRoutes.js index 0287f4c..6422899 100644 --- a/src/libs/route/addRoutes.js +++ b/src/libs/route/addRoutes.js @@ -11,15 +11,13 @@ function createMeta(item) { function createRoute(data) { data.map(e => { const { path } = e - if (path) { - let meta = createMeta(e) - newRoutes.push({ - path, - meta - }) - } + // 有path则添加到路由里 + path && newRoutes.push({ + path, + meta: createMeta(e) + }) // 递归生成路由集合 - e.children && e.children.length && createRoute(e.children); + e.children && e.children.length && createRoute(e.children) }) } diff --git a/src/libs/route/generateRoutes.js b/src/libs/route/generateRoutes.js deleted file mode 100644 index 9db8a7b..0000000 --- a/src/libs/route/generateRoutes.js +++ /dev/null @@ -1,26 +0,0 @@ -import store from "@/store"; -import router from "@/router"; - -export default function() { - setTimeout(() => { - let routes = store.state.auth.routes; - routes.forEach(e => { - if (e.path == "/") { - e.component = () => import("@/layouts/home/index.vue"); - } else { - e.component = () => import(`@/pages/${e.path}.vue`); - } - - e.children && e.children.forEach(n => { - n.path && (n.component = () => import(`@/pages/${n.path}.vue`)); - }); - }); - - routes.push({ - path: "*", - redirect: "404" - }); - - router.addRoutes(routes); - }, 500); -} \ No newline at end of file diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue index 1f970c9..0e8b7ad 100644 --- a/src/pages/account/login/index.vue +++ b/src/pages/account/login/index.vue @@ -157,8 +157,12 @@ export default { util.successMsg("登录成功"); this.setCustomer(res.customer); res.customerName && this.setCustomerName(res.customerName); - // let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/index"; - this.$router.replace('/station'); + + const path = '/station/list' // 默认路径 + this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => { + const list = res.permissionMenu[0].children + this.$router.push(list.find(e => e.path === path) ? path : list[0].path) + }).catch(err => {}) }).catch(res => {}); }, phoneCountdown() { diff --git a/src/pages/account/redirect/index.vue b/src/pages/account/redirect/index.vue index 0ef488e..107e8bf 100644 --- a/src/pages/account/redirect/index.vue +++ b/src/pages/account/redirect/index.vue @@ -37,7 +37,12 @@ export default { util.successMsg('登录成功') this.setCustomer(res.customer) this.setCustomerName(res.customerName) - this.$router.replace('/index') + + const path = '/station/list' // 默认路径 + this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => { + const list = res.permissionMenu[0].children + this.$router.push(list.find(e => e.path === path) ? path : list[0].path) + }).catch(err => {}) }).catch(res => {}) } } diff --git a/src/pages/match/list/index.vue b/src/pages/match/list/index.vue index 0ae4cd5..38a2c47 100644 --- a/src/pages/match/list/index.vue +++ b/src/pages/match/list/index.vue @@ -70,7 +70,6 @@