@smart100/spu-web-plugin 0.0.5 → 0.0.7
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/README.md +2 -0
- package/dist/index.d.ts +4 -2
- package/dist/spu-web-plugin.mjs +3 -3
- package/package.json +2 -2
- package/src/index.ts +4 -2
- package/src/install.ts +2 -0
- package/src/spuConfig.ts +97 -0
- package/src/types/index.d.ts +0 -95
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart100/spu-web-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "rollup -c -w",
|
|
7
7
|
"build": "rollup -c && npm run build:types",
|
|
8
8
|
"build:types": "node script/build-types.js"
|
|
9
9
|
},
|
|
10
|
-
"author": "tarymee",
|
|
10
|
+
"author": "tarymee <tarymee@qq.com>",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"browser1": "dist/spu-web-plugin.umd.js",
|
|
13
13
|
"main1": "dist/spu-web-plugin.cjs",
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,12 @@ import { install } from './install'
|
|
|
3
3
|
import { lsProxy, ssProxy } from './storageProxy'
|
|
4
4
|
import { getLocation, getDistance } from './location'
|
|
5
5
|
import { spuAxios, apaasAxios } from './axios'
|
|
6
|
+
import { spuConfig } from './spuConfig'
|
|
6
7
|
import { downloadService, uploadService } from './oss'
|
|
7
8
|
import { getUniqueid } from './utils'
|
|
8
9
|
import AMapLoader from './AMapLoader'
|
|
9
10
|
import login from './login'
|
|
10
|
-
import { v4 as
|
|
11
|
+
import { v4 as getUuid } from 'uuid'
|
|
11
12
|
// import { downloadService } from './oss'
|
|
12
13
|
|
|
13
14
|
// class SPUWebPlugin {
|
|
@@ -38,10 +39,11 @@ export {
|
|
|
38
39
|
getDistance,
|
|
39
40
|
spuAxios,
|
|
40
41
|
apaasAxios,
|
|
42
|
+
spuConfig,
|
|
41
43
|
downloadService,
|
|
42
44
|
uploadService,
|
|
43
45
|
getUniqueid,
|
|
44
|
-
|
|
46
|
+
getUuid,
|
|
45
47
|
AMapLoader,
|
|
46
48
|
getToken,
|
|
47
49
|
getTokenExpires,
|
package/src/install.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { initStorageProxy } from './storageProxy'
|
|
|
2
2
|
import login from './login'
|
|
3
3
|
import { initAxios } from './axios'
|
|
4
4
|
import urlquery from './urlquery'
|
|
5
|
+
import { initSpuConfig } from './spuConfig'
|
|
5
6
|
// import tenantInfo from './tenantInfo'
|
|
6
7
|
// import { downloadService } from './oss'
|
|
7
8
|
|
|
@@ -22,6 +23,7 @@ const install = (app: any, options: SPUWebPluginOptions) => {
|
|
|
22
23
|
|
|
23
24
|
initStorageProxy(options)
|
|
24
25
|
initAxios(options)
|
|
26
|
+
initSpuConfig(options)
|
|
25
27
|
urlquery.init()
|
|
26
28
|
login.startRefreshtoken()
|
|
27
29
|
|
package/src/spuConfig.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { spuAxios } from './axios'
|
|
2
|
+
import { cloneDeep } from 'lodash-es'
|
|
3
|
+
|
|
4
|
+
let modulekey = ''
|
|
5
|
+
|
|
6
|
+
class SpuConfig {
|
|
7
|
+
private isload = false
|
|
8
|
+
|
|
9
|
+
cache: any[] = []
|
|
10
|
+
|
|
11
|
+
public async get (dataid?: string | string[]): Promise<any> {
|
|
12
|
+
if (!this.isload) {
|
|
13
|
+
try {
|
|
14
|
+
const res = await spuAxios.post('/lifecycle/getconfigdata', {
|
|
15
|
+
// modulekey: 'litheformspu'
|
|
16
|
+
modulekey: modulekey
|
|
17
|
+
})
|
|
18
|
+
// console.log(res)
|
|
19
|
+
// debugger
|
|
20
|
+
if (res.code === 200) {
|
|
21
|
+
this.cache = res?.data?.configs || []
|
|
22
|
+
}
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(err)
|
|
25
|
+
}
|
|
26
|
+
this.isload = true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (dataid) {
|
|
30
|
+
if (Array.isArray(dataid)) {
|
|
31
|
+
return cloneDeep(this.cache.filter((item: any) => (dataid.some((item2) => item2 === item.dataid))))
|
|
32
|
+
} else {
|
|
33
|
+
return cloneDeep(this.cache.find((item: any) => item.dataid === dataid))
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
return cloneDeep(this.cache)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// public async set (configs: any[]) {
|
|
41
|
+
// let isSaveSuccess = false
|
|
42
|
+
|
|
43
|
+
// configs.forEach((item: any) => {
|
|
44
|
+
// const index = this.cache.findIndex((item1: any) => item1.dataid === item.dataid)
|
|
45
|
+
// if (index >= 0) {
|
|
46
|
+
// this.cache[index] = item
|
|
47
|
+
// } else {
|
|
48
|
+
// this.cache.push(item)
|
|
49
|
+
// }
|
|
50
|
+
// })
|
|
51
|
+
|
|
52
|
+
// try {
|
|
53
|
+
// const initconfigRes = await spuAxios.post('/lifecycle/initconfig', {
|
|
54
|
+
// context: {
|
|
55
|
+
// // envid: selectEnv.conn.envid,
|
|
56
|
+
// // envname: selectEnv.conn.name,
|
|
57
|
+
// // tenantcode: tenantData.tenantcode,
|
|
58
|
+
// // modulecode: moduleData.modulecode,
|
|
59
|
+
// // modulekey: moduleData.modulekey,
|
|
60
|
+
// // modulename: moduleData.modulename,
|
|
61
|
+
// // versioncode: versionData.versioncode,
|
|
62
|
+
// // versionnum: versionData.versionnum,
|
|
63
|
+
// // serviceversion: ''
|
|
64
|
+
// },
|
|
65
|
+
// configs: this.cache,
|
|
66
|
+
// extend: {}
|
|
67
|
+
// })
|
|
68
|
+
// if (initconfigRes.code === 200) {
|
|
69
|
+
// const logRes = await spuAxios.post('/api/smartcenter/tenantModule/saveOpLog', {
|
|
70
|
+
// // envid: selectEnv.conn.envid,
|
|
71
|
+
// // tenantcode: tenantData.tenantcode,
|
|
72
|
+
// // versioncode: versionData.versioncode,
|
|
73
|
+
// // modulecode: moduleData.modulecode,
|
|
74
|
+
// logdatas: initconfigRes.data.logdatas,
|
|
75
|
+
// serviceversion: initconfigRes.data.serviceversion
|
|
76
|
+
// })
|
|
77
|
+
// if (logRes.code === 200) {
|
|
78
|
+
// isSaveSuccess = true
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// } catch (err) {
|
|
82
|
+
// console.error(err)
|
|
83
|
+
// }
|
|
84
|
+
// return isSaveSuccess
|
|
85
|
+
// }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function initSpuConfig (options: SPUWebPluginOptions) {
|
|
89
|
+
modulekey = options.modulekey
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const spuConfig = new SpuConfig()
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
initSpuConfig,
|
|
96
|
+
spuConfig
|
|
97
|
+
}
|
package/src/types/index.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue'
|
|
2
|
-
// import type { AxiosInstance } from 'axios'
|
|
3
|
-
|
|
4
|
-
interface ISPUWebPluginOptions {
|
|
5
|
-
modulekey: string
|
|
6
|
-
modulename: string
|
|
7
|
-
moduleversion: string
|
|
8
|
-
router: any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface IAMapLoader {
|
|
12
|
-
load: (options?: {
|
|
13
|
-
plugins?: Array<string>
|
|
14
|
-
AMapUI?: {
|
|
15
|
-
plugins?: Array<string>
|
|
16
|
-
}
|
|
17
|
-
}) => Promise<any>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type Cope = { width?: number, height?: number } | string | boolean
|
|
22
|
-
|
|
23
|
-
interface IDownload {
|
|
24
|
-
type?: 'att' | 'img',
|
|
25
|
-
source: string,
|
|
26
|
-
datetime: string | number,
|
|
27
|
-
storagetype?: StorageType,
|
|
28
|
-
cope?: Cope
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface IDownloadService {
|
|
32
|
-
getUrl: ({
|
|
33
|
-
type = 'img',
|
|
34
|
-
source = '',
|
|
35
|
-
datetime = '',
|
|
36
|
-
storagetype = 'storage',
|
|
37
|
-
cope = ''
|
|
38
|
-
}: IDownload) => Promise<any>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
interface IUpload {
|
|
43
|
-
type?: 'att' | 'img',
|
|
44
|
-
file: File,
|
|
45
|
-
source?: string,
|
|
46
|
-
datetime?: string | number,
|
|
47
|
-
storagetype?: StorageType,
|
|
48
|
-
onprogress?: (p: number, _checkpoint?: IAny) => void
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface IUploadService {
|
|
52
|
-
upload: ({
|
|
53
|
-
type = 'img',
|
|
54
|
-
file,
|
|
55
|
-
source = '',
|
|
56
|
-
datetime = '',
|
|
57
|
-
storagetype = 'storage',
|
|
58
|
-
onprogress,
|
|
59
|
-
}: IUpload) => Promise<any>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type Location = {
|
|
64
|
-
longitude: string
|
|
65
|
-
latitude: string
|
|
66
|
-
address: string
|
|
67
|
-
[propName: string]: any
|
|
68
|
-
} | null
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export const lsProxy: any
|
|
72
|
-
export const ssProxy: any
|
|
73
|
-
export const getLocation: () => Promise<Location>
|
|
74
|
-
export const getDistance: (p1: [number, number], p2: [number, number]) => Promise<any>
|
|
75
|
-
export const spuAxios: any
|
|
76
|
-
// export const spuAxios: AxiosInstance
|
|
77
|
-
export const apaasAxios: any
|
|
78
|
-
export const downloadService: IDownloadService
|
|
79
|
-
export const uploadService: IUploadService
|
|
80
|
-
export const getUniqueid: () => string
|
|
81
|
-
export const uuid: () => string
|
|
82
|
-
export const AMapLoader: IAMapLoader
|
|
83
|
-
export const getToken: () => string
|
|
84
|
-
export const getTokenExpires: () => string
|
|
85
|
-
export const getRefreshToken: () => string
|
|
86
|
-
export const getUser: (key?: string) => any
|
|
87
|
-
export const checkLogin: () => boolean
|
|
88
|
-
|
|
89
|
-
interface ISPUWebPlugin {
|
|
90
|
-
install (app: App, option: ISPUWebPluginOptions): void
|
|
91
|
-
// install: any
|
|
92
|
-
version: string
|
|
93
|
-
}
|
|
94
|
-
declare const SPUWebPlugin: ISPUWebPlugin
|
|
95
|
-
export default SPUWebPlugin
|