Skip to content

Commit c07b204

Browse files
committed
处理路由请求拦截
1 parent 393d6a8 commit c07b204

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
## 一、启动项目步骤
22
* 1、下载文件
33
* 2、安装依赖包
4-
* 3、起一个node服务加载菜单
5-
6-
```shell
7-
node muenu-server.js
8-
```
9-
10-
* 4、启动项目
4+
* 3、启动项目

src/router/router.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ const auth = (to, from, next) => {
5656
*/
5757
const whiteList = ['login'];
5858
const authRoutes = async (to, from, next) => {
59-
const routes = await store.dispatch('getMenuListApi');
60-
const routesUrlList = routes.map(item => item.index);
61-
if (routesUrlList.includes(to.name) || whiteList.includes(to.name)) {
62-
next({ ...to, replace: true });
59+
if (to.name == 'login') {
60+
next();
6361
} else {
64-
next({ name: 'home', replace: true });
62+
const routes = await store.dispatch('getMenuListApi');
63+
const routesUrlList = routes.map(item => item.index);
64+
if (routesUrlList.includes(to.name) || whiteList.includes(to.name)) {
65+
next({ ...to, replace: true });
66+
} else {
67+
next({ name: 'home', replace: true });
68+
}
6569
}
6670
}
6771
/********************************路由拦截配置 start********************************/

0 commit comments

Comments
 (0)