@zat-design/sisyphus-react 3.13.4-beta.5 → 3.13.4-beta.6
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.
@@ -1,16 +1,8 @@
|
|
1
|
+
var _ref;
|
1
2
|
/* eslint-disable no-redeclare */
|
2
3
|
import { useProConfig } from '../../ProConfigProvider';
|
3
4
|
import { getEnumData } from '../utils';
|
4
|
-
var baseEnumStorage = null;
|
5
|
-
try {
|
6
|
-
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
7
|
-
if (storedData) {
|
8
|
-
baseEnumStorage = JSON.parse(storedData);
|
9
|
-
}
|
10
|
-
} catch (error) {
|
11
|
-
console.error('解析枚举缓存数据失败', error);
|
12
|
-
baseEnumStorage = null;
|
13
|
-
}
|
5
|
+
var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
|
14
6
|
/**
|
15
7
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
16
8
|
* @param codes
|
@@ -19,16 +11,16 @@ try {
|
|
19
11
|
* @returns
|
20
12
|
*/
|
21
13
|
function useEnum(codes, value, compose) {
|
22
|
-
var
|
23
|
-
|
24
|
-
storage =
|
25
|
-
var
|
26
|
-
|
27
|
-
cacheKey =
|
28
|
-
|
29
|
-
fieldNames =
|
30
|
-
|
31
|
-
clear =
|
14
|
+
var _ref2 = useProConfig('globalConfig') || {},
|
15
|
+
_ref2$storage = _ref2.storage,
|
16
|
+
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
|
17
|
+
var _ref3 = useProConfig('ProEnum') || {},
|
18
|
+
_ref3$cacheKey = _ref3.cacheKey,
|
19
|
+
cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
|
20
|
+
_ref3$fieldNames = _ref3.fieldNames,
|
21
|
+
fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
|
22
|
+
_ref3$clear = _ref3.clear,
|
23
|
+
clear = _ref3$clear === void 0 ? true : _ref3$clear;
|
32
24
|
var catchData = getEnumData(storage, cacheKey, baseEnumStorage);
|
33
25
|
// 默认枚举缓存数据
|
34
26
|
baseEnumStorage = catchData;
|
@@ -11,10 +11,35 @@ interface EnumRes {
|
|
11
11
|
* @param baseEnumStorage
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
15
|
+
/**
|
16
|
+
* 设置枚举数据
|
17
|
+
* @param storage
|
18
|
+
* @param cacheKey
|
19
|
+
* @param data
|
20
|
+
*/
|
15
21
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
22
|
+
/**
|
23
|
+
* 判断枚举列表是否存在
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param code
|
27
|
+
* @returns
|
28
|
+
*/
|
16
29
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
30
|
+
/**
|
31
|
+
* 判断是否是对象
|
32
|
+
* @param obj
|
33
|
+
* @returns
|
34
|
+
*/
|
17
35
|
export declare function isObject(obj: any): boolean;
|
36
|
+
/**
|
37
|
+
* 合并枚举数据
|
38
|
+
* @param storage
|
39
|
+
* @param code
|
40
|
+
* @param cacheKey
|
41
|
+
* @param responseData
|
42
|
+
*/
|
18
43
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
19
44
|
/**
|
20
45
|
* diff code 差异
|
@@ -8,8 +8,8 @@ import { isNull, isUndefined } from 'lodash';
|
|
8
8
|
* @param baseEnumStorage
|
9
9
|
* @returns
|
10
10
|
*/
|
11
|
-
export function getEnumData(storage, cacheKey, baseEnumStorage
|
12
|
-
if (baseEnumStorage
|
11
|
+
export function getEnumData(storage, cacheKey, baseEnumStorage) {
|
12
|
+
if (baseEnumStorage) {
|
13
13
|
return baseEnumStorage;
|
14
14
|
}
|
15
15
|
if (storage === 'localStorage') {
|
@@ -19,6 +19,12 @@ export function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
|
19
19
|
return JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
20
20
|
}
|
21
21
|
}
|
22
|
+
/**
|
23
|
+
* 设置枚举数据
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param data
|
27
|
+
*/
|
22
28
|
export function setEnumData(storage, cacheKey, data) {
|
23
29
|
var _Object$keys;
|
24
30
|
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
@@ -30,14 +36,33 @@ export function setEnumData(storage, cacheKey, data) {
|
|
30
36
|
window.sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
31
37
|
}
|
32
38
|
}
|
39
|
+
/**
|
40
|
+
* 判断枚举列表是否存在
|
41
|
+
* @param storage
|
42
|
+
* @param cacheKey
|
43
|
+
* @param code
|
44
|
+
* @returns
|
45
|
+
*/
|
33
46
|
export function hasEnumList(storage, cacheKey, code) {
|
34
47
|
var res = getEnumData(storage, cacheKey);
|
35
48
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
36
49
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
37
50
|
}
|
51
|
+
/**
|
52
|
+
* 判断是否是对象
|
53
|
+
* @param obj
|
54
|
+
* @returns
|
55
|
+
*/
|
38
56
|
export function isObject(obj) {
|
39
57
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
40
58
|
}
|
59
|
+
/**
|
60
|
+
* 合并枚举数据
|
61
|
+
* @param storage
|
62
|
+
* @param code
|
63
|
+
* @param cacheKey
|
64
|
+
* @param responseData
|
65
|
+
*/
|
41
66
|
export function mergeCacheData(storage, code, cacheKey, responseData) {
|
42
67
|
var _window, _window2;
|
43
68
|
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
@@ -6,18 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = void 0;
|
7
7
|
var _ProConfigProvider = require("../../ProConfigProvider");
|
8
8
|
var _utils = require("../utils");
|
9
|
+
var _ref;
|
9
10
|
/* eslint-disable no-redeclare */
|
10
|
-
|
11
|
-
var baseEnumStorage = null;
|
12
|
-
try {
|
13
|
-
var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
|
14
|
-
if (storedData) {
|
15
|
-
baseEnumStorage = JSON.parse(storedData);
|
16
|
-
}
|
17
|
-
} catch (error) {
|
18
|
-
console.error('解析枚举缓存数据失败', error);
|
19
|
-
baseEnumStorage = null;
|
20
|
-
}
|
11
|
+
var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
|
21
12
|
/**
|
22
13
|
* 根据 code 从枚举缓存取出对应的 options 、以及回显
|
23
14
|
* @param codes
|
@@ -26,16 +17,16 @@ try {
|
|
26
17
|
* @returns
|
27
18
|
*/
|
28
19
|
function useEnum(codes, value, compose) {
|
29
|
-
var
|
30
|
-
|
31
|
-
storage =
|
32
|
-
var
|
33
|
-
|
34
|
-
cacheKey =
|
35
|
-
|
36
|
-
fieldNames =
|
37
|
-
|
38
|
-
clear =
|
20
|
+
var _ref2 = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
|
21
|
+
_ref2$storage = _ref2.storage,
|
22
|
+
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
|
23
|
+
var _ref3 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
|
24
|
+
_ref3$cacheKey = _ref3.cacheKey,
|
25
|
+
cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
|
26
|
+
_ref3$fieldNames = _ref3.fieldNames,
|
27
|
+
fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
|
28
|
+
_ref3$clear = _ref3.clear,
|
29
|
+
clear = _ref3$clear === void 0 ? true : _ref3$clear;
|
39
30
|
var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage);
|
40
31
|
// 默认枚举缓存数据
|
41
32
|
baseEnumStorage = catchData;
|
@@ -11,10 +11,35 @@ interface EnumRes {
|
|
11
11
|
* @param baseEnumStorage
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any
|
14
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
|
15
|
+
/**
|
16
|
+
* 设置枚举数据
|
17
|
+
* @param storage
|
18
|
+
* @param cacheKey
|
19
|
+
* @param data
|
20
|
+
*/
|
15
21
|
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
|
22
|
+
/**
|
23
|
+
* 判断枚举列表是否存在
|
24
|
+
* @param storage
|
25
|
+
* @param cacheKey
|
26
|
+
* @param code
|
27
|
+
* @returns
|
28
|
+
*/
|
16
29
|
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
30
|
+
/**
|
31
|
+
* 判断是否是对象
|
32
|
+
* @param obj
|
33
|
+
* @returns
|
34
|
+
*/
|
17
35
|
export declare function isObject(obj: any): boolean;
|
36
|
+
/**
|
37
|
+
* 合并枚举数据
|
38
|
+
* @param storage
|
39
|
+
* @param code
|
40
|
+
* @param cacheKey
|
41
|
+
* @param responseData
|
42
|
+
*/
|
18
43
|
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void;
|
19
44
|
/**
|
20
45
|
* diff code 差异
|
@@ -21,8 +21,8 @@ var _excluded = ["children"];
|
|
21
21
|
* @param baseEnumStorage
|
22
22
|
* @returns
|
23
23
|
*/
|
24
|
-
function getEnumData(storage, cacheKey, baseEnumStorage
|
25
|
-
if (baseEnumStorage
|
24
|
+
function getEnumData(storage, cacheKey, baseEnumStorage) {
|
25
|
+
if (baseEnumStorage) {
|
26
26
|
return baseEnumStorage;
|
27
27
|
}
|
28
28
|
if (storage === 'localStorage') {
|
@@ -32,6 +32,12 @@ function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
|
|
32
32
|
return JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
33
33
|
}
|
34
34
|
}
|
35
|
+
/**
|
36
|
+
* 设置枚举数据
|
37
|
+
* @param storage
|
38
|
+
* @param cacheKey
|
39
|
+
* @param data
|
40
|
+
*/
|
35
41
|
function setEnumData(storage, cacheKey, data) {
|
36
42
|
var _Object$keys;
|
37
43
|
if (!((_Object$keys = Object.keys(data === null || data === void 0 ? void 0 : data.data)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length)) {
|
@@ -43,14 +49,33 @@ function setEnumData(storage, cacheKey, data) {
|
|
43
49
|
window.sessionStorage.setItem(cacheKey, JSON.stringify(data));
|
44
50
|
}
|
45
51
|
}
|
52
|
+
/**
|
53
|
+
* 判断枚举列表是否存在
|
54
|
+
* @param storage
|
55
|
+
* @param cacheKey
|
56
|
+
* @param code
|
57
|
+
* @returns
|
58
|
+
*/
|
46
59
|
function hasEnumList(storage, cacheKey, code) {
|
47
60
|
var res = getEnumData(storage, cacheKey);
|
48
61
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
49
62
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
50
63
|
}
|
64
|
+
/**
|
65
|
+
* 判断是否是对象
|
66
|
+
* @param obj
|
67
|
+
* @returns
|
68
|
+
*/
|
51
69
|
function isObject(obj) {
|
52
70
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
53
71
|
}
|
72
|
+
/**
|
73
|
+
* 合并枚举数据
|
74
|
+
* @param storage
|
75
|
+
* @param code
|
76
|
+
* @param cacheKey
|
77
|
+
* @param responseData
|
78
|
+
*/
|
54
79
|
function mergeCacheData(storage, code, cacheKey, responseData) {
|
55
80
|
var _window, _window2;
|
56
81
|
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|