@smart100/spu-web-plugin 0.0.23 → 0.0.25

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/src/tenantInfo.ts DELETED
@@ -1,74 +0,0 @@
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
- format (tenant: ITenantInfo) {
34
- if (!tenant) {
35
- return null
36
- }
37
- const cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m']
38
- const result: NormalizedCloudServ = {}
39
- for (const keyItem of cloundTagMap) {
40
- const cloudServ = tenant.cloudserv[keyItem as StorageEnum]
41
- if (cloudServ) {
42
- result[keyItem as StorageEnum] = {
43
- cloudserv_storage_provider: cloudServ.provider,
44
- cloudserv_storage_storagebucket: cloudServ.storagebucket,
45
- cloudserv_storage_storageendpoint: cloudServ.storageendpoint,
46
- cloudserv_storage_storageurl: cloudServ.storageurl,
47
- cloudserv_storage_accesskeyid: cloudServ.accesskeyid,
48
- cloudserv_storage_region: cloudServ.region
49
- }
50
- }
51
- }
52
- if (Object.keys(result).length === 0) {
53
- return null
54
- }
55
- return result
56
- }
57
-
58
- async getAndSave (tenantCode?: string) {
59
- const tenant: ITenantInfo | null = await this.get(tenantCode)
60
- if (!tenant) {
61
- lsProxy.removeItem('tenant')
62
- cloudServ.remove()
63
- return
64
- }
65
-
66
- lsProxy.setItem('tenant', JSON.stringify(tenant))
67
- const normalizedTenant = this.format(tenant)
68
- if (normalizedTenant) {
69
- cloudServ.set(normalizedTenant)
70
- }
71
- }
72
- }
73
-
74
- export default new TenantInfo()