vue2-client 1.4.55 → 1.4.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -3
- package/package.json +1 -1
- package/src/components/exception/ExceptionPage.vue +70 -70
- package/src/layouts/SinglePageView.vue +15 -11
- package/src/pages/exception/404.vue +25 -21
- package/src/router/async/router.map.js +68 -67
- package/src/router/guards.js +104 -104
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
> 所有关于本项目的变化都在该文档里。
|
|
3
3
|
|
|
4
|
-
**1.4.
|
|
5
|
-
-
|
|
4
|
+
**1.4.57 -2022-11-27 @江超**
|
|
5
|
+
- 优化登录态和未登录态的页面跳转方式
|
|
6
6
|
|
|
7
|
-
**1.4.54 - 1.4.
|
|
7
|
+
**1.4.54 - 1.4.56 -2022-11-25 @江超**
|
|
8
|
+
- 现在登录时会清除indexedDB缓存了
|
|
8
9
|
- 增加查询系统访问记录的接口
|
|
10
|
+
- 优化单页面组件显示效果
|
|
9
11
|
|
|
10
12
|
**1.4.53 -2022-11-21 @陈栋杨**
|
|
11
13
|
- 优化单页面组件传值方式
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="exception-page">
|
|
3
|
-
<div class="img">
|
|
4
|
-
<img :src="config[type].img" alt=""/>
|
|
5
|
-
</div>
|
|
6
|
-
<div class="content">
|
|
7
|
-
<h1>{{ config[type].title }}</h1>
|
|
8
|
-
<div class="desc">{{ config[type].desc }}</div>
|
|
9
|
-
<div class="action">
|
|
10
|
-
<a-button type="primary" @click="backHome"
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
import Config from './typeConfig'
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'ExceptionPage',
|
|
21
|
-
// eslint-disable-next-line vue/require-prop-types
|
|
22
|
-
props: ['type', 'homeRoute'],
|
|
23
|
-
data () {
|
|
24
|
-
return {
|
|
25
|
-
config: Config
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
methods: {
|
|
29
|
-
backHome () {
|
|
30
|
-
if (this.homeRoute) {
|
|
31
|
-
this.$router.push(
|
|
32
|
-
}
|
|
33
|
-
this.$emit('backHome', this.type)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<style lang="less" scoped>
|
|
40
|
-
.exception-page{
|
|
41
|
-
border-radius: 4px;
|
|
42
|
-
display: flex;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
align-items: center;
|
|
45
|
-
background-color: @base-bg-color;
|
|
46
|
-
.img{
|
|
47
|
-
padding-right: 52px;
|
|
48
|
-
zoom: 1;
|
|
49
|
-
img{
|
|
50
|
-
max-width: 430px;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
.content{
|
|
54
|
-
h1{
|
|
55
|
-
color: #434e59;
|
|
56
|
-
font-size: 72px;
|
|
57
|
-
font-weight: 600;
|
|
58
|
-
line-height: 72px;
|
|
59
|
-
margin-bottom: 24px;
|
|
60
|
-
}
|
|
61
|
-
.desc{
|
|
62
|
-
color: @text-color-second;
|
|
63
|
-
font-size: 20px;
|
|
64
|
-
line-height: 28px;
|
|
65
|
-
margin-bottom: 16px;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="exception-page">
|
|
3
|
+
<div class="img">
|
|
4
|
+
<img :src="config[type].img" alt=""/>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="content">
|
|
7
|
+
<h1>{{ config[type].title }}</h1>
|
|
8
|
+
<div class="desc">{{ config[type].desc }}</div>
|
|
9
|
+
<div class="action">
|
|
10
|
+
<a-button type="primary" @click="backHome">返回首页</a-button>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import Config from './typeConfig'
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'ExceptionPage',
|
|
21
|
+
// eslint-disable-next-line vue/require-prop-types
|
|
22
|
+
props: ['type', 'homeRoute'],
|
|
23
|
+
data () {
|
|
24
|
+
return {
|
|
25
|
+
config: Config
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
backHome () {
|
|
30
|
+
if (this.homeRoute) {
|
|
31
|
+
this.$router.push(this.homeRoute)
|
|
32
|
+
}
|
|
33
|
+
this.$emit('backHome', this.type)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<style lang="less" scoped>
|
|
40
|
+
.exception-page{
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: center;
|
|
45
|
+
background-color: @base-bg-color;
|
|
46
|
+
.img{
|
|
47
|
+
padding-right: 52px;
|
|
48
|
+
zoom: 1;
|
|
49
|
+
img{
|
|
50
|
+
max-width: 430px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
.content{
|
|
54
|
+
h1{
|
|
55
|
+
color: #434e59;
|
|
56
|
+
font-size: 72px;
|
|
57
|
+
font-weight: 600;
|
|
58
|
+
line-height: 72px;
|
|
59
|
+
margin-bottom: 24px;
|
|
60
|
+
}
|
|
61
|
+
.desc{
|
|
62
|
+
color: @text-color-second;
|
|
63
|
+
font-size: 20px;
|
|
64
|
+
line-height: 28px;
|
|
65
|
+
margin-bottom: 16px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
</style>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<page-toggle-transition :disabled="animate.disabled" :animate="animate.name" :direction="animate.direction">
|
|
3
3
|
<template v-if="login">
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
<a-spin tip="加载中,马上好" :spinning="!isLoaded">
|
|
5
|
+
<a-card>
|
|
6
|
+
<iframe
|
|
7
|
+
ref="singlepage"
|
|
8
|
+
:src="url"
|
|
9
|
+
:name="this.fullPath"
|
|
10
|
+
class="single-page-iframe"
|
|
11
|
+
@load="load">
|
|
12
|
+
</iframe>
|
|
13
|
+
</a-card>
|
|
14
|
+
</a-spin>
|
|
14
15
|
</template>
|
|
15
16
|
</page-toggle-transition>
|
|
16
17
|
</template>
|
|
@@ -37,7 +38,8 @@ export default {
|
|
|
37
38
|
data () {
|
|
38
39
|
return {
|
|
39
40
|
iframe: null,
|
|
40
|
-
url: ''
|
|
41
|
+
url: '',
|
|
42
|
+
isLoaded: false,
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
computed: {
|
|
@@ -45,6 +47,7 @@ export default {
|
|
|
45
47
|
...mapState('account', ['login'])
|
|
46
48
|
},
|
|
47
49
|
created () {
|
|
50
|
+
this.isLoaded = false
|
|
48
51
|
if (this.singlePageUrl.indexOf('sso:') !== -1) {
|
|
49
52
|
const serviceKey = this.singlePageUrl.substring(4)
|
|
50
53
|
CASLogin(serviceKey, true).then(res => {
|
|
@@ -93,6 +96,7 @@ export default {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
this.$emit('load', this.fullPath)
|
|
99
|
+
this.isLoaded = true
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<exception-page :home-route="homePage" :style="`min-height: ${minHeight}`" type="404" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
import ExceptionPage from '@vue2-client/components/exception/ExceptionPage'
|
|
7
|
-
import { mapState } from 'vuex'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<exception-page :home-route="homePage" :style="`min-height: ${minHeight}`" type="404" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import ExceptionPage from '@vue2-client/components/exception/ExceptionPage'
|
|
7
|
+
import { mapState } from 'vuex'
|
|
8
|
+
const { homePage } = require('@vue2-client/config')
|
|
9
|
+
export default {
|
|
10
|
+
name: 'Exp404',
|
|
11
|
+
components: { ExceptionPage },
|
|
12
|
+
computed: {
|
|
13
|
+
homePage () {
|
|
14
|
+
return homePage
|
|
15
|
+
},
|
|
16
|
+
...mapState('setting', ['pageMinHeight']),
|
|
17
|
+
minHeight () {
|
|
18
|
+
return this.pageMinHeight ? this.pageMinHeight + 'px' : '100vh'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style scoped lang="less">
|
|
25
|
+
</style>
|
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
const { homePage } = require('../../config')
|
|
2
|
+
// 视图组件
|
|
3
|
+
const view = {
|
|
4
|
+
tabs: () => import('@vue2-client/layouts/tabs'),
|
|
5
|
+
blank: () => import('@vue2-client/layouts/BlankView'),
|
|
6
|
+
page: () => import('@vue2-client/layouts/PageView')
|
|
7
|
+
}
|
|
8
|
+
// 动态路由对象定义
|
|
9
|
+
const routerResource = {}
|
|
10
|
+
// --------------------------------------基本视图组件--------------------------------------
|
|
11
|
+
// 空白视图
|
|
12
|
+
routerResource.blank = view.blank
|
|
13
|
+
// 单页面视图
|
|
14
|
+
routerResource.singlePage = view.blank
|
|
15
|
+
|
|
16
|
+
// --------------------------------------仪表盘--------------------------------------
|
|
17
|
+
routerResource.dashboard = view.blank
|
|
18
|
+
// 工作台
|
|
19
|
+
routerResource.workplace = () => import('@vue2-client/pages/dashboard/workplace')
|
|
20
|
+
// --------------------------------------系统配置--------------------------------------
|
|
21
|
+
routerResource.system = view.blank
|
|
22
|
+
// 报表测试用页面
|
|
23
|
+
routerResource.testPage = () => import('@vue2-client/pages/ReportView.vue')
|
|
24
|
+
// 字典管理
|
|
25
|
+
routerResource.dictionaryManage = () => import(/* webpackChunkName: "dictionary" */ '@vue2-client/pages/system/dictionary')
|
|
26
|
+
// 查询配置管理
|
|
27
|
+
routerResource.queryParamsManage = () => import(/* webpackChunkName: "queryParams" */ '@vue2-client/pages/system/queryParams')
|
|
28
|
+
// 文件管理
|
|
29
|
+
routerResource.fileManager = () => import('@vue2-client/pages/system/file')
|
|
30
|
+
// 登录日志
|
|
31
|
+
routerResource.loginInfor = () => import('@vue2-client/pages/system/monitor/loginInfor')
|
|
32
|
+
// 操作日志
|
|
33
|
+
routerResource.operLog = () => import('@vue2-client/pages/system/monitor/operLog')
|
|
34
|
+
// 系统问题反馈工单
|
|
35
|
+
routerResource.submitTicket = () => import(/* webpackChunkName: "submitTicket" */ '@vue2-client/pages/system/ticket')
|
|
36
|
+
|
|
37
|
+
// 基础路由组件注册
|
|
38
|
+
const routerMap = {
|
|
39
|
+
login: {
|
|
40
|
+
authority: '*',
|
|
41
|
+
path: '/login',
|
|
42
|
+
component: () => import('@vue2-client/pages/login')
|
|
43
|
+
},
|
|
44
|
+
root: {
|
|
45
|
+
path: '/',
|
|
46
|
+
name: '首页',
|
|
47
|
+
redirect: homePage,
|
|
48
|
+
component: view.tabs
|
|
49
|
+
},
|
|
50
|
+
exp403: {
|
|
51
|
+
authority: '*',
|
|
52
|
+
name: 'exp403',
|
|
53
|
+
path: '403',
|
|
54
|
+
component: () => import('@vue2-client/pages/exception/403')
|
|
55
|
+
},
|
|
56
|
+
exp404: {
|
|
57
|
+
name: 'exp404',
|
|
58
|
+
path: '404',
|
|
59
|
+
component: () => import('@vue2-client/pages/exception/404')
|
|
60
|
+
},
|
|
61
|
+
exp500: {
|
|
62
|
+
name: 'exp500',
|
|
63
|
+
path: '500',
|
|
64
|
+
component: () => import('@vue2-client/pages/exception/500')
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
Object.assign(routerMap, routerResource)
|
|
68
|
+
export default routerMap
|
package/src/router/guards.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { hasAuthority } from '@vue2-client/utils/authority-utils'
|
|
2
|
-
import { loginIgnore } from '@vue2-client/router/index'
|
|
3
|
-
import { checkAuthorization } from '@vue2-client/utils/request'
|
|
4
|
-
import NProgress from 'nprogress'
|
|
5
|
-
|
|
6
|
-
NProgress.configure({ showSpinner: false })
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 进度条开始
|
|
10
|
-
* @param to
|
|
11
|
-
* @param form
|
|
12
|
-
* @param next
|
|
13
|
-
*/
|
|
14
|
-
const progressStart = (to, from, next) => {
|
|
15
|
-
// start progress bar
|
|
16
|
-
if (!NProgress.isStarted()) {
|
|
17
|
-
NProgress.start()
|
|
18
|
-
}
|
|
19
|
-
next()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 登录守卫
|
|
24
|
-
* @param to
|
|
25
|
-
* @param form
|
|
26
|
-
* @param next
|
|
27
|
-
* @param options
|
|
28
|
-
*/
|
|
29
|
-
const loginGuard = (to, from, next, options) => {
|
|
30
|
-
const { message } = options
|
|
31
|
-
if (!loginIgnore.includes(to) && !checkAuthorization()) {
|
|
32
|
-
message.warning('登录已失效,请重新登录')
|
|
33
|
-
next({ path: '/login' })
|
|
34
|
-
} else {
|
|
35
|
-
next()
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 权限守卫
|
|
41
|
-
* @param to
|
|
42
|
-
* @param form
|
|
43
|
-
* @param next
|
|
44
|
-
* @param options
|
|
45
|
-
*/
|
|
46
|
-
const authorityGuard = (to, from, next, options) => {
|
|
47
|
-
const { store, message } = options
|
|
48
|
-
const permissions = store.getters['account/permissions']
|
|
49
|
-
const roles = store.getters['account/roles']
|
|
50
|
-
if (!hasAuthority(to, permissions, roles)) {
|
|
51
|
-
message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`)
|
|
52
|
-
next({ path: '/403' })
|
|
53
|
-
// NProgress.done()
|
|
54
|
-
} else {
|
|
55
|
-
next()
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 混合导航模式下一级菜单跳转重定向
|
|
61
|
-
* @param to
|
|
62
|
-
* @param from
|
|
63
|
-
* @param next
|
|
64
|
-
* @param options
|
|
65
|
-
* @returns {*}
|
|
66
|
-
*/
|
|
67
|
-
const redirectGuard = (to, from, next, options) => {
|
|
68
|
-
const { store } = options
|
|
69
|
-
const getFirstChild = (routes) => {
|
|
70
|
-
const route = routes[0]
|
|
71
|
-
if (!route.children || route.children.length === 0) {
|
|
72
|
-
return route
|
|
73
|
-
}
|
|
74
|
-
return getFirstChild(route.children)
|
|
75
|
-
}
|
|
76
|
-
if (store.state.setting.layout === 'mix') {
|
|
77
|
-
const firstMenu = store.getters['setting/firstMenu']
|
|
78
|
-
if (firstMenu.find(item => item.fullPath === to.fullPath)) {
|
|
79
|
-
store.commit('setting/setActivatedFirst', to.fullPath)
|
|
80
|
-
const subMenu = store.getters['setting/subMenu']
|
|
81
|
-
if (subMenu.length > 0) {
|
|
82
|
-
const redirect = getFirstChild(subMenu)
|
|
83
|
-
return next({ path: redirect.fullPath })
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
next()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 进度条结束
|
|
92
|
-
* @param to
|
|
93
|
-
* @param form
|
|
94
|
-
* @param options
|
|
95
|
-
*/
|
|
96
|
-
const progressDone = () => {
|
|
97
|
-
// finish progress bar
|
|
98
|
-
NProgress.done()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default {
|
|
102
|
-
beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
|
|
103
|
-
afterEach: [progressDone]
|
|
104
|
-
}
|
|
1
|
+
import { hasAuthority } from '@vue2-client/utils/authority-utils'
|
|
2
|
+
import { loginIgnore } from '@vue2-client/router/index'
|
|
3
|
+
import { checkAuthorization } from '@vue2-client/utils/request'
|
|
4
|
+
import NProgress from 'nprogress'
|
|
5
|
+
|
|
6
|
+
NProgress.configure({ showSpinner: false })
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 进度条开始
|
|
10
|
+
* @param to
|
|
11
|
+
* @param form
|
|
12
|
+
* @param next
|
|
13
|
+
*/
|
|
14
|
+
const progressStart = (to, from, next) => {
|
|
15
|
+
// start progress bar
|
|
16
|
+
if (!NProgress.isStarted()) {
|
|
17
|
+
NProgress.start()
|
|
18
|
+
}
|
|
19
|
+
next()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 登录守卫
|
|
24
|
+
* @param to
|
|
25
|
+
* @param form
|
|
26
|
+
* @param next
|
|
27
|
+
* @param options
|
|
28
|
+
*/
|
|
29
|
+
const loginGuard = (to, from, next, options) => {
|
|
30
|
+
const { message } = options
|
|
31
|
+
if ((!loginIgnore.includes(to) || to.name === '404') && !checkAuthorization()) {
|
|
32
|
+
message.warning('登录已失效,请重新登录')
|
|
33
|
+
next({ path: '/login' })
|
|
34
|
+
} else {
|
|
35
|
+
next()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 权限守卫
|
|
41
|
+
* @param to
|
|
42
|
+
* @param form
|
|
43
|
+
* @param next
|
|
44
|
+
* @param options
|
|
45
|
+
*/
|
|
46
|
+
const authorityGuard = (to, from, next, options) => {
|
|
47
|
+
const { store, message } = options
|
|
48
|
+
const permissions = store.getters['account/permissions']
|
|
49
|
+
const roles = store.getters['account/roles']
|
|
50
|
+
if (!hasAuthority(to, permissions, roles)) {
|
|
51
|
+
message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`)
|
|
52
|
+
next({ path: '/403' })
|
|
53
|
+
// NProgress.done()
|
|
54
|
+
} else {
|
|
55
|
+
next()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 混合导航模式下一级菜单跳转重定向
|
|
61
|
+
* @param to
|
|
62
|
+
* @param from
|
|
63
|
+
* @param next
|
|
64
|
+
* @param options
|
|
65
|
+
* @returns {*}
|
|
66
|
+
*/
|
|
67
|
+
const redirectGuard = (to, from, next, options) => {
|
|
68
|
+
const { store } = options
|
|
69
|
+
const getFirstChild = (routes) => {
|
|
70
|
+
const route = routes[0]
|
|
71
|
+
if (!route.children || route.children.length === 0) {
|
|
72
|
+
return route
|
|
73
|
+
}
|
|
74
|
+
return getFirstChild(route.children)
|
|
75
|
+
}
|
|
76
|
+
if (store.state.setting.layout === 'mix') {
|
|
77
|
+
const firstMenu = store.getters['setting/firstMenu']
|
|
78
|
+
if (firstMenu.find(item => item.fullPath === to.fullPath)) {
|
|
79
|
+
store.commit('setting/setActivatedFirst', to.fullPath)
|
|
80
|
+
const subMenu = store.getters['setting/subMenu']
|
|
81
|
+
if (subMenu.length > 0) {
|
|
82
|
+
const redirect = getFirstChild(subMenu)
|
|
83
|
+
return next({ path: redirect.fullPath })
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
next()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 进度条结束
|
|
92
|
+
* @param to
|
|
93
|
+
* @param form
|
|
94
|
+
* @param options
|
|
95
|
+
*/
|
|
96
|
+
const progressDone = () => {
|
|
97
|
+
// finish progress bar
|
|
98
|
+
NProgress.done()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default {
|
|
102
|
+
beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
|
|
103
|
+
afterEach: [progressDone]
|
|
104
|
+
}
|