t20-common-lib 0.11.4 → 0.12.0
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 +1 -1
- package/packages/branch-bank-select/src/main.vue +19 -1
- package/packages/select-tree-unit/index.js +7 -0
- package/packages/select-tree-unit/src/main.vue +1203 -0
- package/packages/select-tree-unit-form/index.js +7 -0
- package/packages/select-tree-unit-form/src/main.vue +1082 -0
- package/src/api/common.js +12 -0
- package/src/common/selectTree/Extends/ElSelect.vue +180 -0
- package/src/common/selectTree/Filters/defaultFilterItems.js +30 -0
- package/src/common/selectTree/Filters/index.vue +169 -0
- package/src/common/selectTree/Tree/document.svg +8 -0
- package/src/common/selectTree/Tree/folder.svg +9 -0
- package/src/common/selectTree/Tree/index.vue +198 -0
- package/src/common/selectTree/forEachs.js +16 -0
- package/src/common/selectTree/imgs/list-select.png +0 -0
- package/src/common/selectTree/imgs/list-unselect.png +0 -0
- package/src/common/selectTree/imgs/list.png +0 -0
- package/src/common/selectTree/imgs/tree-select.png +0 -0
- package/src/common/selectTree/imgs/tree-unselect.png +0 -0
- package/src/common/selectTree/imgs/tree.png +0 -0
- package/src/index.js +7 -1
- package/src/utils/getJsonc.js +53 -0
- package/src/utils/realUrl.js +14 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* 引入不被打包的配置文件 */
|
|
2
|
+
import stripJsonc from 'strip-json-comments'
|
|
3
|
+
import realUrl from './realUrl'
|
|
4
|
+
/* 前端(内存)缓存 */
|
|
5
|
+
const jsoncs = {}
|
|
6
|
+
|
|
7
|
+
export default function getJsonc(url, sync,rest) {
|
|
8
|
+
const _url = realUrl(url, rest)
|
|
9
|
+
if (sync) {
|
|
10
|
+
if (jsoncs[url + '?sync']) {
|
|
11
|
+
return jsoncs[url + '?sync']
|
|
12
|
+
} else {
|
|
13
|
+
const oAjax = new XMLHttpRequest()
|
|
14
|
+
oAjax.open('GET', _url, false)
|
|
15
|
+
oAjax.send()
|
|
16
|
+
if (oAjax.readyState === 4 && oAjax.status === 200) {
|
|
17
|
+
try {
|
|
18
|
+
const _data = JSON.parse(stripJsonc(oAjax.responseText))
|
|
19
|
+
jsoncs[url + '?sync'] = _data
|
|
20
|
+
jsoncs[url] = Promise.resolve(_data)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw { error: url + ' illegal file', content: oAjax.responseText }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return jsoncs[url + '?sync']
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
if (jsoncs[url]) {
|
|
29
|
+
return jsoncs[url]
|
|
30
|
+
} else {
|
|
31
|
+
const oAjax = new XMLHttpRequest()
|
|
32
|
+
oAjax.open('GET', _url, true)
|
|
33
|
+
oAjax.send()
|
|
34
|
+
jsoncs[url] = new Promise((resolve, reject) => {
|
|
35
|
+
oAjax.onreadystatechange = () => {
|
|
36
|
+
if (oAjax.readyState === 4 && oAjax.status === 200) {
|
|
37
|
+
try {
|
|
38
|
+
const _data = JSON.parse(stripJsonc(oAjax.responseText))
|
|
39
|
+
jsoncs[url + '?sync'] = _data
|
|
40
|
+
resolve(_data)
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw {
|
|
43
|
+
error: url + ' illegal file',
|
|
44
|
+
content: oAjax.responseText
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
return jsoncs[url]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* 前缀,针对乾坤做了处理 */
|
|
2
|
+
const prefix = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || process.env.BASE_URL || '/'
|
|
3
|
+
|
|
4
|
+
export default function realUrl(url, rest = false) {
|
|
5
|
+
if (/^http(s)?:|\/\//.test(url)) {
|
|
6
|
+
return url
|
|
7
|
+
} else if (/^\//.test(url)) {
|
|
8
|
+
return prefix + url.replace(/^\//, '')
|
|
9
|
+
} else if (rest) {
|
|
10
|
+
return '/' + url
|
|
11
|
+
} else {
|
|
12
|
+
return url
|
|
13
|
+
}
|
|
14
|
+
}
|