imatrix-ui 0.2.4-up → 0.2.6-up

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.
@@ -1,156 +1,158 @@
1
1
  <template>
2
- <el-breadcrumb class="app-breadcrumb" separator=">">
3
- <transition-group tag="span" name="breadcrumb">
4
- <el-breadcrumb-item
5
- v-for="(item, index) in levelListWithTitle"
6
- :key="item.path + '-' + index"
7
- >
2
+ <el-breadcrumb class="app-breadcrumb" separator=">">
3
+ <transition-group name="breadcrumb" tag="span">
4
+ <el-breadcrumb-item
5
+ v-for="(item, index) in levelListWithTitle"
6
+ :key="item.path + '-' + index"
7
+ >
8
8
  <span class="no-redirect">
9
9
  {{ $t(item.meta.title) }}
10
10
  </span>
11
- </el-breadcrumb-item>
12
- </transition-group>
13
- </el-breadcrumb>
11
+ </el-breadcrumb-item>
12
+ </transition-group>
13
+ </el-breadcrumb>
14
14
  </template>
15
15
 
16
16
  <script>
17
- import * as Vue from 'vue'
18
- import { getLanguageWithLocale } from '../../../../utils/util'
17
+ import {getLanguageWithLocale} from '../../../../utils/util'
19
18
  import * as pathToRegexp from 'path-to-regexp'
20
- import * as Cookies from 'js-cookie'
19
+ import Cookies from 'js-cookie'
21
20
 
