Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vipSupplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王淑敏
vipSupplier
Commits
02e60649
Commit
02e60649
authored
Sep 09, 2020
by
may_zhouwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new file routes
parent
e424f42f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
33 deletions
+22
-33
src/store/modules/routes.js
+22
-33
No files found.
src/store/modules/routes.js
View file @
02e60649
/**
/**
* @
author
chuzhixin 1204505056@qq.com
* @
copyright
chuzhixin 1204505056@qq.com
* @description 路由拦截状态管理,目前两种模式:all模式与intelligence模式,其中partialRoutes是菜单暂未使用
* @description 路由拦截状态管理,目前两种模式:all模式与intelligence模式,其中partialRoutes是菜单暂未使用
*/
*/
import
{
asyncRoutes
,
constantRoutes
}
from
"@/router"
;
import
{
asyncRoutes
,
constantRoutes
}
from
"@/router"
;
import
{
getRouterList
}
from
"@/api/router"
;
import
{
getRouterList
}
from
"@/api/router"
;
import
{
convertRouter
,
filterRoutes
}
from
"@/utils/r
outes"
;
import
{
filterAllRoutes
,
filterAsyncRoutes
}
from
"@/utils/handleR
outes"
;
const
state
=
{
routes
:
[],
partialRoutes
:
[]
};
const
state
=
{
routes
:
[],
partialRoutes
:
[]
};
const
getters
=
{
const
getters
=
{
...
@@ -13,46 +13,35 @@ const getters = {
...
@@ -13,46 +13,35 @@ const getters = {
};
};
const
mutations
=
{
const
mutations
=
{
setRoutes
(
state
,
routes
)
{
setRoutes
(
state
,
routes
)
{
state
.
routes
=
routes
;
state
.
routes
=
constantRoutes
.
concat
(
routes
);
},
setAllRoutes
(
state
,
routes
)
{
state
.
routes
=
constantRoutes
.
concat
(
routes
);
},
},
setPartialRoutes
(
state
,
routes
)
{
setPartialRoutes
(
state
,
routes
)
{
state
.
partialRoutes
=
routes
;
state
.
partialRoutes
=
constantRoutes
.
concat
(
routes
)
;
},
},
};
};
const
actions
=
{
const
actions
=
{
/**
async
setRoutes
({
commit
},
permissions
)
{
* @author chuzhixin 1204505056@qq.com
//开源版只过滤动态路由permissions,admin不再默认拥有全部权限
* @description intelligence模式设置路由
const
finallyAsyncRoutes
=
await
filterAsyncRoutes
(
* @param {*} { commit }
[...
asyncRoutes
],
* @returns
permissions
*/
);
async
setRoutes
({
commit
})
{
commit
(
"setRoutes"
,
finallyAsyncRoutes
);
const
finallyRoutes
=
filterRoutes
([...
constantRoutes
,
...
asyncRoutes
]);
return
finallyAsyncRoutes
;
commit
(
"setRoutes"
,
finallyRoutes
);
return
[...
asyncRoutes
];
},
},
/**
* @author chuzhixin 1204505056@qq.com
* @description all模式设置路由
* @param {*} { commit }
* @returns
*/
async
setAllRoutes
({
commit
})
{
async
setAllRoutes
({
commit
})
{
let
{
data
}
=
await
getRouterList
();
let
{
data
}
=
await
getRouterList
();
if
(
data
[
data
.
length
-
1
].
path
!==
"*"
)
data
.
push
({
path
:
"*"
,
redirect
:
"/404"
,
hidden
:
true
});
data
.
push
({
path
:
"*"
,
redirect
:
"/404"
,
hidden
:
true
});
let
accessRoutes
=
filterAllRoutes
(
data
);
const
finallyRoutes
=
filterRoutes
(
convertRouter
(
data
));
commit
(
"setAllRoutes"
,
accessRoutes
);
commit
(
"setRoutes"
,
finallyRoutes
);
return
accessRoutes
;
return
finallyRoutes
;
},
},
/**
setPartialRoutes
({
commit
},
accessRoutes
)
{
* @author chuzhixin 1204505056@qq.com
commit
(
"setPartialRoutes"
,
accessRoutes
);
* @description 画廊布局、综合布局设置路由
return
accessRoutes
;
* @param {*} { commit }
* @param accessedRoutes 画廊布局、综合布局设置路由
*/
setPartialRoutes
({
commit
},
accessedRoutes
)
{
commit
(
"setPartialRoutes"
,
accessedRoutes
);
},
},
};
};
export
default
{
state
,
getters
,
mutations
,
actions
};
export
default
{
state
,
getters
,
mutations
,
actions
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment