@smart100/spu-web-plugin 0.0.1
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/spu-web-plugin.mjs +14 -0
- package/package.json +51 -0
- package/src/AMapLoader.ts +46 -0
- package/src/axios.ts +144 -0
- package/src/cloudServ.ts +121 -0
- package/src/index.ts +31 -0
- package/src/install.ts +88 -0
- package/src/loadding/img/loading.gif +0 -0
- package/src/loadding/index.ts +83 -0
- package/src/loadding/index.vue +43 -0
- package/src/location.ts +187 -0
- package/src/login.ts +248 -0
- package/src/oss/downloadService.ts +192 -0
- package/src/oss/index.ts +8 -0
- package/src/oss/multiUpload.ts +129 -0
- package/src/oss/servtoken.ts +131 -0
- package/src/oss/uploadService.ts +145 -0
- package/src/package/ali-oss/aliyun-oss-sdk.apaas.js +25198 -0
- package/src/package/ali-oss/aliyun-oss-sdk.apaas.min.js +15 -0
- package/src/package/ali-oss/aliyun-oss-sdk.js +25168 -0
- package/src/package/ali-oss/aliyun-oss-sdk.min.js +14 -0
- package/src/package/ali-oss/package.json +162 -0
- package/src/package/huaweicloud-obs/esdk-obs-browserjs-without-polyfill.3.22.3.min.js +2 -0
- package/src/package/huaweicloud-obs/esdk-obs-browserjs.3.22.3.min.js +2 -0
- package/src/package/huaweicloud-obs/package.json +28 -0
- package/src/storageProxy.ts +47 -0
- package/src/tenantInfo.ts +76 -0
- package/src/types/index.d.ts +84 -0
- package/src/types/shims-lib.d.ts +37 -0
- package/src/urlquery.ts +53 -0
- package/src/utils.ts +20 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "esdk-obs-browserjs",
|
|
3
|
+
"version": "3.22.3",
|
|
4
|
+
"description": "esdk-obs-browserjs",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=0.12.7"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "webpack"
|
|
11
|
+
},
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"axios": "^0.26.1",
|
|
15
|
+
"blueimp-md5": "^2.18.0",
|
|
16
|
+
"js-base64": "^3.7.1",
|
|
17
|
+
"jssha": "^3.2.0",
|
|
18
|
+
"urijs": "^1.19.7"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/core": "^7.15.5",
|
|
22
|
+
"@babel/polyfill": "^7.12.1",
|
|
23
|
+
"@babel/preset-env": "^7.15.6",
|
|
24
|
+
"babel-loader": "^8.2.2",
|
|
25
|
+
"webpack": "^5.52.1",
|
|
26
|
+
"webpack-cli": "^4.8.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
let STORAGENAMESPACE = ''
|
|
2
|
+
|
|
3
|
+
class StorageProxy {
|
|
4
|
+
constructor (StorageType: 'local' | 'session' = 'local') {
|
|
5
|
+
this.provider = window[`${StorageType}Storage`]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
provider
|
|
9
|
+
|
|
10
|
+
getItem (key: string) {
|
|
11
|
+
return this.provider.getItem(`${STORAGENAMESPACE ? STORAGENAMESPACE + '-' + key : key}`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setItem (key: string, value: string) {
|
|
15
|
+
return this.provider.setItem(`${STORAGENAMESPACE ? STORAGENAMESPACE + '-' + key : key}`, value)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
removeItem (key: string) {
|
|
19
|
+
return this.provider.removeItem(`${STORAGENAMESPACE ? STORAGENAMESPACE + '-' + key : key}`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
clear () {
|
|
23
|
+
const namespaceKeys = []
|
|
24
|
+
for (let i = 0, len = this.provider.length; i < len; i++) {
|
|
25
|
+
const item: string | null = this.provider.key(i)
|
|
26
|
+
if (item && item.indexOf(`${STORAGENAMESPACE}-`) === 0) {
|
|
27
|
+
namespaceKeys.push(item)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
namespaceKeys.forEach((item) => {
|
|
31
|
+
this.removeItem(item)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const lsProxy: StorageProxy = new StorageProxy('local')
|
|
37
|
+
const ssProxy: StorageProxy = new StorageProxy('session')
|
|
38
|
+
|
|
39
|
+
function initStorageProxy (options: SPUWebPluginOptions) {
|
|
40
|
+
STORAGENAMESPACE = options.modulekey
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
initStorageProxy,
|
|
45
|
+
lsProxy,
|
|
46
|
+
ssProxy
|
|
47
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { apaasAxios } from './axios'
|
|
2
|
+
import cloudServ from './cloudServ'
|
|
3
|
+
import { lsProxy } from './storageProxy'
|
|
4
|
+
|
|
5
|
+
class TenantInfo {
|
|
6
|
+
async get (tenantCode?: string) {
|
|
7
|
+
try {
|
|
8
|
+
const tenants: null | ITenantInfo[] = await apaasAxios.get('/api/auth/tenantlist', {}).then((res: any) => {
|
|
9
|
+
// debugger
|
|
10
|
+
return res?.data?.tenants
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
// debugger
|
|
14
|
+
|
|
15
|
+
if (tenants && tenants.length) {
|
|
16
|
+
if (!tenantCode) {
|
|
17
|
+
return tenants[0]
|
|
18
|
+
} else {
|
|
19
|
+
const res =
|
|
20
|
+
tenants.find((item) => {
|
|
21
|
+
return item.code === tenantCode
|
|
22
|
+
}) || null
|
|
23
|
+
return res
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw new Error((e as any).errorMsg)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
save (tenant: NormalizedCloudServ) {
|
|
34
|
+
if (!tenant) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
cloudServ.set(tenant)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
format (tenant: ITenantInfo) {
|
|
41
|
+
if (!tenant) {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
const cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m']
|
|
45
|
+
const result: NormalizedCloudServ = {}
|
|
46
|
+
for (const keyItem of cloundTagMap) {
|
|
47
|
+
const cloudServ = tenant.cloudserv[keyItem as StorageEnum]
|
|
48
|
+
if (cloudServ) {
|
|
49
|
+
result[keyItem as StorageEnum] = {
|
|
50
|
+
cloudserv_storage_provider: cloudServ.provider,
|
|
51
|
+
cloudserv_storage_storagebucket: cloudServ.storagebucket,
|
|
52
|
+
cloudserv_storage_storageendpoint: cloudServ.storageendpoint,
|
|
53
|
+
cloudserv_storage_storageurl: cloudServ.storageurl,
|
|
54
|
+
cloudserv_storage_accesskeyid: cloudServ.accesskeyid,
|
|
55
|
+
cloudserv_storage_region: cloudServ.region
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (Object.keys(result).length === 0) {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
return result
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getAndSave (tenantCode?: string) {
|
|
66
|
+
const tenant: ITenantInfo | null = await this.get(tenantCode)
|
|
67
|
+
if (!tenant) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
lsProxy.setItem('tenant', JSON.stringify(tenant))
|
|
71
|
+
const normalizedTenant = this.format(tenant)
|
|
72
|
+
normalizedTenant && this.save(normalizedTenant)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default new TenantInfo()
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
interface IAny {
|
|
2
|
+
[param: string]: any
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
// // 任意函数对象
|
|
6
|
+
// interface IFunction {
|
|
7
|
+
// [propName: string]: function
|
|
8
|
+
// }
|
|
9
|
+
|
|
10
|
+
// // 提取对象内任意属性,并指向一个字符串,用于别名对象
|
|
11
|
+
// type AliasPicker<S extends IAny> = {
|
|
12
|
+
// [propName in keyof S]?: string
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
interface SPUWebPluginOptions {
|
|
18
|
+
modulekey: string;
|
|
19
|
+
modulename: string;
|
|
20
|
+
moduleversion: string;
|
|
21
|
+
router: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type StorageType = 'storage' | 'storage-1d' | 'storage-3m' | 'storage-1y'
|
|
25
|
+
|
|
26
|
+
enum StorageEnum {
|
|
27
|
+
Storage = 'storage',
|
|
28
|
+
Storage1d = 'storage-1d',
|
|
29
|
+
Storage3m = 'storage-3m',
|
|
30
|
+
Storage1y = 'storage-1y'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface NormalizedCloudServItem {
|
|
34
|
+
cloudserv_storage_provider: string
|
|
35
|
+
cloudserv_storage_storagebucket: string
|
|
36
|
+
cloudserv_storage_storageendpoint: string
|
|
37
|
+
cloudserv_storage_storageurl: string
|
|
38
|
+
cloudserv_storage_accesskeyid?: string
|
|
39
|
+
cloudserv_storage_region?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type NormalizedCloudServ = {
|
|
43
|
+
[key in StorageEnum]?: NormalizedCloudServItem
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface IStorage {
|
|
47
|
+
provider: string
|
|
48
|
+
storagebucket: string
|
|
49
|
+
storageendpoint: string
|
|
50
|
+
storageurl: string
|
|
51
|
+
accesskeyid: string
|
|
52
|
+
region: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type ICloudServ = {
|
|
56
|
+
[key in StorageEnum]: IStorage
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface IProductVersion {
|
|
60
|
+
code: string
|
|
61
|
+
name: string
|
|
62
|
+
productcode: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface ITenantInfo {
|
|
66
|
+
accountcode: string
|
|
67
|
+
code: string
|
|
68
|
+
metatype: string
|
|
69
|
+
name: string
|
|
70
|
+
cloudserv: ICloudServ
|
|
71
|
+
productversionlist: IProductVersion[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare module '*.vue' {
|
|
2
|
+
import type { DefineComponent } from 'vue'
|
|
3
|
+
const component: DefineComponent<{}, {}, any>
|
|
4
|
+
export default component
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare module 'co'
|
|
8
|
+
declare module 'uuid'
|
|
9
|
+
|
|
10
|
+
// declare module 'the-answer'
|
|
11
|
+
|
|
12
|
+
interface Window {
|
|
13
|
+
_AMapSecurityConfig: {
|
|
14
|
+
securityJsCode: string
|
|
15
|
+
}
|
|
16
|
+
// Native Module aPaaS 为 G3 SPU 容器注入的 Native-API
|
|
17
|
+
Native: any
|
|
18
|
+
// wx: IAny;
|
|
19
|
+
// AMapUI: IAny;
|
|
20
|
+
// lsProxy: any;
|
|
21
|
+
// ssProxy: any;
|
|
22
|
+
// xtion: any;
|
|
23
|
+
// Module: IAny;
|
|
24
|
+
// aPaaS: IAny;
|
|
25
|
+
// // eslint-disable-next-line camelcase
|
|
26
|
+
// __wxjs_environment: string;
|
|
27
|
+
// // eslint-disable-next-line camelcase
|
|
28
|
+
// smart100_h5_set_isshowhead: IFunction;
|
|
29
|
+
// // eslint-disable-next-line camelcase
|
|
30
|
+
// smart100_h5_set_isdebugger: IFunction;
|
|
31
|
+
// // eslint-disable-next-line camelcase
|
|
32
|
+
// smart100_h5_set_ispermission: IFunction;
|
|
33
|
+
// // eslint-disable-next-line camelcase
|
|
34
|
+
// smart100_h5_set_isvirtuallocation: IFunction;
|
|
35
|
+
// // eslint-disable-next-line camelcase
|
|
36
|
+
// smart100_h5_set_whennotloggedisautojumplogin: IFunction;
|
|
37
|
+
}
|
package/src/urlquery.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import VConsole from 'vconsole'
|
|
2
|
+
import { ssProxy } from './storageProxy'
|
|
3
|
+
|
|
4
|
+
class Urlquery {
|
|
5
|
+
private isinit = false
|
|
6
|
+
|
|
7
|
+
get isvirtuallocation (): boolean {
|
|
8
|
+
return ssProxy.getItem('isvirtuallocation') === '1'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public init () {
|
|
12
|
+
if (this.isinit) return false
|
|
13
|
+
|
|
14
|
+
this.isinit = true
|
|
15
|
+
|
|
16
|
+
// 调试
|
|
17
|
+
if (location.href.indexOf('isdebugger=1') >= 0 || ssProxy.getItem('isdebugger') === '1') {
|
|
18
|
+
ssProxy.setItem('isdebugger', '1')
|
|
19
|
+
new VConsole({ theme: 'dark' }) /* eslint-disable-line no-new */
|
|
20
|
+
} else {
|
|
21
|
+
ssProxy.setItem('isdebugger', '0')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 虚拟定位测试
|
|
25
|
+
if (location.href.indexOf('isvirtuallocation=1') >= 0 || ssProxy.getItem('isvirtuallocation') === '1') {
|
|
26
|
+
ssProxy.setItem('isvirtuallocation', '1')
|
|
27
|
+
} else {
|
|
28
|
+
ssProxy.setItem('isvirtuallocation', '0')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// this.initDevTool()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// private initDevTool () {
|
|
35
|
+
// window.smart100_h5_set_isdebugger = (value = '1') => {
|
|
36
|
+
// ssProxy.setItem('isdebugger', value)
|
|
37
|
+
// }
|
|
38
|
+
// window.smart100_h5_set_isshowhead = (value = '0') => {
|
|
39
|
+
// ssProxy.setItem('isshowhead', value)
|
|
40
|
+
// }
|
|
41
|
+
// window.smart100_h5_set_ispermission = (value = '1') => {
|
|
42
|
+
// ssProxy.setItem('ispermission', value)
|
|
43
|
+
// }
|
|
44
|
+
// window.smart100_h5_set_isvirtuallocation = (value = '1') => {
|
|
45
|
+
// ssProxy.setItem('isvirtuallocation', value)
|
|
46
|
+
// }
|
|
47
|
+
// window.smart100_h5_set_whennotloggedisautojumplogin = (value = '0') => {
|
|
48
|
+
// ssProxy.setItem('whennotloggedisautojumplogin', value)
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default new Urlquery()
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 是否企微软件内 包括电脑端和APP端
|
|
2
|
+
const isInWxwork = () => {
|
|
3
|
+
return navigator.userAgent.indexOf('wxwork') >= 0
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// 是否在电脑端企微软件内
|
|
7
|
+
const isInPcWxwork = () => {
|
|
8
|
+
return isInWxwork() && navigator.userAgent.indexOf('Mobile') === -1
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 是否在企微APP内
|
|
12
|
+
const isInAppWxwork = () => {
|
|
13
|
+
return isInWxwork() && navigator.userAgent.indexOf('Mobile') >= 0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
isInWxwork,
|
|
18
|
+
isInPcWxwork,
|
|
19
|
+
isInAppWxwork
|
|
20
|
+
}
|