22
21
  export default {
23
- name: 'Breadcrumb',
24
- data() {
25
- return {
26
- levelList: null,
27
- }
28
- },
29
- computed: {
30
- levelListWithTitle() {
31
- return this.levelList.filter(
32
- (item) => item.meta.title !== undefined && item.meta.title !== null
33
- )
34
- },
35
- },
36
- watch: {
37
- $route() {
38
- this.getBreadcrumb()
39
- },
40
- },
41
- created() {
42
- this.getBreadcrumb()
43
- },
44
- methods: {
45
- getBreadcrumb() {
46
- const { params } = this.$route
47
- console.log('this.$route.matched==', this.$route.matched)
48
- let matched = this.$route.matched.filter((item) => {
49
- if (item.name) {
50
- // To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
51
- var toPath = pathToRegexp.compile(item.path)
52
- item.path = toPath(params)
53
- return true
54
- }
55
- })
56
- // const first = matched[0]
57
- if (matched) {
58
- let systemName
59
- const language = getLanguageWithLocale()
60
- const systemNameObj =
61
- window.$vueApp.config.globalProperties.systemNameObj
62
- if (systemNameObj) {
63
- systemName = systemNameObj[language]
64
- }
65
- matched = [
66
- { path: '/', redirect: 'noredirect', meta: { title: systemName } },
67
- ].concat(matched)
68
- const cookieMenu = Cookies.get('selectMenu')
69
- const leftSelectMenu =
70
- window.$vueApp.config.globalProperties._selectMenu
71
- let selectMenu
72
- if (leftSelectMenu) {
73
- selectMenu = leftSelectMenu
74
- } else if (cookieMenu) {
75
- selectMenu = cookieMenu
76
- }
77
- if (selectMenu) {
78
- // 解决表单页面无法获得列表路由
79
- const path = selectMenu.substring(0, selectMenu.indexOf('~~'))
80
- const title = selectMenu.substring(selectMenu.indexOf('~~') + 2)
81
- if (matched && matched.length > 0) {
82
- const lastRoute = matched[matched.length - 1]
83
- if (this.isShouldConcatLastMenu(title, path, lastRoute)) {
84
- matched.push({ path: path, meta: { title: title } })
85
- }
86
- } else {
87
- matched.push({ path: path, meta: { title: title } })
88
- }
89
- }
90
- }
91
- this.levelList = matched
92
- },
93
- // 新建页面时会把列表页面路由刷没,导致菜单路径缺少最后一层菜单问题
94
- isShouldConcatLastMenu(title, path, lastRoute) {
95
- if (
96
- this.isTitleNotEqual(title, lastRoute) &&
97
- this.isPathNotEqual(path, lastRoute)
98
- ) {
99
- // title和path都不同,表示是不同的页面,需要添加到matched集合中
100
- return true
101
- }
102
- return false
103
- },
104
- /**
105
- * Vue.prototype._selectMenu的菜单标题是否与最后的路由页面标题一致
106
- * 返回true表示不一样,返回false表示一样
107
- */
108
- isTitleNotEqual(title, lastRoute) {
109
- if (
110
- title &&
111
- lastRoute.meta &&
112
- title !== lastRoute.meta.title &&
113
- title !== this.$t(lastRoute.meta.title)
114
- ) {
115
- // 表示title不一样,当前可能是在表单页面,需要添加到matched集合中
116
- return true
117
- }
118
- return false
119
- },
120
- /**
121
- * Vue.prototype._selectMenu的菜单的访问路径是否与最后的路由页面的路径一致
122
- * 返回true表示不一样,返回false表示一样
123
- */
124
- isPathNotEqual(path, lastRoute) {
125
- if (path && lastRoute.path && path !== lastRoute.path) {
126
- // 表示path不一样,当前可能是在表单页面,需要添加到matched集合中
127
- return true
128
- }
129
- return false
130
- },
131
- },
22
+ name: 'Breadcrumb',
23
+ data() {
24
+ return {
25
+ levelList: null,
26
+ }
27
+ },
28
+ computed: {
29
+ levelListWithTitle() {
30
+ return this.levelList.filter(
31
+ (item) => item.meta.title !== undefined && item.meta.title !== null
32
+ )
33
+ },
34
+ },
35
+ watch: {
36
+ $route() {
37
+ this.getBreadcrumb()
38
+ },
39
+ },
40
+ created() {
41
+ this.getBreadcrumb()
42
+ },
43
+ methods: {
44
+ getBreadcrumb() {
45
+ const {params} = this.$route
46
+ console.log('this.$route.matched==', this.$route.matched)
47
+ let matched = this.$route.matched.filter((item) => {
48
+ if (item.name) {
49
+ // To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
50
+ var toPath = pathToRegexp.compile(item.path)
51
+ item.path = toPath(params)
52
+ return true
53
+ }
54
+ })
55
+ // const first = matched[0]
56
+ if (matched) {
57
+ let systemName
58
+ const language = getLanguageWithLocale()
59
+ const systemNameObj =
60
+ window.$vueApp.config.globalProperties.systemNameObj
61
+ if (systemNameObj) {
62
+ systemName = systemNameObj[language]
63
+ }
64
+ matched = [
65
+ {path: '/', redirect: 'noredirect', meta: {title: systemName}},
66
+ ].concat(matched)
67
+ const cookieMenu = Cookies.get('selectMenu')
68
+ const leftSelectMenu =
69
+ window.$vueApp.config.globalProperties._selectMenu
70
+ let selectMenu
71
+ if (leftSelectMenu) {
72
+ selectMenu = leftSelectMenu
73
+ } else if (cookieMenu) {
74
+ selectMenu = cookieMenu
75
+ }
76
+ if (selectMenu) {
77
+ // 解决表单页面无法获得列表路由
78
+ const path = selectMenu.substring(0, selectMenu.indexOf('~~'))
79
+ const title = selectMenu.substring(selectMenu.indexOf('~~') + 2)
80
+ if (matched && matched.length > 0) {
81
+ const lastRoute = matched[matched.length - 1]
82
+ if (this.isShouldConcatLastMenu(title, path, lastRoute)) {
83
+ matched.push({path: path, meta: {title: title}})
84
+ }
85
+ } else {
86
+ matched.push({path: path, meta: {title: title}})
87
+ }
88
+ }
89
+ }
90
+ this.levelList = matched
91
+ },
92
+ // 新建页面时会把列表页面路由刷没,导致菜单路径缺少最后一层菜单问题
93
+ isShouldConcatLastMenu(title, path, lastRoute) {
94
+ if (
95
+ this.isTitleNotEqual(title, lastRoute) &&
96
+ this.isPathNotEqual(path, lastRoute)
97
+ ) {
98
+ // title和path都不同,表示是不同的页面,需要添加到matched集合中
99
+ return true
100
+ }
101
+ return false
102
+ },
103
+ /**
104
+ * Vue.prototype._selectMenu的菜单标题是否与最后的路由页面标题一致
105
+ * 返回true表示不一样,返回false表示一样
106
+ */
107
+ isTitleNotEqual(title, lastRoute) {
108
+ if (
109
+ title &&
110
+ lastRoute.meta &&
111
+ title !== lastRoute.meta.title &&
112
+ title !== this.$t(lastRoute.meta.title)
113
+ ) {
114
+ // 表示title不一样,当前可能是在表单页面,需要添加到matched集合中
115
+ return true
116
+ }
117
+ return false
118
+ },
119
+ /**
120
+ * Vue.prototype._selectMenu的菜单的访问路径是否与最后的路由页面的路径一致
121
+ * 返回true表示不一样,返回false表示一样
122
+ */
123
+ isPathNotEqual(path, lastRoute) {
124
+ if (path && lastRoute.path && path !== lastRoute.path) {
125
+ // 表示path不一样,当前可能是在表单页面,需要添加到matched集合中
126
+ return true
127
+ }
128
+ return false
129
+ },
130
+ },
132
131
  }
133
132
  </script>
134
133
 
135
134
  <style lang="scss" rel="stylesheet/scss" scoped>
136
135
  .app-breadcrumb.el-breadcrumb {
137
- background-color: #eee;
138
- width: 100%;
139
- border: 1px solid #ccc;
140
- bottom: 2px;
141
- margin-left: 2px;
142
- display: inline-block;
143
- font-size: 14px;
144
- line-height: 40px;
145
- .no-redirect {
146
- color: #333;
147
- cursor: text;
148
- }
149
- .el-breadcrumb__item {
150
- padding-left: 5px;
151
- }
152
- .el-breadcrumb__separator {
153
- margin: 0 5px;
154
- }
136
+ background-color: #eee;
137
+ width: 100%;
138
+ border: 1px solid #ccc;
139
+ bottom: 2px;
140
+ margin-left: 2px;
141
+ display: inline-block;
142
+ font-size: 14px;
143
+ line-height: 40px;
144
+
145
+ .no-redirect {
146
+ color: #333;
147
+ cursor: text;
148
+ }
149
+
150
+ .el-breadcrumb__item {
151
+ padding-left: 5px;
152
+ }
153
+
154
+ .el-breadcrumb__separator {
155
+ margin: 0 5px;
156
+ }
155
157
  }
156
158
  </style>