@zat-design/sisyphus-react 4.0.11 → 4.0.13
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/es/ProEnum/hooks/useEnum.js +118 -12
- package/es/ProEnum/hooks/useEnumRequest.js +167 -70
- package/es/ProEnum/hooks/useFrequentEnumRequest.d.ts +1 -1
- package/es/ProEnum/hooks/useFrequentEnumRequest.js +8 -4
- package/es/ProEnum/propsType.d.ts +7 -2
- package/es/ProEnum/utils/frequentEnum.d.ts +2 -2
- package/es/ProEnum/utils/frequentEnum.js +65 -2
- package/es/ProEnum/utils/index.d.ts +11 -5
- package/es/ProEnum/utils/index.js +287 -19
- package/es/ProForm/components/combination/Group/utils/index.d.ts +16 -16
- package/lib/ProEnum/hooks/useEnum.js +118 -12
- package/lib/ProEnum/hooks/useEnumRequest.js +166 -69
- package/lib/ProEnum/hooks/useFrequentEnumRequest.d.ts +1 -1
- package/lib/ProEnum/hooks/useFrequentEnumRequest.js +8 -4
- package/lib/ProEnum/propsType.d.ts +7 -2
- package/lib/ProEnum/utils/frequentEnum.d.ts +2 -2
- package/lib/ProEnum/utils/frequentEnum.js +65 -2
- package/lib/ProEnum/utils/index.d.ts +11 -5
- package/lib/ProEnum/utils/index.js +287 -20
- package/lib/ProForm/components/combination/Group/utils/index.d.ts +16 -16
- package/package.json +2 -1
|
@@ -7,20 +7,73 @@ exports.mergeFrequentEnumData = mergeFrequentEnumData;
|
|
|
7
7
|
exports.replaceFrequentEnumCache = replaceFrequentEnumCache;
|
|
8
8
|
exports.validateFrequentEnumConfig = validateFrequentEnumConfig;
|
|
9
9
|
var _index = require("./index");
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
13
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
14
15
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
15
18
|
/**
|
|
16
19
|
* 替换频繁枚举缓存数据的参数接口
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* IndexedDB 异步版本的替换频繁枚举缓存数据
|
|
23
|
+
*/
|
|
24
|
+
function replaceFrequentEnumCacheAsync(_x) {
|
|
25
|
+
return _replaceFrequentEnumCacheAsync.apply(this, arguments);
|
|
26
|
+
}
|
|
19
27
|
/**
|
|
20
28
|
* 替换频繁枚举缓存数据
|
|
21
29
|
* @param params 参数对象
|
|
22
30
|
* @returns 更新后的缓存数据
|
|
23
31
|
*/
|
|
32
|
+
function _replaceFrequentEnumCacheAsync() {
|
|
33
|
+
_replaceFrequentEnumCacheAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
34
|
+
var storage, cacheKey, enums, newData, fieldNames, clear, cacheData;
|
|
35
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
storage = params.storage, cacheKey = params.cacheKey, enums = params.enums, newData = params.newData, fieldNames = params.fieldNames, clear = params.clear;
|
|
39
|
+
_context.next = 3;
|
|
40
|
+
return Promise.resolve((0, _index.getEnumData)(storage, cacheKey) || {
|
|
41
|
+
data: {}
|
|
42
|
+
});
|
|
43
|
+
case 3:
|
|
44
|
+
cacheData = _context.sent;
|
|
45
|
+
// 确保cacheData.data存在
|
|
46
|
+
if (!cacheData.data) {
|
|
47
|
+
cacheData.data = {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 只替换指定的枚举
|
|
51
|
+
enums.forEach(code => {
|
|
52
|
+
if (newData[code]) {
|
|
53
|
+
var processedData = newData[code];
|
|
54
|
+
|
|
55
|
+
// 应用数据清洗逻辑
|
|
56
|
+
if (clear && Array.isArray(processedData)) {
|
|
57
|
+
processedData = processedData.map(item => {
|
|
58
|
+
return (0, _index.cacheFieldNames)(fieldNames, item);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
cacheData.data[code] = processedData;
|
|
62
|
+
cacheData.time = Date.now();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
_context.next = 8;
|
|
66
|
+
return Promise.resolve((0, _index.setEnumData)(storage, cacheKey, cacheData));
|
|
67
|
+
case 8:
|
|
68
|
+
return _context.abrupt("return", cacheData);
|
|
69
|
+
case 9:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee);
|
|
74
|
+
}));
|
|
75
|
+
return _replaceFrequentEnumCacheAsync.apply(this, arguments);
|
|
76
|
+
}
|
|
24
77
|
function replaceFrequentEnumCache(params) {
|
|
25
78
|
var _params$storage = params.storage,
|
|
26
79
|
storage = _params$storage === void 0 ? 'localStorage' : _params$storage,
|
|
@@ -52,7 +105,17 @@ function replaceFrequentEnumCache(params) {
|
|
|
52
105
|
data: {}
|
|
53
106
|
};
|
|
54
107
|
}
|
|
55
|
-
|
|
108
|
+
|
|
109
|
+
// IndexedDB 异步处理
|
|
110
|
+
if (storage === 'indexedDB') {
|
|
111
|
+
return replaceFrequentEnumCacheAsync(params);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// localStorage/sessionStorage 同步处理(保持原逻辑)
|
|
115
|
+
var cacheDataResult = (0, _index.getEnumData)(storage, cacheKey);
|
|
116
|
+
// getEnumData 对于非 indexedDB 返回同步值,对于 indexedDB 返回 Promise
|
|
117
|
+
// 这里 storage 不是 indexedDB,所以是同步值
|
|
118
|
+
var cacheData = cacheDataResult || {
|
|
56
119
|
data: {}
|
|
57
120
|
};
|
|
58
121
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataOption } from '../propsType';
|
|
2
|
-
type StorageType = 'localStorage' | 'sessionStorage';
|
|
2
|
+
type StorageType = 'localStorage' | 'sessionStorage' | 'indexedDB';
|
|
3
3
|
export declare const baseCacheKey = "zat-design-pro-component-cacheKey";
|
|
4
4
|
interface EnumRes {
|
|
5
5
|
data: Record<string, DataOption[]>;
|
|
@@ -12,14 +12,20 @@ interface EnumRes {
|
|
|
12
12
|
* @param baseEnumStorage
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes
|
|
15
|
+
export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes | Promise<EnumRes>;
|
|
16
16
|
/**
|
|
17
17
|
* 设置枚举数据
|
|
18
18
|
* @param storage
|
|
19
19
|
* @param cacheKey
|
|
20
20
|
* @param data
|
|
21
21
|
*/
|
|
22
|
-
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any):
|
|
22
|
+
export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* 删除枚举缓存数据
|
|
25
|
+
* @param storage
|
|
26
|
+
* @param cacheKey
|
|
27
|
+
*/
|
|
28
|
+
export declare function removeEnumData(storage: StorageType, cacheKey: string): Promise<void>;
|
|
23
29
|
/**
|
|
24
30
|
* 判断枚举列表是否存在
|
|
25
31
|
* @param storage
|
|
@@ -27,7 +33,7 @@ export declare function setEnumData(storage: StorageType, cacheKey: string, data
|
|
|
27
33
|
* @param code
|
|
28
34
|
* @returns
|
|
29
35
|
*/
|
|
30
|
-
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
|
|
36
|
+
export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): false | import("../propsType").DataOptionType[];
|
|
31
37
|
/**
|
|
32
38
|
* 判断是否是对象
|
|
33
39
|
* @param obj
|
|
@@ -41,7 +47,7 @@ export declare function isObject(obj: any): boolean;
|
|
|
41
47
|
* @param cacheKey
|
|
42
48
|
* @param responseData
|
|
43
49
|
*/
|
|
44
|
-
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): void
|
|
50
|
+
export declare function mergeCacheData(storage: string, code: string, cacheKey: string, responseData: any): Promise<void>;
|
|
45
51
|
/**
|
|
46
52
|
* diff code 差异
|
|
47
53
|
* @param cacheCodes
|
|
@@ -10,11 +10,157 @@ exports.getEnumData = getEnumData;
|
|
|
10
10
|
exports.hasEnumList = hasEnumList;
|
|
11
11
|
exports.isObject = isObject;
|
|
12
12
|
exports.mergeCacheData = mergeCacheData;
|
|
13
|
+
exports.removeEnumData = removeEnumData;
|
|
13
14
|
exports.setEnumData = setEnumData;
|
|
14
|
-
var
|
|
15
|
+
var _idbKeyval = require("idb-keyval");
|
|
16
|
+
var _excluded = ["children"],
|
|
17
|
+
_excluded2 = ["params"];
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
15
19
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
20
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
23
|
var baseCacheKey = exports.baseCacheKey = 'zat-design-pro-component-cacheKey';
|
|
24
|
+
|
|
25
|
+
// IndexedDB 可用性检测缓存
|
|
26
|
+
var indexedDBAvailable = null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 检测 IndexedDB 是否可用
|
|
30
|
+
*/
|
|
31
|
+
function checkIndexedDBSupport() {
|
|
32
|
+
return _checkIndexedDBSupport.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 从 IndexedDB 读取数据
|
|
36
|
+
*/
|
|
37
|
+
function _checkIndexedDBSupport() {
|
|
38
|
+
_checkIndexedDBSupport = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
39
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
if (!(indexedDBAvailable !== null)) {
|
|
43
|
+
_context.next = 2;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return _context.abrupt("return", indexedDBAvailable);
|
|
47
|
+
case 2:
|
|
48
|
+
_context.prev = 2;
|
|
49
|
+
_context.next = 5;
|
|
50
|
+
return (0, _idbKeyval.set)('__idb_test__', 1);
|
|
51
|
+
case 5:
|
|
52
|
+
_context.next = 7;
|
|
53
|
+
return (0, _idbKeyval.del)('__idb_test__');
|
|
54
|
+
case 7:
|
|
55
|
+
indexedDBAvailable = true;
|
|
56
|
+
return _context.abrupt("return", true);
|
|
57
|
+
case 11:
|
|
58
|
+
_context.prev = 11;
|
|
59
|
+
_context.t0 = _context["catch"](2);
|
|
60
|
+
console.warn('ProEnum: IndexedDB is not available in this environment:', _context.t0);
|
|
61
|
+
console.warn('ProEnum: Please use localStorage or sessionStorage instead');
|
|
62
|
+
indexedDBAvailable = false;
|
|
63
|
+
return _context.abrupt("return", false);
|
|
64
|
+
case 17:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context.stop();
|
|
67
|
+
}
|
|
68
|
+
}, _callee, null, [[2, 11]]);
|
|
69
|
+
}));
|
|
70
|
+
return _checkIndexedDBSupport.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
function getFromIndexedDB(_x) {
|
|
73
|
+
return _getFromIndexedDB.apply(this, arguments);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 写入数据到 IndexedDB
|
|
77
|
+
*/
|
|
78
|
+
function _getFromIndexedDB() {
|
|
79
|
+
_getFromIndexedDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key) {
|
|
80
|
+
var available, value;
|
|
81
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
82
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
_context2.next = 2;
|
|
85
|
+
return checkIndexedDBSupport();
|
|
86
|
+
case 2:
|
|
87
|
+
available = _context2.sent;
|
|
88
|
+
if (available) {
|
|
89
|
+
_context2.next = 5;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return _context2.abrupt("return", {
|
|
93
|
+
data: {}
|
|
94
|
+
});
|
|
95
|
+
case 5:
|
|
96
|
+
_context2.prev = 5;
|
|
97
|
+
_context2.next = 8;
|
|
98
|
+
return (0, _idbKeyval.get)(key);
|
|
99
|
+
case 8:
|
|
100
|
+
value = _context2.sent;
|
|
101
|
+
return _context2.abrupt("return", value || {
|
|
102
|
+
data: {}
|
|
103
|
+
});
|
|
104
|
+
case 12:
|
|
105
|
+
_context2.prev = 12;
|
|
106
|
+
_context2.t0 = _context2["catch"](5);
|
|
107
|
+
console.warn('ProEnum: IndexedDB read failed:', _context2.t0);
|
|
108
|
+
return _context2.abrupt("return", {
|
|
109
|
+
data: {}
|
|
110
|
+
});
|
|
111
|
+
case 16:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context2.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee2, null, [[5, 12]]);
|
|
116
|
+
}));
|
|
117
|
+
return _getFromIndexedDB.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
function setToIndexedDB(_x2, _x3) {
|
|
120
|
+
return _setToIndexedDB.apply(this, arguments);
|
|
121
|
+
}
|
|
122
|
+
function _setToIndexedDB() {
|
|
123
|
+
_setToIndexedDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
|
|
124
|
+
var available, params, cleanValue;
|
|
125
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
126
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
_context3.next = 2;
|
|
129
|
+
return checkIndexedDBSupport();
|
|
130
|
+
case 2:
|
|
131
|
+
available = _context3.sent;
|
|
132
|
+
if (available) {
|
|
133
|
+
_context3.next = 5;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
return _context3.abrupt("return");
|
|
137
|
+
case 5:
|
|
138
|
+
if (Object.keys((value === null || value === void 0 ? void 0 : value.data) || {}).length) {
|
|
139
|
+
_context3.next = 7;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return _context3.abrupt("return");
|
|
143
|
+
case 7:
|
|
144
|
+
_context3.prev = 7;
|
|
145
|
+
// 清理 params 字段(ahooks useRequest 缓存结构中的冗余字段)
|
|
146
|
+
params = value.params, cleanValue = _objectWithoutProperties(value, _excluded2);
|
|
147
|
+
_context3.next = 11;
|
|
148
|
+
return (0, _idbKeyval.set)(key, cleanValue);
|
|
149
|
+
case 11:
|
|
150
|
+
_context3.next = 16;
|
|
151
|
+
break;
|
|
152
|
+
case 13:
|
|
153
|
+
_context3.prev = 13;
|
|
154
|
+
_context3.t0 = _context3["catch"](7);
|
|
155
|
+
console.warn('ProEnum: IndexedDB write failed:', _context3.t0);
|
|
156
|
+
case 16:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context3.stop();
|
|
159
|
+
}
|
|
160
|
+
}, _callee3, null, [[7, 13]]);
|
|
161
|
+
}));
|
|
162
|
+
return _setToIndexedDB.apply(this, arguments);
|
|
163
|
+
}
|
|
18
164
|
/**
|
|
19
165
|
* 获取枚举数据
|
|
20
166
|
* @param storage
|
|
@@ -23,15 +169,38 @@ var baseCacheKey = exports.baseCacheKey = 'zat-design-pro-component-cacheKey';
|
|
|
23
169
|
* @returns
|
|
24
170
|
*/
|
|
25
171
|
function getEnumData(storage, cacheKey, baseEnumStorage) {
|
|
172
|
+
// IndexedDB 返回 Promise
|
|
173
|
+
if (storage === 'indexedDB') {
|
|
174
|
+
return getFromIndexedDB(cacheKey);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// localStorage/sessionStorage 保持同步
|
|
26
178
|
if (baseEnumStorage && window.localStorage.getItem(cacheKey) && cacheKey === baseCacheKey) {
|
|
27
179
|
return baseEnumStorage;
|
|
28
180
|
}
|
|
29
181
|
if (storage === 'localStorage') {
|
|
30
|
-
|
|
182
|
+
var data = JSON.parse(window.localStorage.getItem(cacheKey) || '{}');
|
|
183
|
+
// 确保返回的数据格式正确,包含 data 字段
|
|
184
|
+
if (data && typeof data === 'object' && 'data' in data) {
|
|
185
|
+
return data;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
data: {}
|
|
189
|
+
};
|
|
31
190
|
}
|
|
32
191
|
if (storage === 'sessionStorage') {
|
|
33
|
-
|
|
192
|
+
var _data = JSON.parse(window.sessionStorage.getItem(cacheKey) || '{}');
|
|
193
|
+
// 确保返回的数据格式正确,包含 data 字段
|
|
194
|
+
if (_data && typeof _data === 'object' && 'data' in _data) {
|
|
195
|
+
return _data;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
data: {}
|
|
199
|
+
};
|
|
34
200
|
}
|
|
201
|
+
return {
|
|
202
|
+
data: {}
|
|
203
|
+
};
|
|
35
204
|
}
|
|
36
205
|
|
|
37
206
|
/**
|
|
@@ -41,10 +210,16 @@ function getEnumData(storage, cacheKey, baseEnumStorage) {
|
|
|
41
210
|
* @param data
|
|
42
211
|
*/
|
|
43
212
|
function setEnumData(storage, cacheKey, data) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
213
|
+
if (!Object.keys((data === null || data === void 0 ? void 0 : data.data) || {}).length) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// IndexedDB 返回 Promise
|
|
218
|
+
if (storage === 'indexedDB') {
|
|
219
|
+
return setToIndexedDB(cacheKey, data);
|
|
47
220
|
}
|
|
221
|
+
|
|
222
|
+
// localStorage/sessionStorage 保持同步
|
|
48
223
|
if (storage === 'localStorage') {
|
|
49
224
|
window.localStorage.setItem(cacheKey, JSON.stringify(data));
|
|
50
225
|
} else if (storage === 'sessionStorage') {
|
|
@@ -52,6 +227,14 @@ function setEnumData(storage, cacheKey, data) {
|
|
|
52
227
|
}
|
|
53
228
|
}
|
|
54
229
|
|
|
230
|
+
/**
|
|
231
|
+
* 删除枚举缓存数据
|
|
232
|
+
* @param storage
|
|
233
|
+
* @param cacheKey
|
|
234
|
+
*/
|
|
235
|
+
function removeEnumData(_x4, _x5) {
|
|
236
|
+
return _removeEnumData.apply(this, arguments);
|
|
237
|
+
}
|
|
55
238
|
/**
|
|
56
239
|
* 判断枚举列表是否存在
|
|
57
240
|
* @param storage
|
|
@@ -59,7 +242,60 @@ function setEnumData(storage, cacheKey, data) {
|
|
|
59
242
|
* @param code
|
|
60
243
|
* @returns
|
|
61
244
|
*/
|
|
245
|
+
function _removeEnumData() {
|
|
246
|
+
_removeEnumData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(storage, cacheKey) {
|
|
247
|
+
var available;
|
|
248
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
249
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
250
|
+
case 0:
|
|
251
|
+
if (!(storage === 'indexedDB')) {
|
|
252
|
+
_context4.next = 16;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
_context4.next = 3;
|
|
256
|
+
return checkIndexedDBSupport();
|
|
257
|
+
case 3:
|
|
258
|
+
available = _context4.sent;
|
|
259
|
+
if (available) {
|
|
260
|
+
_context4.next = 6;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
return _context4.abrupt("return");
|
|
264
|
+
case 6:
|
|
265
|
+
_context4.prev = 6;
|
|
266
|
+
_context4.next = 9;
|
|
267
|
+
return (0, _idbKeyval.del)(cacheKey);
|
|
268
|
+
case 9:
|
|
269
|
+
_context4.next = 14;
|
|
270
|
+
break;
|
|
271
|
+
case 11:
|
|
272
|
+
_context4.prev = 11;
|
|
273
|
+
_context4.t0 = _context4["catch"](6);
|
|
274
|
+
console.warn('ProEnum: IndexedDB delete failed:', _context4.t0);
|
|
275
|
+
case 14:
|
|
276
|
+
_context4.next = 17;
|
|
277
|
+
break;
|
|
278
|
+
case 16:
|
|
279
|
+
if (storage === 'localStorage') {
|
|
280
|
+
window.localStorage.removeItem(cacheKey);
|
|
281
|
+
} else if (storage === 'sessionStorage') {
|
|
282
|
+
window.sessionStorage.removeItem(cacheKey);
|
|
283
|
+
}
|
|
284
|
+
case 17:
|
|
285
|
+
case "end":
|
|
286
|
+
return _context4.stop();
|
|
287
|
+
}
|
|
288
|
+
}, _callee4, null, [[6, 11]]);
|
|
289
|
+
}));
|
|
290
|
+
return _removeEnumData.apply(this, arguments);
|
|
291
|
+
}
|
|
62
292
|
function hasEnumList(storage, cacheKey, code) {
|
|
293
|
+
// 对于 indexedDB,getEnumData 返回 Promise,但 hasEnumList 是同步函数
|
|
294
|
+
// 这里只支持同步存储类型
|
|
295
|
+
if (storage === 'indexedDB') {
|
|
296
|
+
console.warn('ProEnum: hasEnumList does not support indexedDB, please use async version');
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
63
299
|
var res = getEnumData(storage, cacheKey);
|
|
64
300
|
var enumList = (res === null || res === void 0 ? void 0 : res.data) || {};
|
|
65
301
|
return enumList === null || enumList === void 0 ? void 0 : enumList[code];
|
|
@@ -81,23 +317,52 @@ function isObject(obj) {
|
|
|
81
317
|
* @param cacheKey
|
|
82
318
|
* @param responseData
|
|
83
319
|
*/
|
|
84
|
-
function mergeCacheData(
|
|
85
|
-
|
|
86
|
-
var cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
|
87
|
-
var cacheData = JSON.parse((_window = window) === null || _window === void 0 ? void 0 : _window[cacheStorage].getItem(cacheKey));
|
|
88
|
-
// 合并枚举到总数据源上
|
|
89
|
-
if (cacheData && cacheData.data) {
|
|
90
|
-
cacheData.data[code] = responseData;
|
|
91
|
-
}
|
|
92
|
-
(_window2 = window) === null || _window2 === void 0 || _window2[cacheStorage].setItem(cacheKey, JSON.stringify(cacheData));
|
|
320
|
+
function mergeCacheData(_x6, _x7, _x8, _x9) {
|
|
321
|
+
return _mergeCacheData.apply(this, arguments);
|
|
93
322
|
}
|
|
94
|
-
|
|
95
323
|
/**
|
|
96
324
|
* diff code 差异
|
|
97
325
|
* @param cacheCodes
|
|
98
326
|
* @param codes
|
|
99
327
|
* @returns
|
|
100
328
|
*/
|
|
329
|
+
function _mergeCacheData() {
|
|
330
|
+
_mergeCacheData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(storage, code, cacheKey, responseData) {
|
|
331
|
+
var cacheData, _window, _window2, cacheStorage, _cacheData;
|
|
332
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
333
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
334
|
+
case 0:
|
|
335
|
+
if (!(storage === 'indexedDB')) {
|
|
336
|
+
_context5.next = 9;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
_context5.next = 3;
|
|
340
|
+
return getFromIndexedDB(cacheKey);
|
|
341
|
+
case 3:
|
|
342
|
+
cacheData = _context5.sent;
|
|
343
|
+
if (cacheData && cacheData.data) {
|
|
344
|
+
cacheData.data[code] = responseData;
|
|
345
|
+
}
|
|
346
|
+
_context5.next = 7;
|
|
347
|
+
return setToIndexedDB(cacheKey, cacheData);
|
|
348
|
+
case 7:
|
|
349
|
+
_context5.next = 13;
|
|
350
|
+
break;
|
|
351
|
+
case 9:
|
|
352
|
+
cacheStorage = storage === 'localStorage' ? 'localStorage' : 'sessionStorage';
|
|
353
|
+
_cacheData = JSON.parse(((_window = window) === null || _window === void 0 || (_window = _window[cacheStorage]) === null || _window === void 0 ? void 0 : _window.getItem(cacheKey)) || '{}'); // 合并枚举到总数据源上
|
|
354
|
+
if (_cacheData && _cacheData.data) {
|
|
355
|
+
_cacheData.data[code] = responseData;
|
|
356
|
+
}
|
|
357
|
+
(_window2 = window) === null || _window2 === void 0 || (_window2 = _window2[cacheStorage]) === null || _window2 === void 0 || _window2.setItem(cacheKey, JSON.stringify(_cacheData));
|
|
358
|
+
case 13:
|
|
359
|
+
case "end":
|
|
360
|
+
return _context5.stop();
|
|
361
|
+
}
|
|
362
|
+
}, _callee5);
|
|
363
|
+
}));
|
|
364
|
+
return _mergeCacheData.apply(this, arguments);
|
|
365
|
+
}
|
|
101
366
|
function diffCode(cacheCodes, codes) {
|
|
102
367
|
var diff = false;
|
|
103
368
|
// 以后面传入的作计算
|
|
@@ -123,10 +388,12 @@ function cacheFieldNames(fieldNames, dataSource) {
|
|
|
123
388
|
restFieldNames = _objectWithoutProperties(fieldNames, _excluded);
|
|
124
389
|
var result = {};
|
|
125
390
|
Object.keys(restFieldNames).forEach(key => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
391
|
+
var sourceKey = restFieldNames[key];
|
|
392
|
+
var sourceVal = dataSource[sourceKey];
|
|
393
|
+
var fallbackVal = dataSource[key];
|
|
394
|
+
var val = ![undefined, null, ''].includes(sourceVal) ? sourceVal : fallbackVal;
|
|
395
|
+
if (![undefined, null, ''].includes(val)) {
|
|
396
|
+
result[key] = val;
|
|
130
397
|
}
|
|
131
398
|
});
|
|
132
399
|
// 递归去对数据进行清洗
|
|
@@ -76,37 +76,34 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
76
76
|
show?: boolean | ReactiveFunction<any, boolean>;
|
|
77
77
|
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
78
78
|
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
className?: string;
|
|
79
|
+
isView?: boolean;
|
|
80
|
+
id?: string;
|
|
82
81
|
prefixCls?: string;
|
|
82
|
+
className?: string;
|
|
83
83
|
style?: React.CSSProperties;
|
|
84
|
+
rootClassName?: string;
|
|
85
|
+
hidden?: boolean;
|
|
84
86
|
onReset?: () => void;
|
|
85
87
|
status?: "" | "warning" | "error" | "success" | "validating";
|
|
86
|
-
hidden?: boolean;
|
|
87
|
-
id?: string;
|
|
88
88
|
vertical?: boolean;
|
|
89
|
-
|
|
90
|
-
isView?: boolean;
|
|
89
|
+
validateTrigger?: string | false | string[];
|
|
91
90
|
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
92
91
|
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
93
|
-
|
|
94
|
-
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
95
|
-
help?: React.ReactNode;
|
|
96
|
-
preserve?: boolean;
|
|
97
|
-
trigger?: string;
|
|
92
|
+
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
98
93
|
colon?: boolean;
|
|
99
|
-
|
|
94
|
+
htmlFor?: string;
|
|
100
95
|
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
101
96
|
labelCol?: import("antd").ColProps;
|
|
102
97
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
98
|
+
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
103
99
|
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
104
|
-
|
|
100
|
+
trigger?: string;
|
|
105
101
|
validateDebounce?: number;
|
|
106
102
|
valuePropName?: string;
|
|
107
103
|
messageVariables?: Record<string, string>;
|
|
108
104
|
initialValue?: any;
|
|
109
105
|
onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
|
|
106
|
+
preserve?: boolean;
|
|
110
107
|
isListField?: boolean;
|
|
111
108
|
isList?: boolean;
|
|
112
109
|
noStyle?: boolean;
|
|
@@ -114,9 +111,10 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
114
111
|
icons: import("antd/es/form/FormItem").FeedbackIcons;
|
|
115
112
|
};
|
|
116
113
|
validateStatus?: "" | "warning" | "error" | "success" | "validating";
|
|
114
|
+
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
117
115
|
wrapperCol?: import("antd").ColProps;
|
|
116
|
+
help?: React.ReactNode;
|
|
118
117
|
fieldId?: string;
|
|
119
|
-
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
120
118
|
switchValue?: [any, any];
|
|
121
119
|
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
122
120
|
[key: string]: any;
|
|
@@ -124,9 +122,11 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
124
122
|
index?: number;
|
|
125
123
|
}) => string | React.ReactElement<any, any>;
|
|
126
124
|
viewType?: import("../../../render/propsType").ViewType;
|
|
125
|
+
trim?: boolean;
|
|
127
126
|
upperCase?: boolean;
|
|
128
127
|
toISOString?: boolean;
|
|
129
128
|
toCSTString?: boolean;
|
|
129
|
+
clearNotShow?: boolean;
|
|
130
130
|
name: any;
|
|
131
131
|
dependencies: any[];
|
|
132
132
|
tooltip: string | {
|
|
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
141
141
|
* 创建组件属性
|
|
142
142
|
*/
|
|
143
143
|
export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
|
|
144
|
-
componentProps: import("lodash").Omit<any, "
|
|
144
|
+
componentProps: import("lodash").Omit<any, "precision" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
|
|
145
145
|
formItemTransform: {
|
|
146
146
|
getValueProps: any;
|
|
147
147
|
normalize: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zat-design/sisyphus-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"big.js": "^6.2.1",
|
|
84
84
|
"classnames": "^2.3.1",
|
|
85
85
|
"dayjs": "^1.11.13",
|
|
86
|
+
"idb-keyval": "^6.2.2",
|
|
86
87
|
"lodash": "^4.17.21",
|
|
87
88
|
"rc-resize-observer": "^1.4.0",
|
|
88
89
|
"react-lazyload": "^3.2.1",
|