@indfnd/utils 0.1.32 → 0.1.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indfnd/utils",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "author": "huxuetong",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,12 +1,21 @@
1
1
  import { axios } from '@/utils'
2
2
  import { config } from '@/config'
3
3
  import { getLocalStorage, setLocalStorage } from '@/utils/storage'
4
+ import { getUserInfoCache } from '@/utils/cache'
5
+ import { getGlobalConfig } from '@/api/platform/config.js'
4
6
 
5
7
  const UC_CONTEXT = config.ucExtServerContext
6
8
 
7
- const DATAVERSION_KEY = 'ind-cache-dataVersion-applicationTree'
8
-
9
+ // TODO 调用platform的getGlobalConfig,如果未开启前端缓存enableTreeLocalCache == '1',改为原始逻辑
9
10
  export async function getApplicationTreeApi(params) {
11
+ const DATAVERSION_KEY = 'ind-cache-dataVersion-applicationTree' + getUserInfoCache()?.manageUnitId
12
+ //0.读取全局配置,是否使用缓存
13
+ const globalConfigData = await getGlobalConfig()
14
+ if (!globalConfigData?.enableTreeLocalCache || globalConfigData?.enableTreeLocalCache !== '1') {
15
+ return axios.formPost(`${UC_CONTEXT}/tree/uc-application/getApplicationTree`, {
16
+ params,
17
+ })
18
+ }
10
19
  //1.读取缓存,获得版本号
11
20
  const cachedData = getLocalStorage(DATAVERSION_KEY)
12
21
 
@@ -0,0 +1,22 @@
1
+ // 使用原生的axios,避免拦截器报无会话
2
+ import axios from 'axios'
3
+ import { getSessionStorage, removeSessionStorage, setSessionStorage } from '@/utils/storage'
4
+
5
+ const GLOBAL_CACHE_KEY = 'global-cache'
6
+
7
+ /**
8
+ * 获取云庭配置的global配置文件,取到以后放到sessionStorage,避免重复请求
9
+ */
10
+ export const getGlobalConfig = async () => {
11
+ if (getSessionStorage(GLOBAL_CACHE_KEY)) {
12
+ return getSessionStorage(GLOBAL_CACHE_KEY)
13
+ } else {
14
+ // 加载global配置,当前只有系统配置,组件配置没在内
15
+ let url =
16
+ location.protocol + '//' + location.host + '/ibp-sc/manage/global?t=' + new Date().getTime()
17
+ return axios.get(url).then(({ data }) => {
18
+ setSessionStorage(GLOBAL_CACHE_KEY, data)
19
+ return data
20
+ })
21
+ }
22
+ }
@@ -2,3 +2,4 @@ export * from './dict'
2
2
  export * from './menu'
3
3
  export * from './oss'
4
4
  export * from './user'
5
+ export * from './config.js'
package/src/api/user.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  import { axios } from '@/utils'
2
2
  import { config } from '@/config'
3
3
  import { getLocalStorage, setLocalStorage } from '@/utils/storage'
4
+ import { getUserInfoCache } from '@/utils/cache'
5
+ import { getGlobalConfig } from '@/api/platform/config.js'
4
6
 
5
7
  const UC_CONTEXT = config.ucExtServerContext
6
8
 
7
- const DATAVERSION_KEY = 'ind-cache-dataVersion-organTree'
8
-
9
9
  export async function listUserTreeApi(params) {
10
+ const DATAVERSION_KEY = 'ind-cache-dataVersion-organTree' + getUserInfoCache()?.manageUnitId
11
+
12
+ //0.读取全局配置,是否使用缓存
13
+ const globalConfigData = await getGlobalConfig()
14
+ if (!globalConfigData?.enableTreeLocalCache || globalConfigData?.enableTreeLocalCache !== '1') {
15
+ return axios.get(`${UC_CONTEXT}/tree/uc-user/listUserTree`, { params })
16
+ }
10
17
  //1.读取缓存,获得版本号
11
18
  const cachedData = getLocalStorage(DATAVERSION_KEY)
12
19
 
@@ -1,2 +1,4 @@
1
- export declare function listComTreeApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
2
- //# sourceMappingURL=com.d.ts.map
1
+ export declare function listComTreeApi(
2
+ params: any,
3
+ ): Promise<import('axios').AxiosResponse<any, any>>
4
+ //# sourceMappingURL=com.d.ts.map
@@ -1,2 +1,4 @@
1
- export declare function listIndexDescApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
2
- //# sourceMappingURL=index-desc.d.ts.map
1
+ export declare function listIndexDescApi(
2
+ params: any,
3
+ ): Promise<import('axios').AxiosResponse<any, any>>
4
+ //# sourceMappingURL=index-desc.d.ts.map
@@ -1,7 +1,7 @@
1
- export * from './platform'
2
- export * from './com'
3
- export * from './index-desc'
4
- export * from './item'
5
- export * from './permission'
6
- export * from './user'
7
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './platform';
2
+ export * from './com';
3
+ export * from './index-desc';
4
+ export * from './item';
5
+ export * from './permission';
6
+ export * from './user';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,6 @@
1
- export declare function listItemTreeApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
2
- export declare function getPriceInfo(): Promise<import("axios").AxiosResponse<any, any>>;
3
- export declare function getItem(params: any): Promise<import("axios").AxiosResponse<any, any>>;
4
- //# sourceMappingURL=item.d.ts.map
1
+ export declare function listItemTreeApi(
2
+ params: any,
3
+ ): Promise<import('axios').AxiosResponse<any, any>>
4
+ export declare function getPriceInfo(): Promise<import('axios').AxiosResponse<any, any>>
5
+ export declare function getItem(params: any): Promise<import('axios').AxiosResponse<any, any>>
6
+ //# sourceMappingURL=item.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare function getApplicationTreeApi(params: any): Promise<any>
2
- //# sourceMappingURL=permission.d.ts.map
1
+ export declare function getApplicationTreeApi(params: any): Promise<any>;
2
+ //# sourceMappingURL=permission.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/api/permission.ts"],"names":[],"mappings":"AAQA,wBAAsB,qBAAqB,CAAC,MAAM,KAAA,gBAsBjD"}
1
+ {"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/api/permission.ts"],"names":[],"mappings":"AASA,wBAAsB,qBAAqB,CAAC,MAAM,KAAA,gBA8BjD"}
@@ -0,0 +1,2 @@
1
+ export function getGlobalConfig(): Promise<any>;
2
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/api/platform/config.js"],"names":[],"mappings":"AASO,gDAYN"}
@@ -1,4 +1,6 @@
1
- export declare function getDictsMapApi(dictId: string): Promise<import("axios").AxiosResponse<any, any>>;
2
- export declare function getDictApi(dictId: string): Promise<any>;
3
- export declare function getDictMapApi(dictIdArr: string[]): Promise<{}>;
4
- //# sourceMappingURL=dict.d.ts.map
1
+ export declare function getDictsMapApi(
2
+ dictId: string,
3
+ ): Promise<import('axios').AxiosResponse<any, any>>
4
+ export declare function getDictApi(dictId: string): Promise<any>
5
+ export declare function getDictMapApi(dictIdArr: string[]): Promise<{}>
6
+ //# sourceMappingURL=dict.d.ts.map
@@ -2,4 +2,5 @@ export * from './dict';
2
2
  export * from './menu';
3
3
  export * from './oss';
4
4
  export * from './user';
5
+ export * from './config.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA"}
@@ -1,11 +1,21 @@
1
- export declare function getPermissionApi(): Promise<import("axios").AxiosResponse<any, any>>;
2
- export declare function getMenuHistoryApi(): Promise<import("axios").AxiosResponse<any, any>>;
3
- export declare function menuHistoryApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
4
- export declare function deleteMenuHistoryApi(historyId: any): Promise<import("axios").AxiosResponse<any, any>>;
5
- export declare function getMenuCollectApi(): Promise<import("axios").AxiosResponse<any, any>>;
6
- export declare function addMenuCollectApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
7
- export declare function deleteMenuCollectApi(collectId: any): Promise<import("axios").AxiosResponse<any, any>>;
8
- export declare function removeMenuCollectApi(params: any): Promise<import("axios").AxiosResponse<any, any>>;
9
- export declare function getAppListApi(): Promise<import("axios").AxiosResponse<any, any>>;
10
- export declare function getMaxTabNumValueApi(): Promise<import("axios").AxiosResponse<any, any>>;
11
- //# sourceMappingURL=menu.d.ts.map
1
+ export declare function getPermissionApi(): Promise<import('axios').AxiosResponse<any, any>>
2
+ export declare function getMenuHistoryApi(): Promise<import('axios').AxiosResponse<any, any>>
3
+ export declare function menuHistoryApi(
4
+ params: any,
5
+ ): Promise<import('axios').AxiosResponse<any, any>>
6
+ export declare function deleteMenuHistoryApi(
7
+ historyId: any,
8
+ ): Promise<import('axios').AxiosResponse<any, any>>
9
+ export declare function getMenuCollectApi(): Promise<import('axios').AxiosResponse<any, any>>
10
+ export declare function addMenuCollectApi(
11
+ params: any,
12
+ ): Promise<import('axios').AxiosResponse<any, any>>
13
+ export declare function deleteMenuCollectApi(
14
+ collectId: any,
15
+ ): Promise<import('axios').AxiosResponse<any, any>>
16
+ export declare function removeMenuCollectApi(
17
+ params: any,
18
+ ): Promise<import('axios').AxiosResponse<any, any>>
19
+ export declare function getAppListApi(): Promise<import('axios').AxiosResponse<any, any>>
20
+ export declare function getMaxTabNumValueApi(): Promise<import('axios').AxiosResponse<any, any>>
21
+ //# sourceMappingURL=menu.d.ts.map
@@ -1,17 +1,17 @@
1
- import { ResponseType } from 'axios';
1
+ import { ResponseType } from 'axios'
2
2
  /**
3
3
  * 文档中心下载文件的url,主要用于图片等直接写在 href 里
4
4
  *
5
5
  * @param fileId 文件Id
6
6
  * @returns url
7
7
  */
8
- export declare function getOssFileUrl(fileId?: string): string;
8
+ export declare function getOssFileUrl(fileId?: string): string
9
9
  /**
10
10
  * 文档中心上传文件的url
11
11
  *
12
12
  * @returns url
13
13
  */
14
- export declare function putOssFileUrl(): string;
14
+ export declare function putOssFileUrl(): string
15
15
  /**
16
16
  * 获取文档中心文件
17
17
  *
@@ -19,7 +19,10 @@ export declare function putOssFileUrl(): string;
19
19
  * @param responseType 数据类型,支持 arraybuffer | blob | document | json | text | stream
20
20
  * @returns 文件内容
21
21
  */
22
- export declare function getOssFileApi(fileId: string, responseType?: ResponseType): Promise<import("axios").AxiosResponse<any, any>>;
22
+ export declare function getOssFileApi(
23
+ fileId: string,
24
+ responseType?: ResponseType,
25
+ ): Promise<import('axios').AxiosResponse<any, any>>
23
26
  /**
24
27
  * 将文件上传到文档中心
25
28
  *
@@ -27,12 +30,17 @@ export declare function getOssFileApi(fileId: string, responseType?: ResponseTyp
27
30
  * @param blob 文件的Blob数据
28
31
  * @returns 文件Id
29
32
  */
30
- export declare function putOssFileApi(filename: string, blob: Blob): import("axios").AxiosPromise<any>;
33
+ export declare function putOssFileApi(
34
+ filename: string,
35
+ blob: Blob,
36
+ ): import('axios').AxiosPromise<any>
31
37
  /**
32
38
  * 获取文档中心预览URL
33
39
  *
34
40
  * @param fileId 文件Id
35
41
  * @returns 文件内容
36
42
  */
37
- export declare function getPreviewUrlApi(fileId: string): Promise<import("axios").AxiosResponse<any, any>>;
38
- //# sourceMappingURL=oss.d.ts.map
43
+ export declare function getPreviewUrlApi(
44
+ fileId: string,
45
+ ): Promise<import('axios').AxiosResponse<any, any>>
46
+ //# sourceMappingURL=oss.d.ts.map
@@ -1,12 +1,19 @@
1
- export declare function loginApi({ userName, password, validCodeId, validCodeInput }: {
2
- userName: any;
3
- password: any;
4
- validCodeId: any;
5
- validCodeInput: any;
6
- }): Promise<import("axios").AxiosResponse<any, any>>;
7
- export declare function getUserInfoApi(): Promise<import("axios").AxiosResponse<any, any>>;
8
- export declare function getGlobalPolicyApi(): Promise<import("axios").AxiosResponse<any, any>>;
9
- export declare function updatePasswordApi(data: any): Promise<import("axios").AxiosResponse<any, any>>;
10
- export declare function getCaptchaURL(validCodeId: string): string;
11
- export declare function logoutApi(): Promise<import("axios").AxiosResponse<any, any>>;
12
- //# sourceMappingURL=user.d.ts.map
1
+ export declare function loginApi({
2
+ userName,
3
+ password,
4
+ validCodeId,
5
+ validCodeInput,
6
+ }: {
7
+ userName: any
8
+ password: any
9
+ validCodeId: any
10
+ validCodeInput: any
11
+ }): Promise<import('axios').AxiosResponse<any, any>>
12
+ export declare function getUserInfoApi(): Promise<import('axios').AxiosResponse<any, any>>
13
+ export declare function getGlobalPolicyApi(): Promise<import('axios').AxiosResponse<any, any>>
14
+ export declare function updatePasswordApi(
15
+ data: any,
16
+ ): Promise<import('axios').AxiosResponse<any, any>>
17
+ export declare function getCaptchaURL(validCodeId: string): string
18
+ export declare function logoutApi(): Promise<import('axios').AxiosResponse<any, any>>
19
+ //# sourceMappingURL=user.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare function listUserTreeApi(params: any): Promise<any>
2
- //# sourceMappingURL=user.d.ts.map
1
+ export declare function listUserTreeApi(params: any): Promise<any>;
2
+ //# sourceMappingURL=user.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/api/user.ts"],"names":[],"mappings":"AAQA,wBAAsB,eAAe,CAAC,MAAM,KAAA,gBAoB3C"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/api/user.ts"],"names":[],"mappings":"AAQA,wBAAsB,eAAe,CAAC,MAAM,KAAA,gBA2B3C"}