@smart100/spu-web-plugin 0.0.18 → 0.0.22
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/dist/index.d.ts +1 -0
- package/dist/spu-web-plugin.mjs +51083 -41735
- package/package.json +2 -1
- package/src/axios.ts +14 -1
- package/src/components/expandexp/index.ts +73 -5
- package/src/components/expandexp/template.ts +158 -10
- package/src/components/webMessage/index.ts +143 -0
- package/src/core.js +30 -25
- package/src/index.ts +7 -1
- package/src/install.ts +5 -0
- package/src/types/shims-lib.d.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart100/spu-web-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "rollup -c -w",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
40
|
+
"@smart100/wxworksuite-plugin": "^0.0.3",
|
|
40
41
|
"axios": "^1.6.0",
|
|
41
42
|
"co": "^4.6.0",
|
|
42
43
|
"dayjs": "^1.11.10",
|
package/src/axios.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { get } from 'lodash-es'
|
|
|
8
8
|
// import { Message } from 'element-ui'
|
|
9
9
|
import { loadding } from './components/loadding'
|
|
10
10
|
import login from './login'
|
|
11
|
+
import core from './core'
|
|
11
12
|
|
|
12
13
|
interface Response {
|
|
13
14
|
code: number | string
|
|
@@ -18,6 +19,7 @@ interface Response {
|
|
|
18
19
|
const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPluginOptions) => {
|
|
19
20
|
const axiosInstance: AxiosInstance = axios.create({
|
|
20
21
|
baseURL: type === 'spu' ? `/api/${options.modulekey}/${options.moduleversion}` : '',
|
|
22
|
+
// baseURL: '',
|
|
21
23
|
// timeout: 36000000
|
|
22
24
|
// withCredentials: true, // 不能开启 影响ali oss
|
|
23
25
|
// headers: {
|
|
@@ -26,7 +28,7 @@ const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPlugi
|
|
|
26
28
|
// }
|
|
27
29
|
})
|
|
28
30
|
|
|
29
|
-
axiosInstance.interceptors.request.use((config: any) => {
|
|
31
|
+
axiosInstance.interceptors.request.use(async (config: any) => {
|
|
30
32
|
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
31
33
|
const isShowLoading = get(config, 'isShowLoading', true)
|
|
32
34
|
isShowLoading && loadding.open()
|
|
@@ -38,6 +40,17 @@ const createAxiosInstance = (type: 'spu' | 'apaas' = 'spu', options: SPUWebPlugi
|
|
|
38
40
|
config.headers.token = token
|
|
39
41
|
}
|
|
40
42
|
}
|
|
43
|
+
|
|
44
|
+
if (type === 'spu' && config.modulekey) {
|
|
45
|
+
const moduleData: any = await core.getModuleData(config.modulekey)
|
|
46
|
+
if (moduleData.data) {
|
|
47
|
+
config.baseURL = `/api/${config.modulekey}/${moduleData.data.moduleversion}`
|
|
48
|
+
} else {
|
|
49
|
+
console.error(moduleData.errorMsg)
|
|
50
|
+
config.baseURL = `/api/${config.modulekey}/v?.?`
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
return config
|
|
42
55
|
}, error => {
|
|
43
56
|
return Promise.reject(error)
|
|
@@ -54,6 +54,7 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
54
54
|
|
|
55
55
|
expandStatus: '1', // 1普通导出(没有做图片导出服务) 2服务端导出(做了图片导出服务未SPU化) 3安装了图片导出SPU
|
|
56
56
|
filewatermarkGlobalConfig: '0', // 全局文件水印开关
|
|
57
|
+
exportConfigInit: false,
|
|
57
58
|
exportcontentArray: ['excel', 'link', 'photo'], // 当 expandStatus = 2 | 3时才显示导出内容给用户选择
|
|
58
59
|
percentage: 0,
|
|
59
60
|
step: new Step(),
|
|
@@ -68,7 +69,7 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
68
69
|
runningTaskCount: 0,
|
|
69
70
|
isOldVersionService: false
|
|
70
71
|
}, (key: string, value: any) => {
|
|
71
|
-
const {
|
|
72
|
+
const { exportConfigInit, stepName, stepText, exportcontentArray, exportcontent, isOldVersionService, runningTaskCount, fileName, filetype, fileSize, exportDataItem, percentage, resultMessage } = this.data
|
|
72
73
|
|
|
73
74
|
// debugger
|
|
74
75
|
const $exportSel = this.shadow.querySelector('.export-sel') as any
|
|
@@ -89,6 +90,10 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
89
90
|
const $wait = this.shadow.querySelector('.export-wait') as any
|
|
90
91
|
const $waitSpan = this.shadow.querySelector('.export-wait span') as any
|
|
91
92
|
|
|
93
|
+
if (key === 'exportConfigInit') {
|
|
94
|
+
this.vIf($exportSelCon, exportConfigInit)
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
if (key === 'expandStatus' || key === 'stepName') {
|
|
93
98
|
// this.vIf($exportSel, (expandStatus !== '1' && stepName === 'initial'))
|
|
94
99
|
this.vIf($exportSel, (stepName === 'initial'))
|
|
@@ -232,6 +237,15 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
232
237
|
}
|
|
233
238
|
}
|
|
234
239
|
|
|
240
|
+
vOp (ele: any, flag: boolean) {
|
|
241
|
+
const elc = ele.classList
|
|
242
|
+
if (flag) {
|
|
243
|
+
elc.contains('opacity0') && elc.remove('opacity0')
|
|
244
|
+
} else {
|
|
245
|
+
!elc.contains('opacity0') && elc.add('opacity0')
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
235
249
|
initData (data: any, setCallback: any) {
|
|
236
250
|
this.data = cloneDeep(data)
|
|
237
251
|
const dataP = cloneDeep(data)
|
|
@@ -286,17 +300,34 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
286
300
|
})
|
|
287
301
|
|
|
288
302
|
this.shadow.querySelector('.export-file .export-file-r-download')!.addEventListener('click', () => {
|
|
289
|
-
console.log('下载')
|
|
290
303
|
this.handleDownload()
|
|
291
304
|
})
|
|
292
305
|
|
|
293
306
|
this.shadow.querySelector('.export-file .export-file-r-cancel')!.addEventListener('click', () => {
|
|
294
|
-
|
|
307
|
+
// this.handleCencel()
|
|
308
|
+
const ele = this.shadow.querySelector('.spu-expandexp-confirm')
|
|
309
|
+
this.vIf(ele, true)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
this.shadow.querySelector('.spu-expandexp-confirm-modal-th-close')!.addEventListener('click', () => {
|
|
314
|
+
const ele = this.shadow.querySelector('.spu-expandexp-confirm')
|
|
315
|
+
this.vIf(ele, false)
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
this.shadow.querySelector('.spu-expandexp-confirm-modal-cancel')!.addEventListener('click', () => {
|
|
319
|
+
const ele = this.shadow.querySelector('.spu-expandexp-confirm')
|
|
320
|
+
this.vIf(ele, false)
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
this.shadow.querySelector('.spu-expandexp-confirm-modal-confirm')!.addEventListener('click', () => {
|
|
295
324
|
this.handleCencel()
|
|
296
325
|
})
|
|
297
326
|
|
|
298
|
-
|
|
299
|
-
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
this.shadow.querySelector('.export-btn')!.addEventListener('click', () => {
|
|
330
|
+
// console.log('导出')
|
|
300
331
|
this.handleExport()
|
|
301
332
|
// this.data.percentage = this.data.percentage + 20
|
|
302
333
|
// this.data.isOldVersionService = false
|
|
@@ -338,6 +369,8 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
338
369
|
this.data.iscompress = data.iscompress.toString()
|
|
339
370
|
this.data.imagesizepercolumn = data.imagesizepercolumn.toString()
|
|
340
371
|
this.data.imageheightcm = data.imageheightcm.toString()
|
|
372
|
+
|
|
373
|
+
this.data.exportConfigInit = true
|
|
341
374
|
}
|
|
342
375
|
}
|
|
343
376
|
})
|
|
@@ -377,6 +410,8 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
377
410
|
this.data.exportcontent = 'excel'
|
|
378
411
|
this.data.filewatermark = '0'
|
|
379
412
|
this.data.iscompress = '0'
|
|
413
|
+
|
|
414
|
+
this.data.exportConfigInit = true
|
|
380
415
|
} else if (this.data.expandStatus === '2') {
|
|
381
416
|
this.data.iscompress = '1'
|
|
382
417
|
|
|
@@ -396,6 +431,7 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
396
431
|
this.data.filewatermarkGlobalConfig = '0'
|
|
397
432
|
}).finally(() => {
|
|
398
433
|
this.data.filewatermark = this.data.filewatermarkGlobalConfig === '1' ? '1' : '0'
|
|
434
|
+
this.data.exportConfigInit = true
|
|
399
435
|
})
|
|
400
436
|
}
|
|
401
437
|
})
|
|
@@ -555,8 +591,21 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
555
591
|
}
|
|
556
592
|
|
|
557
593
|
handleCencel () {
|
|
594
|
+
const $message = this.shadow.querySelector('.spu-expandexp-message') as any
|
|
595
|
+
// this.vText($message, '取消成功!')
|
|
596
|
+
// this.vIf($message, true)
|
|
597
|
+
// this.vOp($message, true)
|
|
598
|
+
// $message.classList.add('success')
|
|
599
|
+
// setTimeout(() => {
|
|
600
|
+
// this.vOp($message, false)
|
|
601
|
+
// setTimeout(() => {
|
|
602
|
+
// this.vIf($message, false)
|
|
603
|
+
// }, 1000)
|
|
604
|
+
// }, 1500)
|
|
605
|
+
// return false
|
|
558
606
|
// console.log(this.data)
|
|
559
607
|
// console.log(this.data.exportDataItem)
|
|
608
|
+
|
|
560
609
|
apaasAxios
|
|
561
610
|
.post('/api/teapi/queue/impexp/cancel', {
|
|
562
611
|
dynamicid: this.data.exportId
|
|
@@ -566,9 +615,28 @@ export default class SpuExpandexp extends HTMLElement {
|
|
|
566
615
|
// 取消成功
|
|
567
616
|
this.updateStep('cancel')
|
|
568
617
|
this.data.resultMessage = '任务已取消'
|
|
618
|
+
this.vText($message, '取消成功!')
|
|
619
|
+
this.vIf($message, true)
|
|
620
|
+
this.vOp($message, true)
|
|
621
|
+
$message.classList.add('success')
|
|
569
622
|
}
|
|
570
623
|
})
|
|
571
624
|
.catch((error: any) => {
|
|
625
|
+
this.vText($message, '取消失败!')
|
|
626
|
+
this.vIf($message, true)
|
|
627
|
+
this.vOp($message, true)
|
|
628
|
+
$message.classList.add('error')
|
|
629
|
+
})
|
|
630
|
+
.finally(() => {
|
|
631
|
+
const ele = this.shadow.querySelector('.spu-expandexp-confirm')
|
|
632
|
+
this.vIf(ele, false)
|
|
633
|
+
|
|
634
|
+
setTimeout(() => {
|
|
635
|
+
this.vOp($message, false)
|
|
636
|
+
setTimeout(() => {
|
|
637
|
+
this.vIf($message, false)
|
|
638
|
+
}, 2000)
|
|
639
|
+
}, 2000)
|
|
572
640
|
|
|
573
641
|
})
|
|
574
642
|
}
|
|
@@ -10,6 +10,87 @@ import icon_zip from './icons/icon_zip.png'
|
|
|
10
10
|
export default (ele: SpuExpandexp) => {
|
|
11
11
|
return `
|
|
12
12
|
<style>
|
|
13
|
+
.spu-expandexp-confirm {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0px;
|
|
21
|
+
right: 0px;
|
|
22
|
+
bottom: 0px;
|
|
23
|
+
}
|
|
24
|
+
.spu-expandexp-confirm-modal {
|
|
25
|
+
width: 400px;
|
|
26
|
+
margin: 50px auto 0;
|
|
27
|
+
border-radius: 2px;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
.spu-expandexp-confirm-modal-th {
|
|
31
|
+
height: 40px;
|
|
32
|
+
background-color: #409eff;
|
|
33
|
+
}
|
|
34
|
+
.spu-expandexp-confirm-modal-th-title {
|
|
35
|
+
float: left;
|
|
36
|
+
line-height: 40px;
|
|
37
|
+
color: #fff;
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
margin-left: 16px;
|
|
40
|
+
}
|
|
41
|
+
.spu-expandexp-confirm-modal-th-close {
|
|
42
|
+
float: right;
|
|
43
|
+
line-height: 40px;
|
|
44
|
+
height: 40px;
|
|
45
|
+
width: 40px;
|
|
46
|
+
color: #fff;
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
text-align: center;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
.spu-expandexp-confirm-modal-tb {
|
|
52
|
+
padding: 16px;
|
|
53
|
+
background-color: #fff;
|
|
54
|
+
}
|
|
55
|
+
.spu-expandexp-confirm-modal-tb-tip {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
.spu-expandexp-confirm-modal-btnwrap {
|
|
59
|
+
margin-top: 12px;
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: row-reverse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.spu-expandexp-message {
|
|
65
|
+
width: auto;
|
|
66
|
+
height: 30px;
|
|
67
|
+
line-height: 30px;
|
|
68
|
+
border-radius: 3px;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
position: absolute;
|
|
71
|
+
padding: 0 24px;
|
|
72
|
+
top: 50px;
|
|
73
|
+
left: 50%;
|
|
74
|
+
transform: translate(-50%, 0);
|
|
75
|
+
transition: all .6s ease;
|
|
76
|
+
}
|
|
77
|
+
.spu-expandexp-message.success {
|
|
78
|
+
background-color: #f0f9eb;
|
|
79
|
+
border: 1px solid #529b2e;
|
|
80
|
+
color: #67c23a;
|
|
81
|
+
}
|
|
82
|
+
.spu-expandexp-message.error {
|
|
83
|
+
background-color: #fde2e2;
|
|
84
|
+
border: 1px solid #c45656;
|
|
85
|
+
color: #f56c6c;
|
|
86
|
+
}
|
|
87
|
+
.opacity0 {
|
|
88
|
+
transition: all .6s ease;
|
|
89
|
+
opacity: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
</style>
|
|
93
|
+
<style>
|
|
13
94
|
:host {
|
|
14
95
|
display: block;
|
|
15
96
|
width: 100%;
|
|
@@ -31,9 +112,16 @@ export default (ele: SpuExpandexp) => {
|
|
|
31
112
|
height: 100%;
|
|
32
113
|
background-color: rgba(0, 0, 0, 0.5);
|
|
33
114
|
overflow: auto;
|
|
115
|
+
position: absolute;
|
|
116
|
+
top: 0;
|
|
117
|
+
left: 0px;
|
|
118
|
+
right: 0px;
|
|
119
|
+
bottom: 0px;
|
|
34
120
|
}
|
|
35
121
|
|
|
36
122
|
|
|
123
|
+
|
|
124
|
+
|
|
37
125
|
.modal {
|
|
38
126
|
width: 80%;
|
|
39
127
|
max-width: 800px;
|
|
@@ -181,17 +269,17 @@ export default (ele: SpuExpandexp) => {
|
|
|
181
269
|
line-height: 20px;
|
|
182
270
|
width: 20px;
|
|
183
271
|
border-radius: 14px;
|
|
184
|
-
color: #
|
|
185
|
-
background: #
|
|
186
|
-
border: 1px solid #
|
|
272
|
+
color: #999;
|
|
273
|
+
background: #fff;
|
|
274
|
+
border: 1px solid #999;
|
|
187
275
|
text-align: center;
|
|
188
276
|
font-size: 14px;
|
|
189
277
|
cursor: pointer;
|
|
190
278
|
}
|
|
191
279
|
.export-file-r-cancel:hover {
|
|
192
|
-
background: #
|
|
193
|
-
border-color: #
|
|
194
|
-
color: #
|
|
280
|
+
background: #fff;
|
|
281
|
+
border-color: #777;
|
|
282
|
+
color: #777;
|
|
195
283
|
}
|
|
196
284
|
|
|
197
285
|
|
|
@@ -214,7 +302,7 @@ export default (ele: SpuExpandexp) => {
|
|
|
214
302
|
animation-duration: 3s;
|
|
215
303
|
height: 100%;
|
|
216
304
|
width: 0;
|
|
217
|
-
background-color: #
|
|
305
|
+
background-color: #409eff;
|
|
218
306
|
-webkit-transition: width .6s ease;
|
|
219
307
|
transition: width .6s ease;
|
|
220
308
|
}
|
|
@@ -267,7 +355,7 @@ export default (ele: SpuExpandexp) => {
|
|
|
267
355
|
flex-direction: row-reverse;
|
|
268
356
|
}
|
|
269
357
|
.btn {
|
|
270
|
-
|
|
358
|
+
height: 38px;
|
|
271
359
|
line-height: 38px;
|
|
272
360
|
border: 1px solid #409eff;
|
|
273
361
|
background-color: #409eff;
|
|
@@ -281,6 +369,39 @@ export default (ele: SpuExpandexp) => {
|
|
|
281
369
|
background: #66b1ff;
|
|
282
370
|
border-color: #66b1ff;
|
|
283
371
|
}
|
|
372
|
+
|
|
373
|
+
.btn1 {
|
|
374
|
+
height: 30px;
|
|
375
|
+
line-height: 30px;
|
|
376
|
+
border: 1px solid #409eff;
|
|
377
|
+
background-color: #409eff;
|
|
378
|
+
border-radius: 5px;
|
|
379
|
+
color: #fff;
|
|
380
|
+
padding: 0 12px;
|
|
381
|
+
font-size: 14px;
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
}
|
|
384
|
+
.btn1:hover {
|
|
385
|
+
background: #66b1ff;
|
|
386
|
+
border-color: #66b1ff;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.btn2 {
|
|
390
|
+
height: 30px;
|
|
391
|
+
line-height: 30px;
|
|
392
|
+
border: 1px solid #aaa;
|
|
393
|
+
background-color: #fff;
|
|
394
|
+
border-radius: 5px;
|
|
395
|
+
color: #444;
|
|
396
|
+
padding: 0 12px;
|
|
397
|
+
font-size: 14px;
|
|
398
|
+
cursor: pointer;
|
|
399
|
+
}
|
|
400
|
+
.btn2:hover {
|
|
401
|
+
border-color: #ccc;
|
|
402
|
+
color: #777;
|
|
403
|
+
background-color: #fff;
|
|
404
|
+
}
|
|
284
405
|
</style>
|
|
285
406
|
|
|
286
407
|
<div class="spu-expandexp">
|
|
@@ -301,7 +422,7 @@ export default (ele: SpuExpandexp) => {
|
|
|
301
422
|
|
|
302
423
|
<div class="export-sel hide">
|
|
303
424
|
<div class="export-sel-title">请选择导出内容</div>
|
|
304
|
-
<div class="export-sel-con"></div>
|
|
425
|
+
<div class="export-sel-con hide"></div>
|
|
305
426
|
</div>
|
|
306
427
|
|
|
307
428
|
<div class="export-section-wrap hide">
|
|
@@ -333,12 +454,39 @@ export default (ele: SpuExpandexp) => {
|
|
|
333
454
|
</div>
|
|
334
455
|
|
|
335
456
|
<div class="export-btnwrap">
|
|
336
|
-
<div class="btn">导出</div>
|
|
457
|
+
<div class="export-btn btn">导出</div>
|
|
337
458
|
</div>
|
|
338
459
|
|
|
339
460
|
</div>
|
|
340
461
|
</div>
|
|
341
462
|
</div>
|
|
342
463
|
</div>
|
|
464
|
+
|
|
465
|
+
<div class="spu-expandexp-confirm hide">
|
|
466
|
+
<div class="spu-expandexp-confirm-modal">
|
|
467
|
+
<div class="spu-expandexp-confirm-modal-th">
|
|
468
|
+
<div class="spu-expandexp-confirm-modal-th-title">
|
|
469
|
+
数据导出
|
|
470
|
+
</div>
|
|
471
|
+
<div class="spu-expandexp-confirm-modal-th-close">
|
|
472
|
+
x
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
<div class="spu-expandexp-confirm-modal-tb">
|
|
476
|
+
|
|
477
|
+
<div class="spu-expandexp-confirm-modal-tb-tip">
|
|
478
|
+
确认是否取消该任务?
|
|
479
|
+
</div>
|
|
480
|
+
|
|
481
|
+
<div class="spu-expandexp-confirm-modal-btnwrap">
|
|
482
|
+
<div class="spu-expandexp-confirm-modal-confirm btn1">确定</div>
|
|
483
|
+
<div class="spu-expandexp-confirm-modal-cancel btn2" style="margin-right: 12px;">关闭</div>
|
|
484
|
+
</div>
|
|
485
|
+
|
|
486
|
+
</div>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<div class="spu-expandexp-message hide opacity0"></div>
|
|
343
491
|
`
|
|
344
492
|
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const styletext = `
|
|
2
|
+
:host {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: 10000;
|
|
9
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
10
|
+
}
|
|
11
|
+
:host .spu-web-message {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
const template = `
|
|
21
|
+
<div class="spu-web-message">
|
|
22
|
+
<div class="spu-web-message-icon"></div>
|
|
23
|
+
</div>
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
export default class SpuWebMessage extends HTMLElement {
|
|
27
|
+
|
|
28
|
+
static componentName: string = 'spu-web-message'
|
|
29
|
+
static register () {
|
|
30
|
+
if (!window.customElements.get(SpuWebMessage.componentName)) {
|
|
31
|
+
window.customElements.define(SpuWebMessage.componentName, SpuWebMessage)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
isuseshadow = true
|
|
36
|
+
// isuseshadow = false
|
|
37
|
+
shadow: ShadowRoot | null = null
|
|
38
|
+
constructor () {
|
|
39
|
+
super()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 当自定义元素第一次被连接到文档DOM时被调用。
|
|
43
|
+
connectedCallback () {
|
|
44
|
+
// console.log('connectedCallback')
|
|
45
|
+
const templateElem = document.createElement('template')
|
|
46
|
+
templateElem.innerHTML = template
|
|
47
|
+
const content = templateElem.content.cloneNode(true)
|
|
48
|
+
|
|
49
|
+
if (this.isuseshadow) {
|
|
50
|
+
this.shadow = this.attachShadow({ mode: 'open' })
|
|
51
|
+
this.shadow.append(content)
|
|
52
|
+
this.appendStyle()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// this.shadow.querySelector('.spu-web-message').addEventListener('click', () => {
|
|
56
|
+
// console.log(this)
|
|
57
|
+
// console.log(this.isuseshadow)
|
|
58
|
+
// console.log(this.shadow)
|
|
59
|
+
// })
|
|
60
|
+
// this.addEventListener('click', () => {
|
|
61
|
+
// console.log(this)
|
|
62
|
+
// console.log(this.isuseshadow)
|
|
63
|
+
// console.log(this.shadow)
|
|
64
|
+
// })
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
this.append(content)
|
|
68
|
+
this.appendStyle()
|
|
69
|
+
|
|
70
|
+
// this.addEventListener('click', () => {
|
|
71
|
+
// console.log(this)
|
|
72
|
+
// console.log(this.isuseshadow)
|
|
73
|
+
// console.log(this.shadow)
|
|
74
|
+
// })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 当组件从 DOM 文档移除后调用。
|
|
79
|
+
disconnectedCallback () {
|
|
80
|
+
// console.log('disconnectedCallback')
|
|
81
|
+
// setTimeout(() => {
|
|
82
|
+
// console.log(this)
|
|
83
|
+
// }, 100)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
createStyleEle () {
|
|
87
|
+
var styleElement = document.createElement('style')
|
|
88
|
+
styleElement.type = 'text/css'
|
|
89
|
+
styleElement.id = SpuWebMessage.componentName
|
|
90
|
+
styleElement.innerHTML = styletext
|
|
91
|
+
return styleElement
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
appendStyle () {
|
|
95
|
+
if (this.isuseshadow) {
|
|
96
|
+
const style = this.createStyleEle()
|
|
97
|
+
this.shadow!.appendChild(style)
|
|
98
|
+
} else {
|
|
99
|
+
if (!document.getElementById(SpuWebMessage.componentName)) {
|
|
100
|
+
const style = this.createStyleEle()
|
|
101
|
+
document.getElementsByTagName('head')[0].appendChild(style)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Loadding {
|
|
110
|
+
count = 0
|
|
111
|
+
|
|
112
|
+
ele: null | HTMLElement = null
|
|
113
|
+
|
|
114
|
+
constructor () {
|
|
115
|
+
SpuWebMessage.register()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
open () {
|
|
119
|
+
this.count++
|
|
120
|
+
if (!this.ele) {
|
|
121
|
+
this.ele = document.createElement('spu-web-message')
|
|
122
|
+
// console.log(this.ele)
|
|
123
|
+
document.body.appendChild(this.ele)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
close () {
|
|
128
|
+
this.count--
|
|
129
|
+
if (this.count <= 0) {
|
|
130
|
+
this.count = 0
|
|
131
|
+
if (this.ele) {
|
|
132
|
+
document.body.removeChild(this.ele)
|
|
133
|
+
this.ele = null
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const loadding = new Loadding()
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
loadding
|
|
143
|
+
}
|
package/src/core.js
CHANGED
|
@@ -70,6 +70,7 @@ class Core {
|
|
|
70
70
|
let response
|
|
71
71
|
try {
|
|
72
72
|
response = await axios.get(`${hostsRoot}/multiplatconfig/env/${envName}`, {
|
|
73
|
+
isShowLoading: false,
|
|
73
74
|
isSendToken: false
|
|
74
75
|
})
|
|
75
76
|
// console.log(response)
|
|
@@ -98,6 +99,8 @@ class Core {
|
|
|
98
99
|
res = await axios.post(`${smartcenter}/api/smartcenter/biz/getTenantWebAndApiDefined`, {
|
|
99
100
|
envid: envId,
|
|
100
101
|
tenantcode: tenantCode
|
|
102
|
+
}, {
|
|
103
|
+
isShowLoading: false
|
|
101
104
|
})
|
|
102
105
|
} catch (err) {
|
|
103
106
|
console.error(err)
|
|
@@ -180,6 +183,9 @@ class Core {
|
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
async getModuleData (modulekey) {
|
|
186
|
+
if (!modulekey) {
|
|
187
|
+
modulekey = globalOptions.modulekey
|
|
188
|
+
}
|
|
183
189
|
const res = {
|
|
184
190
|
errorMsg: '',
|
|
185
191
|
data: null
|
|
@@ -205,6 +211,9 @@ class Core {
|
|
|
205
211
|
}
|
|
206
212
|
|
|
207
213
|
async getContext (modulekey) {
|
|
214
|
+
if (!modulekey) {
|
|
215
|
+
modulekey = globalOptions.modulekey
|
|
216
|
+
}
|
|
208
217
|
let context
|
|
209
218
|
const moduleData = await this.getModuleData(modulekey)
|
|
210
219
|
if (moduleData?.data) {
|
|
@@ -234,6 +243,9 @@ class Core {
|
|
|
234
243
|
}
|
|
235
244
|
|
|
236
245
|
async checkModule (modulekey) {
|
|
246
|
+
if (!modulekey) {
|
|
247
|
+
modulekey = globalOptions.modulekey
|
|
248
|
+
}
|
|
237
249
|
const moduleData = await this.getModuleData(modulekey)
|
|
238
250
|
return !!moduleData.data
|
|
239
251
|
}
|
|
@@ -362,21 +374,21 @@ class Core {
|
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
376
|
|
|
365
|
-
async getApiOrigin (modulekey) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
377
|
+
// async getApiOrigin (modulekey) {
|
|
378
|
+
// let apiOrigin = ''
|
|
379
|
+
// let errorMsg = ''
|
|
380
|
+
// const moduleData = await this.getModuleData(modulekey)
|
|
381
|
+
// if (moduleData.data) {
|
|
382
|
+
// const moduleBusiness = await this.getModuleBusiness(modulekey)
|
|
383
|
+
// apiOrigin = `${moduleBusiness}/api/${moduleData.data.modulekey}/${moduleData.data.moduleversion}/`
|
|
384
|
+
// } else {
|
|
385
|
+
// errorMsg = moduleData.errorMsg
|
|
386
|
+
// }
|
|
387
|
+
// return {
|
|
388
|
+
// apiOrigin,
|
|
389
|
+
// errorMsg
|
|
390
|
+
// }
|
|
391
|
+
// }
|
|
380
392
|
|
|
381
393
|
|
|
382
394
|
// Module.apiRequest({
|
|
@@ -441,30 +453,23 @@ class Core {
|
|
|
441
453
|
}
|
|
442
454
|
}
|
|
443
455
|
|
|
444
|
-
|
|
445
456
|
const core = new Core()
|
|
446
457
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
458
|
const Module = {
|
|
451
459
|
// getContextSync () {
|
|
452
460
|
// return core.getContext(modulekey)
|
|
453
461
|
// },
|
|
454
462
|
// linkToPage: core.linkToPage.bind(core),
|
|
455
463
|
// linkToModule: core.linkToModule.bind(core),
|
|
464
|
+
getModuleData: core.getModuleData.bind(core),
|
|
465
|
+
getContext: core.getContext.bind(core),
|
|
466
|
+
getEnvData: core.getEnvData.bind(core),
|
|
456
467
|
apiRequest: core.apiRequest.bind(core),
|
|
457
468
|
checkModule: core.checkModule.bind(core)
|
|
458
469
|
}
|
|
459
470
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
471
|
export default core
|
|
465
472
|
|
|
466
|
-
|
|
467
|
-
|
|
468
473
|
export {
|
|
469
474
|
Module
|
|
470
475
|
}
|