vue2-client 1.10.32-alpha.1 → 1.10.32
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/package.json +107 -107
- package/src/App.vue +2 -2
- package/src/base-client/components/common/XAddNativeForm/demo.vue +1 -1
- package/src/base-client/components/common/XDataCard/XDataCard.vue +16 -17
- package/src/base-client/components/common/XForm/XForm.vue +393 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +47 -9
- package/src/base-client/components/common/XFormCol/XFormCol.vue +1 -1
- package/src/base-client/components/common/XFormGroup/XFormGroup.vue +301 -301
- package/src/base-client/components/common/XFormTable/demo.vue +2 -2
- package/src/components/cache/AKeepAlive.js +172 -179
- package/src/layouts/BlankView.vue +22 -78
- package/src/router/async/router.map.js +148 -95
- package/src/router/guards.js +263 -260
- package/src/utils/microAppUtils.js +0 -9
- package/src/utils/routerUtil.js +450 -526
- package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +0 -121
|
@@ -1,179 +1,172 @@
|
|
|
1
|
-
import { isDef, isRegExp, remove } from '@vue2-client/utils/util'
|
|
2
|
-
|
|
3
|
-
const patternTypes = [String, RegExp, Array]
|
|
4
|
-
|
|
5
|
-
function matches (pattern, name) {
|
|
6
|
-
if (Array.isArray(pattern)) {
|
|
7
|
-
if (pattern.indexOf(name) > -1) {
|
|
8
|
-
return true
|
|
9
|
-
} else {
|
|
10
|
-
for (const item of pattern) {
|
|
11
|
-
if (isRegExp(item) && item.test(name)) {
|
|
12
|
-
return true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
} else if (typeof pattern === 'string') {
|
|
18
|
-
return pattern.split(',').indexOf(name) > -1
|
|
19
|
-
} else if (isRegExp(pattern)) {
|
|
20
|
-
return pattern.test(name)
|
|
21
|
-
}
|
|
22
|
-
/* istanbul ignore next */
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getComponentName (opts) {
|
|
27
|
-
return opts && (opts.Ctor.options.name || opts.tag)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getComponentKey (vnode) {
|
|
31
|
-
const { componentOptions, key } = vnode
|
|
32
|
-
return key == null
|
|
33
|
-
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
34
|
-
: key +
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getFirstComponentChild (children) {
|
|
38
|
-
if (Array.isArray(children)) {
|
|
39
|
-
for (let i = 0; i < children.length; i++) {
|
|
40
|
-
const c = children[i]
|
|
41
|
-
if (isDef(c) && (isDef(c.componentOptions) || c.isAsyncPlaceholder)) {
|
|
42
|
-
return c
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function pruneCache (keepAliveInstance, filter) {
|
|
49
|
-
const { cache, keys, _vnode } = keepAliveInstance
|
|
50
|
-
for (const key in cache) {
|
|
51
|
-
const cachedNode = cache[key]
|
|
52
|
-
if (cachedNode) {
|
|
53
|
-
const name = getComponentName(cachedNode.componentOptions)
|
|
54
|
-
const componentKey = getComponentKey(cachedNode)
|
|
55
|
-
if (name && !filter(name, componentKey)) {
|
|
56
|
-
pruneCacheEntry(cache, key, keys, _vnode)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function pruneCacheEntry2 (cache, key, keys) {
|
|
63
|
-
const cached = cache[key]
|
|
64
|
-
if (cached) {
|
|
65
|
-
cached.componentInstance.$destroy()
|
|
66
|
-
}
|
|
67
|
-
cache[key] = null
|
|
68
|
-
remove(keys, key)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function pruneCacheEntry (cache, key, keys, current) {
|
|
72
|
-
const cached = cache[key]
|
|
73
|
-
if (cached && (!current || cached.tag !== current.tag)) {
|
|
74
|
-
cached.componentInstance.$destroy()
|
|
75
|
-
}
|
|
76
|
-
cache[key] = null
|
|
77
|
-
remove(keys, key)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default {
|
|
81
|
-
name: 'AKeepAlive',
|
|
82
|
-
abstract: true,
|
|
83
|
-
model: {
|
|
84
|
-
prop: 'clearCaches',
|
|
85
|
-
event: 'clear'
|
|
86
|
-
},
|
|
87
|
-
props: {
|
|
88
|
-
include: patternTypes,
|
|
89
|
-
exclude: patternTypes,
|
|
90
|
-
excludeKeys: patternTypes,
|
|
91
|
-
max: [String, Number],
|
|
92
|
-
clearCaches: Array
|
|
93
|
-
},
|
|
94
|
-
watch: {
|
|
95
|
-
clearCaches: function (val) {
|
|
96
|
-
if (val && val.length > 0) {
|
|
97
|
-
const { cache, keys } = this
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
vnode.data.keepAlive = true
|
|
176
|
-
}
|
|
177
|
-
return vnode || (slot && slot[0])
|
|
178
|
-
}
|
|
179
|
-
}
|
|
1
|
+
import { isDef, isRegExp, remove } from '@vue2-client/utils/util'
|
|
2
|
+
|
|
3
|
+
const patternTypes = [String, RegExp, Array]
|
|
4
|
+
|
|
5
|
+
function matches (pattern, name) {
|
|
6
|
+
if (Array.isArray(pattern)) {
|
|
7
|
+
if (pattern.indexOf(name) > -1) {
|
|
8
|
+
return true
|
|
9
|
+
} else {
|
|
10
|
+
for (const item of pattern) {
|
|
11
|
+
if (isRegExp(item) && item.test(name)) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
} else if (typeof pattern === 'string') {
|
|
18
|
+
return pattern.split(',').indexOf(name) > -1
|
|
19
|
+
} else if (isRegExp(pattern)) {
|
|
20
|
+
return pattern.test(name)
|
|
21
|
+
}
|
|
22
|
+
/* istanbul ignore next */
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getComponentName (opts) {
|
|
27
|
+
return opts && (opts.Ctor.options.name || opts.tag)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getComponentKey (vnode) {
|
|
31
|
+
const { componentOptions, key } = vnode
|
|
32
|
+
return key == null
|
|
33
|
+
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
34
|
+
: key + componentOptions.Ctor.cid
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getFirstComponentChild (children) {
|
|
38
|
+
if (Array.isArray(children)) {
|
|
39
|
+
for (let i = 0; i < children.length; i++) {
|
|
40
|
+
const c = children[i]
|
|
41
|
+
if (isDef(c) && (isDef(c.componentOptions) || c.isAsyncPlaceholder)) {
|
|
42
|
+
return c
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function pruneCache (keepAliveInstance, filter) {
|
|
49
|
+
const { cache, keys, _vnode } = keepAliveInstance
|
|
50
|
+
for (const key in cache) {
|
|
51
|
+
const cachedNode = cache[key]
|
|
52
|
+
if (cachedNode) {
|
|
53
|
+
const name = getComponentName(cachedNode.componentOptions)
|
|
54
|
+
const componentKey = getComponentKey(cachedNode)
|
|
55
|
+
if (name && !filter(name, componentKey)) {
|
|
56
|
+
pruneCacheEntry(cache, key, keys, _vnode)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function pruneCacheEntry2 (cache, key, keys) {
|
|
63
|
+
const cached = cache[key]
|
|
64
|
+
if (cached) {
|
|
65
|
+
cached.componentInstance.$destroy()
|
|
66
|
+
}
|
|
67
|
+
cache[key] = null
|
|
68
|
+
remove(keys, key)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function pruneCacheEntry (cache, key, keys, current) {
|
|
72
|
+
const cached = cache[key]
|
|
73
|
+
if (cached && (!current || cached.tag !== current.tag)) {
|
|
74
|
+
cached.componentInstance.$destroy()
|
|
75
|
+
}
|
|
76
|
+
cache[key] = null
|
|
77
|
+
remove(keys, key)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
name: 'AKeepAlive',
|
|
82
|
+
abstract: true,
|
|
83
|
+
model: {
|
|
84
|
+
prop: 'clearCaches',
|
|
85
|
+
event: 'clear'
|
|
86
|
+
},
|
|
87
|
+
props: {
|
|
88
|
+
include: patternTypes,
|
|
89
|
+
exclude: patternTypes,
|
|
90
|
+
excludeKeys: patternTypes,
|
|
91
|
+
max: [String, Number],
|
|
92
|
+
clearCaches: Array
|
|
93
|
+
},
|
|
94
|
+
watch: {
|
|
95
|
+
clearCaches: function (val) {
|
|
96
|
+
if (val && val.length > 0) {
|
|
97
|
+
const { cache, keys } = this
|
|
98
|
+
val.forEach(key => {
|
|
99
|
+
pruneCacheEntry2(cache, key, keys)
|
|
100
|
+
})
|
|
101
|
+
this.$emit('clear', [])
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
created () {
|
|
107
|
+
this.cache = Object.create(null)
|
|
108
|
+
this.keys = []
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
destroyed () {
|
|
112
|
+
for (const key in this.cache) {
|
|
113
|
+
pruneCacheEntry(this.cache, key, this.keys)
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
mounted () {
|
|
118
|
+
this.$watch('include', val => {
|
|
119
|
+
pruneCache(this, (name) => matches(val, name))
|
|
120
|
+
})
|
|
121
|
+
this.$watch('exclude', val => {
|
|
122
|
+
pruneCache(this, (name) => !matches(val, name))
|
|
123
|
+
})
|
|
124
|
+
this.$watch('excludeKeys', val => {
|
|
125
|
+
pruneCache(this, (name, key) => !matches(val, key))
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
render () {
|
|
130
|
+
const slot = this.$slots.default
|
|
131
|
+
const vnode = getFirstComponentChild(slot)
|
|
132
|
+
const componentOptions = vnode && vnode.componentOptions
|
|
133
|
+
if (componentOptions) {
|
|
134
|
+
// check pattern
|
|
135
|
+
const name = getComponentName(componentOptions)
|
|
136
|
+
const componentKey = getComponentKey(vnode)
|
|
137
|
+
const { include, exclude, excludeKeys } = this
|
|
138
|
+
if (
|
|
139
|
+
// not included
|
|
140
|
+
(include && (!name || !matches(include, name))) ||
|
|
141
|
+
// excluded
|
|
142
|
+
(exclude && name && matches(exclude, name)) ||
|
|
143
|
+
(excludeKeys && componentKey && matches(excludeKeys, componentKey))
|
|
144
|
+
) {
|
|
145
|
+
return vnode
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const { cache, keys } = this
|
|
149
|
+
const key = vnode.key == null
|
|
150
|
+
// same constructor may get registered as different local components
|
|
151
|
+
// so cid alone is not enough (#3269)
|
|
152
|
+
? componentOptions.Ctor.cid + (componentOptions.tag ? `::${componentOptions.tag}` : '')
|
|
153
|
+
: vnode.key + componentOptions.Ctor.cid
|
|
154
|
+
if (cache[key]) {
|
|
155
|
+
vnode.componentInstance = cache[key].componentInstance
|
|
156
|
+
// make current key freshest
|
|
157
|
+
remove(keys, key)
|
|
158
|
+
keys.push(key)
|
|
159
|
+
} else {
|
|
160
|
+
cache[key] = vnode
|
|
161
|
+
keys.push(key)
|
|
162
|
+
// prune oldest entry
|
|
163
|
+
if (this.max && keys.length > parseInt(this.max)) {
|
|
164
|
+
pruneCacheEntry(cache, keys[0], keys, this._vnode)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
vnode.data.keepAlive = true
|
|
169
|
+
}
|
|
170
|
+
return vnode || (slot && slot[0])
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -1,78 +1,22 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<page-toggle-transition :disabled="animate.disabled" :animate="animate.name" :direction="animate.direction">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
computed: {
|
|
26
|
-
...mapState('setting', ['cachePage', 'animate'])
|
|
27
|
-
},
|
|
28
|
-
created () {
|
|
29
|
-
this.loadCacheConfig(this.$router?.options?.routes)
|
|
30
|
-
},
|
|
31
|
-
mounted () {
|
|
32
|
-
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
33
|
-
window.microApp.addDataListener((data) => {
|
|
34
|
-
if (data.type === 'refresh') {
|
|
35
|
-
this.refresh()
|
|
36
|
-
} else if (data.type === 'clearCache' && data.key) {
|
|
37
|
-
this.clearCache(data.key)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
methods: {
|
|
43
|
-
// 加载需要排除缓存的路由配置
|
|
44
|
-
loadCacheConfig (routes, pCache = true) {
|
|
45
|
-
routes.forEach(item => {
|
|
46
|
-
const cacheAble = item.meta?.page?.cacheAble ?? pCache ?? true
|
|
47
|
-
if (!cacheAble) {
|
|
48
|
-
this.excludeKeys.push(new RegExp(`${item.path.replace(/:[^/]*/g, '[^/]*')}(\\?.*)?\\d*$`))
|
|
49
|
-
}
|
|
50
|
-
if (item.children) {
|
|
51
|
-
this.loadCacheConfig(item.children, cacheAble)
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
},
|
|
55
|
-
// 刷新页面方法
|
|
56
|
-
refresh () {
|
|
57
|
-
this.refreshing = true
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
this.refreshing = false
|
|
60
|
-
}, 200)
|
|
61
|
-
},
|
|
62
|
-
// 清除特定页面的缓存
|
|
63
|
-
clearCache (resultKeys) {
|
|
64
|
-
this.clearCaches = resultKeys
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
watch: {
|
|
68
|
-
'$router.options.routes': function (val) {
|
|
69
|
-
this.excludeKeys = []
|
|
70
|
-
this.loadCacheConfig(val)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
</script>
|
|
75
|
-
|
|
76
|
-
<style scoped>
|
|
77
|
-
|
|
78
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<page-toggle-transition :disabled="animate.disabled" :animate="animate.name" :direction="animate.direction">
|
|
3
|
+
<router-view />
|
|
4
|
+
</page-toggle-transition>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import PageToggleTransition from '../components/transition/PageToggleTransition'
|
|
9
|
+
import { mapState } from 'vuex'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'BlankView',
|
|
13
|
+
components: { PageToggleTransition },
|
|
14
|
+
computed: {
|
|
15
|
+
...mapState('setting', ['multiPage', 'animate'])
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
|
|
22
|
+
</style>
|