@smart100/spu-web-plugin 0.0.19 → 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 +18625 -9338
- package/package.json +2 -1
- package/src/axios.ts +14 -1
- package/src/components/expandexp/template.ts +3 -2
- package/src/core.js +27 -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)
|
|
@@ -390,7 +390,7 @@ export default (ele: SpuExpandexp) => {
|
|
|
390
390
|
height: 30px;
|
|
391
391
|
line-height: 30px;
|
|
392
392
|
border: 1px solid #aaa;
|
|
393
|
-
background-color: #
|
|
393
|
+
background-color: #fff;
|
|
394
394
|
border-radius: 5px;
|
|
395
395
|
color: #444;
|
|
396
396
|
padding: 0 12px;
|
|
@@ -398,8 +398,9 @@ export default (ele: SpuExpandexp) => {
|
|
|
398
398
|
cursor: pointer;
|
|
399
399
|
}
|
|
400
400
|
.btn2:hover {
|
|
401
|
-
border-color: #
|
|
401
|
+
border-color: #ccc;
|
|
402
402
|
color: #777;
|
|
403
|
+
background-color: #fff;
|
|
403
404
|
}
|
|
404
405
|
</style>
|
|
405
406
|
|
package/src/core.js
CHANGED
|
@@ -183,6 +183,9 @@ class Core {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
async getModuleData (modulekey) {
|
|
186
|
+
if (!modulekey) {
|
|
187
|
+
modulekey = globalOptions.modulekey
|
|
188
|
+
}
|
|
186
189
|
const res = {
|
|
187
190
|
errorMsg: '',
|
|
188
191
|
data: null
|
|
@@ -208,6 +211,9 @@ class Core {
|
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
async getContext (modulekey) {
|
|
214
|
+
if (!modulekey) {
|
|
215
|
+
modulekey = globalOptions.modulekey
|
|
216
|
+
}
|
|
211
217
|
let context
|
|
212
218
|
const moduleData = await this.getModuleData(modulekey)
|
|
213
219
|
if (moduleData?.data) {
|
|
@@ -237,6 +243,9 @@ class Core {
|
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
async checkModule (modulekey) {
|
|
246
|
+
if (!modulekey) {
|
|
247
|
+
modulekey = globalOptions.modulekey
|
|
248
|
+
}
|
|
240
249
|
const moduleData = await this.getModuleData(modulekey)
|
|
241
250
|
return !!moduleData.data
|
|
242
251
|
}
|
|
@@ -365,21 +374,21 @@ class Core {
|
|
|
365
374
|
}
|
|
366
375
|
}
|
|
367
376
|
|
|
368
|
-
async getApiOrigin (modulekey) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
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
|
+
// }
|
|
383
392
|
|
|
384
393
|
|
|
385
394
|
// Module.apiRequest({
|
|
@@ -444,30 +453,23 @@ class Core {
|
|
|
444
453
|
}
|
|
445
454
|
}
|
|
446
455
|
|
|
447
|
-
|
|
448
456
|
const core = new Core()
|
|
449
457
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
458
|
const Module = {
|
|
454
459
|
// getContextSync () {
|
|
455
460
|
// return core.getContext(modulekey)
|
|
456
461
|
// },
|
|
457
462
|
// linkToPage: core.linkToPage.bind(core),
|
|
458
463
|
// linkToModule: core.linkToModule.bind(core),
|
|
464
|
+
getModuleData: core.getModuleData.bind(core),
|
|
465
|
+
getContext: core.getContext.bind(core),
|
|
466
|
+
getEnvData: core.getEnvData.bind(core),
|
|
459
467
|
apiRequest: core.apiRequest.bind(core),
|
|
460
468
|
checkModule: core.checkModule.bind(core)
|
|
461
469
|
}
|
|
462
470
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
471
|
export default core
|
|
468
472
|
|
|
469
|
-
|
|
470
|
-
|
|
471
473
|
export {
|
|
472
474
|
Module
|
|
473
475
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { v4 as getUuid } from 'uuid'
|
|
|
12
12
|
import { Module } from './core'
|
|
13
13
|
import components from './components'
|
|
14
14
|
import { expandexp } from './components/expandexp'
|
|
15
|
+
import { jssdk } from '@smart100/wxworksuite-plugin'
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
// class SPUWebPlugin {
|
|
@@ -31,6 +32,10 @@ const getTokenExpires = login.getTokenExpires.bind(login)
|
|
|
31
32
|
const getRefreshToken = login.getRefreshToken.bind(login)
|
|
32
33
|
const getUser = login.getUser.bind(login)
|
|
33
34
|
const checkLogin = login.checkLogin.bind(login)
|
|
35
|
+
const wxworkSuite = {
|
|
36
|
+
JSSDK: jssdk,
|
|
37
|
+
isWxworkSuiteTenant: jssdk.checkData
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
export {
|
|
36
41
|
SPUWebPlugin as default,
|
|
@@ -54,5 +59,6 @@ export {
|
|
|
54
59
|
checkLogin,
|
|
55
60
|
Module,
|
|
56
61
|
components,
|
|
57
|
-
expandexp
|
|
62
|
+
expandexp,
|
|
63
|
+
wxworkSuite
|
|
58
64
|
}
|
package/src/install.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { initAxios } from './axios'
|
|
|
4
4
|
import urlquery from './urlquery'
|
|
5
5
|
import { initSpuConfig } from './spuConfig'
|
|
6
6
|
import { initApaasSpuTrack } from './apaasSpuTrack'
|
|
7
|
+
import { WxworksuitePluginInstall } from '@smart100/wxworksuite-plugin'
|
|
7
8
|
import { merge } from 'lodash-es'
|
|
8
9
|
import { initTest } from './test'
|
|
9
10
|
|
|
@@ -42,6 +43,10 @@ const install = (app: any, options: SPUWebPluginOptions) => {
|
|
|
42
43
|
initApaasSpuTrack()
|
|
43
44
|
urlquery.init()
|
|
44
45
|
login.startRefreshtoken()
|
|
46
|
+
// 安装企微第三方应用插件
|
|
47
|
+
WxworksuitePluginInstall({
|
|
48
|
+
getToken: login.getToken.bind(login)
|
|
49
|
+
})
|
|
45
50
|
initTest(globalOptions)
|
|
46
51
|
|
|
47
52
|
if (globalOptions.router) {
|
package/src/types/shims-lib.d.ts
CHANGED
|
@@ -7,6 +7,15 @@ declare module '*.vue' {
|
|
|
7
7
|
declare module 'co'
|
|
8
8
|
declare module 'uuid'
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
declare module '*.svg'
|
|
12
|
+
declare module '*.png'
|
|
13
|
+
declare module '*.jpg'
|
|
14
|
+
declare module '*.jpeg'
|
|
15
|
+
declare module '*.gif'
|
|
16
|
+
// declare module '*.bmp'
|
|
17
|
+
// declare module '*.tiff'
|
|
18
|
+
|
|
10
19
|
// declare module 'the-answer'
|
|
11
20
|
|
|
12
21
|
interface Window {
|