'admin-21.02.26:处理后端控制路由、升级最新依赖等'
This commit is contained in:
parent
1009a1a1c6
commit
1efc57b866
2
.env
2
.env
@ -4,5 +4,5 @@ VITE_PORT = 10000
|
||||
# open 运行 npm run dev 时自动打开浏览器
|
||||
VITE_OPEN = false
|
||||
|
||||
# public path 配置线上环境路径
|
||||
# public path 配置线上环境路径(打包)
|
||||
VITE_PUBLIC_PATH = /vue-admin-wonderful-next-preview/
|
@ -26,11 +26,11 @@
|
||||
"@types/nprogress": "^0.2.0",
|
||||
"@types/sortablejs": "^1.10.6",
|
||||
"@vitejs/plugin-vue": "^1.1.4",
|
||||
"@vue/compiler-sfc": "^3.0.5",
|
||||
"@vue/compiler-sfc": "^3.0.6",
|
||||
"dotenv": "^8.2.0",
|
||||
"sass": "^1.32.8",
|
||||
"sass-loader": "^11.0.1",
|
||||
"typescript": "^4.2.2",
|
||||
"vite": "^2.0.2"
|
||||
"vite": "^2.0.3"
|
||||
}
|
||||
}
|
@ -16,8 +16,7 @@ export function getMenuAdmin(params?: object) {
|
||||
// 获取后端动态路由菜单(test)
|
||||
export function getMenuTest(params?: object) {
|
||||
return request({
|
||||
// url: '/gitee/lyt-top/vue-admin-wonderful-images/raw/master/next/menu/testMenu.json',
|
||||
url: '/src/api/menu/testMenu.json',
|
||||
url: '/gitee/lyt-top/vue-admin-wonderful-images/raw/master/next/menu/testMenu.json',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
|
@ -1,309 +0,0 @@
|
||||
{
|
||||
"code": 0,
|
||||
"type": "testMenu",
|
||||
"data": [
|
||||
{
|
||||
"path": "/home",
|
||||
"name": "home",
|
||||
"component": "home/index",
|
||||
"meta": {
|
||||
"title": "首页",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": true,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-shouye"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/limits",
|
||||
"name": "limits",
|
||||
"component": "layout/routerView/parent",
|
||||
"redirect": "/limits/frontEnd",
|
||||
"meta": {
|
||||
"title": "权限管理",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-quanxian"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/limits/backEnd",
|
||||
"name": "limitsBackEnd",
|
||||
"component": "layout/routerView/parent",
|
||||
"meta": {
|
||||
"title": "后端控制",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
]
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/limits/backEnd/page",
|
||||
"name": "limitsBackEndEndPage",
|
||||
"component": "limits/backEnd/page/index",
|
||||
"meta": {
|
||||
"title": "页面权限",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/menu",
|
||||
"name": "menu",
|
||||
"component": "layout/routerView/parent",
|
||||
"redirect": "/menu/menu1",
|
||||
"meta": {
|
||||
"title": "菜单嵌套",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/menu/menu1",
|
||||
"name": "menu1",
|
||||
"component": "layout/routerView/parent",
|
||||
"redirect": "/menu/menu1/menu11",
|
||||
"meta": {
|
||||
"title": "菜单1",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/menu/menu1/menu11",
|
||||
"name": "menu11",
|
||||
"component": "menu/menu1/menu11/index",
|
||||
"meta": {
|
||||
"title": "菜单11",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/menu/menu1/menu12",
|
||||
"name": "menu12",
|
||||
"component": "layout/routerView/parent",
|
||||
"redirect": "/menu/menu1/menu12/menu121",
|
||||
"meta": {
|
||||
"title": "菜单12",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/menu/menu1/menu12/menu121",
|
||||
"name": "menu121",
|
||||
"component": "menu/menu1/menu12/menu121/index",
|
||||
"meta": {
|
||||
"title": "菜单121",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/menu/menu1/menu12/menu122",
|
||||
"name": "menu122",
|
||||
"component": "menu/menu1/menu12/menu122/index",
|
||||
"meta": {
|
||||
"title": "菜单122",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/menu/menu1/menu13",
|
||||
"name": "menu13",
|
||||
"component": "menu/menu1/menu13/index",
|
||||
"meta": {
|
||||
"title": "菜单13",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/menu/menu2",
|
||||
"name": "menu2",
|
||||
"component": "menu/menu2/index",
|
||||
"meta": {
|
||||
"title": "菜单2",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-caidan"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/fun",
|
||||
"name": "funIndex",
|
||||
"component": "layout/routerView/parent",
|
||||
"redirect": "/fun/tagsView",
|
||||
"meta": {
|
||||
"title": "功能",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-crew_feature"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "/fun/tagsView",
|
||||
"name": "funTagsView",
|
||||
"component": "fun/tagsView/index",
|
||||
"meta": {
|
||||
"title": "tagsView操作",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "el-icon-thumb"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/pages",
|
||||
"name": "pagesIndex",
|
||||
"component": "pages/index",
|
||||
"meta": {
|
||||
"title": "页面",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-fuzhiyemian"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/chart",
|
||||
"name": "chartIndex",
|
||||
"component": "chart/index",
|
||||
"meta": {
|
||||
"title": "大数据图表",
|
||||
"isLink": "",
|
||||
"isHide": false,
|
||||
"isKeepAlive": true,
|
||||
"isAffix": false,
|
||||
"isIframe": false,
|
||||
"auth": [
|
||||
"admin",
|
||||
"test"
|
||||
],
|
||||
"icon": "iconfonticon-ico_shuju"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -476,7 +476,7 @@ export function getBackEndControlRoutes() {
|
||||
if (!token) return false
|
||||
store.dispatch('setUserInfos')
|
||||
const auth = store.state.userInfos.authPageList[0] // 模拟 admin 与 test
|
||||
if (auth !== 'admin') {
|
||||
if (auth === 'admin') {
|
||||
return new Promise((resolve, reject) => {
|
||||
getMenuAdmin().then((res: any) => {
|
||||
setBackEndControlRoutesFun(res)
|
||||
@ -486,11 +486,13 @@ export function getBackEndControlRoutes() {
|
||||
})
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
getMenuTest().then((res: any) => {
|
||||
setBackEndControlRoutesFun(res)
|
||||
if (res.data) resolve(res)
|
||||
else reject('请求错误')
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -500,12 +502,12 @@ export function setBackEndControlRoutesFun(res: any) {
|
||||
const oldRoutes = JSON.parse(JSON.stringify(res.data))
|
||||
store.dispatch('setBackEndControlRoutes', oldRoutes)
|
||||
dynamicRoutes[0].children = backEndRouter(res.data)
|
||||
resetRoute() // 删除/重置路由
|
||||
router.addRoute(pathMatch) // 添加404界面
|
||||
setAddRoute() // 添加动态路由
|
||||
setFilterMenu() // 过滤权限菜单
|
||||
setCacheTagsViewRoutes() // 添加 keepAlive 缓存
|
||||
console.log(dynamicRoutes)
|
||||
console.log(router.getRoutes())
|
||||
window.location.href = window.location.href
|
||||
}
|
||||
|
||||
// 后端控制路由,后端路由 component 转换
|
||||
@ -659,7 +661,7 @@ if (store.state.themeConfig.isRequestRoutes) getBackEndControlRoutes()
|
||||
router.beforeEach((to, from, next) => {
|
||||
document.title = `${to.meta.title} - vue-admin-wonderful-next` || `vue-admin-wonderful-next`
|
||||
NProgress.configure({ showSpinner: false })
|
||||
NProgress.start()
|
||||
if (to.meta.title) NProgress.start()
|
||||
const token = getSession('token')
|
||||
if (to.path === '/login' && !token) {
|
||||
next()
|
||||
|
@ -39,5 +39,5 @@ export default {
|
||||
animation: 'slideRight',
|
||||
columnsAsideStyle: 'columnsRound',
|
||||
layout: 'defaults',
|
||||
isRequestRoutes: true
|
||||
isRequestRoutes: false
|
||||
}
|
Loading…
Reference in New Issue
Block a user