@fast-china/utils 1.0.37 → 2.0.0
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/CHANGELOG.md +21 -0
- package/CONTRIBUTING.md +87 -0
- package/README.md +111 -50
- package/README.zh.md +111 -50
- package/SECURITY.md +46 -0
- package/dist/array/index.d.mts +87 -0
- package/dist/array/index.d.mts.map +1 -0
- package/dist/array/index.mjs +161 -0
- package/dist/array/index.mjs.map +1 -0
- package/dist/async/index.d.mts +146 -0
- package/dist/async/index.d.mts.map +1 -0
- package/dist/async/index.mjs +336 -0
- package/dist/async/index.mjs.map +1 -0
- package/dist/base64/index.d.mts +105 -0
- package/dist/base64/index.d.mts.map +1 -0
- package/dist/base64/index.mjs +427 -0
- package/dist/base64/index.mjs.map +1 -0
- package/dist/color/index.d.mts +90 -0
- package/dist/color/index.d.mts.map +1 -0
- package/dist/color/index.mjs +178 -0
- package/dist/color/index.mjs.map +1 -0
- package/dist/crypto/index.d.mts +157 -0
- package/dist/crypto/index.d.mts.map +1 -0
- package/dist/crypto/index.mjs +541 -0
- package/dist/crypto/index.mjs.map +1 -0
- package/dist/date/index.d.mts +191 -0
- package/dist/date/index.d.mts.map +1 -0
- package/dist/date/index.mjs +383 -0
- package/dist/date/index.mjs.map +1 -0
- package/dist/dom/style.d.mts +30 -0
- package/dist/dom/style.d.mts.map +1 -0
- package/dist/dom/style.mjs +74 -0
- package/dist/dom/style.mjs.map +1 -0
- package/dist/env/index.d.mts +63 -0
- package/dist/env/index.d.mts.map +1 -0
- package/dist/env/index.mjs +97 -0
- package/dist/env/index.mjs.map +1 -0
- package/dist/identity/index.d.mts +78 -0
- package/dist/identity/index.d.mts.map +1 -0
- package/dist/identity/index.mjs +87 -0
- package/dist/identity/index.mjs.map +1 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +23 -0
- package/dist/internal/text.mjs +36 -0
- package/dist/internal/text.mjs.map +1 -0
- package/dist/logger/index.d.mts +87 -0
- package/dist/logger/index.d.mts.map +1 -0
- package/dist/logger/index.mjs +124 -0
- package/dist/logger/index.mjs.map +1 -0
- package/dist/number/index.d.mts +89 -0
- package/dist/number/index.d.mts.map +1 -0
- package/dist/number/index.mjs +215 -0
- package/dist/number/index.mjs.map +1 -0
- package/dist/object/index.d.mts +76 -0
- package/dist/object/index.d.mts.map +1 -0
- package/dist/object/index.mjs +134 -0
- package/dist/object/index.mjs.map +1 -0
- package/dist/storage/index.d.mts +104 -0
- package/dist/storage/index.d.mts.map +1 -0
- package/dist/storage/index.mjs +324 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/string/index.d.mts +130 -0
- package/dist/string/index.d.mts.map +1 -0
- package/dist/string/index.mjs +275 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/vue/emits.d.mts +24 -0
- package/dist/vue/emits.d.mts.map +1 -0
- package/dist/vue/emits.mjs +47 -0
- package/dist/vue/emits.mjs.map +1 -0
- package/dist/vue/expose.d.mts +12 -0
- package/dist/vue/expose.d.mts.map +1 -0
- package/dist/vue/expose.mjs +16 -0
- package/dist/vue/expose.mjs.map +1 -0
- package/dist/vue/func.d.mts +14 -0
- package/dist/vue/func.d.mts.map +1 -0
- package/dist/vue/func.mjs +16 -0
- package/dist/vue/func.mjs.map +1 -0
- package/dist/vue/index.d.mts +9 -0
- package/dist/vue/install.d.mts +69 -0
- package/dist/vue/install.d.mts.map +1 -0
- package/dist/vue/install.mjs +123 -0
- package/dist/vue/install.mjs.map +1 -0
- package/dist/vue/props.d.mts +23 -0
- package/dist/vue/props.d.mts.map +1 -0
- package/dist/vue/props.mjs +41 -0
- package/dist/vue/props.mjs.map +1 -0
- package/dist/vue/render.d.mts +13 -0
- package/dist/vue/render.d.mts.map +1 -0
- package/dist/vue/render.mjs +23 -0
- package/dist/vue/render.mjs.map +1 -0
- package/dist/vue/slots.d.mts +19 -0
- package/dist/vue/slots.d.mts.map +1 -0
- package/dist/vue/slots.mjs +13 -0
- package/dist/vue/slots.mjs.map +1 -0
- package/dist/vue/with.d.mts +12 -0
- package/dist/vue/with.d.mts.map +1 -0
- package/dist/vue/with.mjs +15 -0
- package/dist/vue/with.mjs.map +1 -0
- package/docs/API.md +96 -0
- package/docs/API.zh-CN.md +96 -0
- package/docs/DEVELOPMENT_RELEASE.zh-CN.md +65 -0
- package/docs/RUNTIME_CONTRACT.md +37 -0
- package/package.json +65 -73
- package/src/array/index.ts +173 -0
- package/src/async/index.ts +475 -0
- package/src/base64/index.ts +374 -0
- package/src/color/index.ts +208 -0
- package/src/crypto/index.ts +670 -0
- package/src/date/index.ts +451 -0
- package/src/dom/index.ts +6 -0
- package/src/dom/style.ts +92 -0
- package/src/env/index.ts +169 -0
- package/src/identity/index.ts +144 -0
- package/src/index.ts +20 -0
- package/src/internal/text.ts +46 -0
- package/src/logger/index.ts +219 -0
- package/src/number/index.ts +235 -0
- package/src/object/index.ts +160 -0
- package/src/storage/index.ts +524 -0
- package/src/string/index.ts +328 -0
- package/src/vue/emits.ts +71 -0
- package/src/vue/expose.ts +11 -0
- package/src/vue/func.ts +17 -0
- package/src/vue/index.ts +13 -0
- package/src/vue/install.ts +185 -0
- package/src/vue/props.ts +39 -0
- package/src/vue/render.ts +41 -0
- package/src/vue/slots.ts +23 -0
- package/src/vue/with.ts +10 -0
- package/Fast.png +0 -0
- package/dist/index.global.js +0 -14500
- package/dist/index.global.js.map +0 -1
- package/dist/index.global.min.js +0 -2
- package/dist/index.global.min.js.map +0 -1
- package/es/array/index.d.ts +0 -19
- package/es/array/index.mjs +0 -2
- package/es/array/index.mjs.map +0 -1
- package/es/base64/index.d.ts +0 -21
- package/es/base64/index.mjs +0 -2
- package/es/base64/index.mjs.map +0 -1
- package/es/click/index.d.ts +0 -33
- package/es/click/index.mjs +0 -2
- package/es/click/index.mjs.map +0 -1
- package/es/color/index.d.ts +0 -33
- package/es/color/index.mjs +0 -2
- package/es/color/index.mjs.map +0 -1
- package/es/console/index.d.ts +0 -31
- package/es/console/index.mjs +0 -2
- package/es/console/index.mjs.map +0 -1
- package/es/crypto/index.d.ts +0 -46
- package/es/crypto/index.mjs +0 -2
- package/es/crypto/index.mjs.map +0 -1
- package/es/date/index.d.ts +0 -44
- package/es/date/index.mjs +0 -2
- package/es/date/index.mjs.map +0 -1
- package/es/dom/index.d.ts +0 -1
- package/es/dom/index.mjs +0 -2
- package/es/dom/index.mjs.map +0 -1
- package/es/dom/style.d.ts +0 -12
- package/es/dom/style.mjs +0 -2
- package/es/dom/style.mjs.map +0 -1
- package/es/env/index.d.ts +0 -25
- package/es/env/index.mjs +0 -2
- package/es/env/index.mjs.map +0 -1
- package/es/error/index.d.ts +0 -3
- package/es/error/index.mjs +0 -2
- package/es/error/index.mjs.map +0 -1
- package/es/identity/index.d.ts +0 -14
- package/es/identity/index.mjs +0 -2
- package/es/identity/index.mjs.map +0 -1
- package/es/index.d.ts +0 -15
- package/es/index.es.d.ts +0 -2
- package/es/index.mjs +0 -2
- package/es/index.mjs.map +0 -1
- package/es/object/index.d.ts +0 -13
- package/es/object/index.mjs +0 -2
- package/es/object/index.mjs.map +0 -1
- package/es/storage/index.d.ts +0 -96
- package/es/storage/index.mjs +0 -2
- package/es/storage/index.mjs.map +0 -1
- package/es/string/index.d.ts +0 -114
- package/es/string/index.mjs +0 -2
- package/es/string/index.mjs.map +0 -1
- package/es/vue/emits.d.ts +0 -8
- package/es/vue/emits.mjs +0 -2
- package/es/vue/emits.mjs.map +0 -1
- package/es/vue/expose.d.ts +0 -4
- package/es/vue/expose.mjs +0 -2
- package/es/vue/expose.mjs.map +0 -1
- package/es/vue/func.d.ts +0 -6
- package/es/vue/func.mjs +0 -2
- package/es/vue/func.mjs.map +0 -1
- package/es/vue/index.d.ts +0 -8
- package/es/vue/index.mjs +0 -2
- package/es/vue/index.mjs.map +0 -1
- package/es/vue/install.d.ts +0 -5
- package/es/vue/install.mjs +0 -2
- package/es/vue/install.mjs.map +0 -1
- package/es/vue/props.d.ts +0 -9
- package/es/vue/props.mjs +0 -2
- package/es/vue/props.mjs.map +0 -1
- package/es/vue/slots.d.ts +0 -11
- package/es/vue/slots.mjs +0 -2
- package/es/vue/slots.mjs.map +0 -1
- package/es/vue/useRender.d.ts +0 -6
- package/es/vue/useRender.mjs +0 -2
- package/es/vue/useRender.mjs.map +0 -1
- package/es/vue/with.d.ts +0 -5
- package/es/vue/with.mjs +0 -2
- package/es/vue/with.mjs.map +0 -1
- package/lib/array/index.d.ts +0 -19
- package/lib/array/index.js +0 -2
- package/lib/array/index.js.map +0 -1
- package/lib/base64/index.d.ts +0 -21
- package/lib/base64/index.js +0 -2
- package/lib/base64/index.js.map +0 -1
- package/lib/click/index.d.ts +0 -33
- package/lib/click/index.js +0 -2
- package/lib/click/index.js.map +0 -1
- package/lib/color/index.d.ts +0 -33
- package/lib/color/index.js +0 -2
- package/lib/color/index.js.map +0 -1
- package/lib/console/index.d.ts +0 -31
- package/lib/console/index.js +0 -2
- package/lib/console/index.js.map +0 -1
- package/lib/crypto/index.d.ts +0 -46
- package/lib/crypto/index.js +0 -2
- package/lib/crypto/index.js.map +0 -1
- package/lib/date/index.d.ts +0 -44
- package/lib/date/index.js +0 -2
- package/lib/date/index.js.map +0 -1
- package/lib/dom/index.d.ts +0 -1
- package/lib/dom/index.js +0 -2
- package/lib/dom/index.js.map +0 -1
- package/lib/dom/style.d.ts +0 -12
- package/lib/dom/style.js +0 -2
- package/lib/dom/style.js.map +0 -1
- package/lib/env/index.d.ts +0 -25
- package/lib/env/index.js +0 -2
- package/lib/env/index.js.map +0 -1
- package/lib/error/index.d.ts +0 -3
- package/lib/error/index.js +0 -2
- package/lib/error/index.js.map +0 -1
- package/lib/identity/index.d.ts +0 -14
- package/lib/identity/index.js +0 -2
- package/lib/identity/index.js.map +0 -1
- package/lib/index.d.ts +0 -15
- package/lib/index.es.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/object/index.d.ts +0 -13
- package/lib/object/index.js +0 -2
- package/lib/object/index.js.map +0 -1
- package/lib/storage/index.d.ts +0 -96
- package/lib/storage/index.js +0 -2
- package/lib/storage/index.js.map +0 -1
- package/lib/string/index.d.ts +0 -114
- package/lib/string/index.js +0 -2
- package/lib/string/index.js.map +0 -1
- package/lib/vue/emits.d.ts +0 -8
- package/lib/vue/emits.js +0 -2
- package/lib/vue/emits.js.map +0 -1
- package/lib/vue/expose.d.ts +0 -4
- package/lib/vue/expose.js +0 -2
- package/lib/vue/expose.js.map +0 -1
- package/lib/vue/func.d.ts +0 -6
- package/lib/vue/func.js +0 -2
- package/lib/vue/func.js.map +0 -1
- package/lib/vue/index.d.ts +0 -8
- package/lib/vue/index.js +0 -2
- package/lib/vue/index.js.map +0 -1
- package/lib/vue/install.d.ts +0 -5
- package/lib/vue/install.js +0 -2
- package/lib/vue/install.js.map +0 -1
- package/lib/vue/props.d.ts +0 -9
- package/lib/vue/props.js +0 -2
- package/lib/vue/props.js.map +0 -1
- package/lib/vue/slots.d.ts +0 -11
- package/lib/vue/slots.js +0 -2
- package/lib/vue/slots.js.map +0 -1
- package/lib/vue/useRender.d.ts +0 -6
- package/lib/vue/useRender.js +0 -2
- package/lib/vue/useRender.js.map +0 -1
- package/lib/vue/with.d.ts +0 -5
- package/lib/vue/with.js +0 -2
- package/lib/vue/with.js.map +0 -1
package/lib/click/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/click/index.ts"],"sourcesContent":["let _debounceTimeout: ReturnType<typeof setTimeout> | null = null;\nlet _throttleRunning = false;\n\n/**\n * 点击工具类\n */\nexport const clickUtil = {\n\t/**\n\t * 防抖\n\t * @param fn - 执行函数\n\t * @param delay - 延时毫秒\n\t * @returns 返回一个新的防抖函数\n\t */\n\tdebounce(fn: () => void, delay = 500): void {\n\t\t// 如果已有定时器,清除它\n\t\tif (_debounceTimeout) {\n\t\t\tclearTimeout(_debounceTimeout);\n\t\t}\n\t\t// 设置新的定时器\n\t\t_debounceTimeout = setTimeout(() => {\n\t\t\t// 调用原函数\n\t\t\tfn();\n\t\t}, delay);\n\t},\n\t/**\n\t * 异步防抖\n\t * @param fn - 执行函数\n\t * @param delay - 延时毫秒\n\t * @returns 返回一个新的防抖函数\n\t */\n\tasync debounceAsync(fn: () => Promise<void>, delay = 500): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// 清除已有定时器\n\t\t\tif (_debounceTimeout) {\n\t\t\t\tclearTimeout(_debounceTimeout);\n\t\t\t}\n\t\t\t// 设置新的定时器\n\t\t\t_debounceTimeout = setTimeout(async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// 调用异步函数 fn\n\t\t\t\t\tawait fn();\n\t\t\t\t\tresolve();\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\t\t\t}, delay);\n\t\t});\n\t},\n\t/**\n\t * 节流\n\t * @param fn - 执行函数\n\t * @param delay - 延时毫秒\n\t * @returns 返回一个新的节流函数\n\t */\n\tthrottle(fn: () => void, delay = 500): void {\n\t\t// 如果节流操作正在运行,直接返回\n\t\tif (_throttleRunning) {\n\t\t\treturn;\n\t\t}\n\t\t// 设置节流状态为运行\n\t\t_throttleRunning = true;\n\t\t// 调用原函数\n\t\tfn();\n\t\t// 设置定时器以重置节流状态\n\t\tsetTimeout(() => {\n\t\t\t_throttleRunning = false;\n\t\t}, delay);\n\t},\n\t/**\n\t * 异步节流\n\t * @param fn - 执行函数\n\t * @param delay - 延时毫秒\n\t * @returns 返回一个新的节流函数\n\t */\n\tasync throttleAsync(fn: () => Promise<void>, delay = 500): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// 如果节流操作正在进行,直接返回\n\t\t\tif (_throttleRunning) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// 设置节流状态为运行\n\t\t\t_throttleRunning = true;\n\t\t\t// 调用原函数\n\t\t\tfn()\n\t\t\t\t.then(() => {\n\t\t\t\t\tresolve();\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\treject(error);\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\t// 设置定时器以重置节流状态\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t_throttleRunning = false;\n\t\t\t\t\t}, delay);\n\t\t\t\t});\n\t\t});\n\t},\n};\n"],"names":["_debounceTimeout","_throttleRunning","clickUtil","debounce","fn","delay","clearTimeout","setTimeout","async","Promise","resolve","reject","error","throttle","then","catch","finally"],"mappings":"gFAAA,IAAIA,EAAyD,KACzDC,GAAmB,EAKhB,MAAMC,EAAY,CAOxB,QAAAC,CAASC,EAAgBC,EAAQ,KAE5BL,GACHM,aAAaN,GAGdA,EAAmBO,WAAW,KAE7BH,KACEC,EACJ,EAOAG,cAAM,MAAcJ,EAAyBC,EAAQ,MAC7C,IAAII,QAAQ,CAACC,EAASC,KAExBX,GACHM,aAAaN,GAGdA,EAAmBO,WAAWC,UAC7B,UAEOJ,IACNM,GACD,OAASE,GACRD,EAAOC,EACR,GACEP,KASL,QAAAQ,CAAST,EAAgBC,EAAQ,KAE5BJ,IAIJA,GAAmB,EAEnBG,IAEAG,WAAW,KACVN,GAAmB,GACjBI,GACJ,EAOAG,cAAM,MAAcJ,EAAyBC,EAAQ,MAC7C,IAAII,QAAQ,CAACC,EAASC,KAExBV,IAIJA,GAAmB,EAEnBG,IACEU,KAAK,KACLJ,MAEAK,MAAOH,IACPD,EAAOC,KAEPI,QAAQ,KAERT,WAAW,KACVN,GAAmB,GACjBI"}
|
package/lib/color/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 颜色工具类
|
|
3
|
-
*/
|
|
4
|
-
export declare const colorUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* hex颜色转rgb颜色
|
|
7
|
-
* @param str 颜色值字符串
|
|
8
|
-
* @returns 返回处理后的颜色值
|
|
9
|
-
*/
|
|
10
|
-
hexToRgb(str: any): any;
|
|
11
|
-
/**
|
|
12
|
-
* rgb颜色转Hex颜色
|
|
13
|
-
* @param r 代表红色
|
|
14
|
-
* @param g 代表绿色
|
|
15
|
-
* @param b 代表蓝色
|
|
16
|
-
* @returns 返回处理后的颜色值
|
|
17
|
-
*/
|
|
18
|
-
rgbToHex(r: any, g: any, b: any): string;
|
|
19
|
-
/**
|
|
20
|
-
* 加深颜色值
|
|
21
|
-
* @param color 颜色值字符串
|
|
22
|
-
* @param level 加深的程度,限0-1之间
|
|
23
|
-
* @returns 返回处理后的颜色值
|
|
24
|
-
*/
|
|
25
|
-
getDarkColor(color: string, level: number): string;
|
|
26
|
-
/**
|
|
27
|
-
* 变浅颜色值
|
|
28
|
-
* @param color 颜色值字符串
|
|
29
|
-
* @param level 加深的程度,限0-1之间
|
|
30
|
-
* @returns 返回处理后的颜色值
|
|
31
|
-
*/
|
|
32
|
-
getLightColor(color: string, level: number): string;
|
|
33
|
-
};
|
package/lib/color/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../error/index.js"),r={hexToRgb(r){let e="";if(!/^#?[0-9A-F]{6}$/i.test(r))throw new t.FastError("输入错误的hex");e=(r=r.replace("#","")).match(/../g);for(let t=0;t<3;t++)e[t]=parseInt(e[t],16);return e},rgbToHex(r,e,o){const s=/^\d{1,3}$/;if(!s.test(r)||!s.test(e)||!s.test(o))throw new t.FastError("输入错误的rgb颜色值");const n=[r.toString(16),e.toString(16),o.toString(16)];for(let t=0;t<3;t++)1===n[t].length&&(n[t]=`0${n[t]}`);return`#${n.join("")}`},getDarkColor(r,e){if(!/^#?[0-9A-F]{6}$/i.test(r))throw new t.FastError("输入错误的hex颜色值");const o=this.hexToRgb(r);for(let t=0;t<3;t++)o[t]=Math.round(20.5*e+o[t]*(1-e));return this.rgbToHex(o[0],o[1],o[2])},getLightColor(r,e){if(!/^#?[0-9A-F]{6}$/i.test(r))throw new t.FastError("输入错误的hex颜色值");const o=this.hexToRgb(r);for(let t=0;t<3;t++)o[t]=Math.round(255*e+o[t]*(1-e));return this.rgbToHex(o[0],o[1],o[2])}};exports.colorUtil=r;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/color/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/color/index.ts"],"sourcesContent":["import { FastError } from \"../error\";\n\n/**\n * 颜色工具类\n */\nexport const colorUtil = {\n\t/**\n\t * hex颜色转rgb颜色\n\t * @param str 颜色值字符串\n\t * @returns 返回处理后的颜色值\n\t */\n\thexToRgb(str: any): any {\n\t\tlet hex: any = \"\";\n\t\tconst reg = /^#?[0-9A-F]{6}$/i;\n\t\tif (!reg.test(str)) throw new FastError(\"输入错误的hex\");\n\t\tstr = str.replace(\"#\", \"\");\n\t\thex = str.match(/../g);\n\t\tfor (let i = 0; i < 3; i++) hex[i] = parseInt(hex[i], 16);\n\t\treturn hex;\n\t},\n\t/**\n\t * rgb颜色转Hex颜色\n\t * @param r 代表红色\n\t * @param g 代表绿色\n\t * @param b 代表蓝色\n\t * @returns 返回处理后的颜色值\n\t */\n\trgbToHex(r: any, g: any, b: any): string {\n\t\tconst reg = /^\\d{1,3}$/;\n\t\tif (!reg.test(r) || !reg.test(g) || !reg.test(b)) throw new FastError(\"输入错误的rgb颜色值\");\n\t\tconst hex = [r.toString(16), g.toString(16), b.toString(16)];\n\t\tfor (let i = 0; i < 3; i++) if (hex[i].length === 1) hex[i] = `0${hex[i]}`;\n\t\treturn `#${hex.join(\"\")}`;\n\t},\n\t/**\n\t * 加深颜色值\n\t * @param color 颜色值字符串\n\t * @param level 加深的程度,限0-1之间\n\t * @returns 返回处理后的颜色值\n\t */\n\tgetDarkColor(color: string, level: number): string {\n\t\tconst reg = /^#?[0-9A-F]{6}$/i;\n\t\tif (!reg.test(color)) throw new FastError(\"输入错误的hex颜色值\");\n\t\tconst rgb = this.hexToRgb(color);\n\t\tfor (let i = 0; i < 3; i++) rgb[i] = Math.round(20.5 * level + rgb[i] * (1 - level));\n\t\treturn this.rgbToHex(rgb[0], rgb[1], rgb[2]);\n\t},\n\t/**\n\t * 变浅颜色值\n\t * @param color 颜色值字符串\n\t * @param level 加深的程度,限0-1之间\n\t * @returns 返回处理后的颜色值\n\t */\n\tgetLightColor(color: string, level: number): string {\n\t\tconst reg = /^#?[0-9A-F]{6}$/i;\n\t\tif (!reg.test(color)) throw new FastError(\"输入错误的hex颜色值\");\n\t\tconst rgb = this.hexToRgb(color);\n\t\tfor (let i = 0; i < 3; i++) rgb[i] = Math.round(255 * level + rgb[i] * (1 - level));\n\t\treturn this.rgbToHex(rgb[0], rgb[1], rgb[2]);\n\t},\n};\n"],"names":["colorUtil","hexToRgb","str","hex","test","FastError","replace","match","i","parseInt","rgbToHex","r","g","b","reg","toString","length","join","getDarkColor","color","level","rgb","this","Math","round","getLightColor"],"mappings":"qHAKaA,EAAY,CAMxB,QAAAC,CAASC,GACR,IAAIC,EAAW,GAEf,IADY,mBACHC,KAAKF,GAAM,MAAM,IAAIG,EAAAA,UAAU,YAExCF,GADAD,EAAMA,EAAII,QAAQ,IAAK,KACbC,MAAM,OAChB,IAAA,IAASC,EAAI,EAAGA,EAAI,EAAGA,IAAKL,EAAIK,GAAKC,SAASN,EAAIK,GAAI,IACtD,OAAOL,CACR,EAQA,QAAAO,CAASC,EAAQC,EAAQC,GACxB,MAAMC,EAAM,YACZ,IAAKA,EAAIV,KAAKO,KAAOG,EAAIV,KAAKQ,KAAOE,EAAIV,KAAKS,SAAU,IAAIR,EAAAA,UAAU,eACtE,MAAMF,EAAM,CAACQ,EAAEI,SAAS,IAAKH,EAAEG,SAAS,IAAKF,EAAEE,SAAS,KACxD,IAAA,IAASP,EAAI,EAAGA,EAAI,EAAGA,IAA2B,IAAlBL,EAAIK,GAAGQ,SAAcb,EAAIK,GAAK,IAAIL,EAAIK,MACtE,MAAO,IAAIL,EAAIc,KAAK,KACrB,EAOA,YAAAC,CAAaC,EAAeC,GAE3B,IADY,mBACHhB,KAAKe,GAAQ,MAAM,IAAId,EAAAA,UAAU,eAC1C,MAAMgB,EAAMC,KAAKrB,SAASkB,GAC1B,IAAA,IAASX,EAAI,EAAGA,EAAI,EAAGA,MAASA,GAAKe,KAAKC,MAAM,KAAOJ,EAAQC,EAAIb,IAAM,EAAIY,IAC7E,OAAOE,KAAKZ,SAASW,EAAI,GAAIA,EAAI,GAAIA,EAAI,GAC1C,EAOA,aAAAI,CAAcN,EAAeC,GAE5B,IADY,mBACHhB,KAAKe,GAAQ,MAAM,IAAId,EAAAA,UAAU,eAC1C,MAAMgB,EAAMC,KAAKrB,SAASkB,GAC1B,IAAA,IAASX,EAAI,EAAGA,EAAI,EAAGA,MAASA,GAAKe,KAAKC,MAAM,IAAMJ,EAAQC,EAAIb,IAAM,EAAIY,IAC5E,OAAOE,KAAKZ,SAASW,EAAI,GAAIA,EAAI,GAAIA,EAAI,GAC1C"}
|
package/lib/console/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare const useConsole: () => {
|
|
2
|
-
/**
|
|
3
|
-
* 设置 Uni-App 在 APP-PLUS 下是否拆分输出
|
|
4
|
-
*/
|
|
5
|
-
setUniAppPlusSplit(value: boolean): void;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* 打印 Log 日志
|
|
9
|
-
* @param name 来源名称
|
|
10
|
-
*/
|
|
11
|
-
export declare const consoleLog: (name: string, message?: string | false, error?: any) => void;
|
|
12
|
-
/**
|
|
13
|
-
* 打印 Warn 日志
|
|
14
|
-
* @param name 来源名称
|
|
15
|
-
*/
|
|
16
|
-
export declare const consoleWarn: (name: string, message?: string | false, error?: any) => void;
|
|
17
|
-
/**
|
|
18
|
-
* 打印 Debug 日志
|
|
19
|
-
* @param name 来源名称
|
|
20
|
-
*/
|
|
21
|
-
export declare const consoleDebug: (name: string, message?: string | false, error?: any) => void;
|
|
22
|
-
/**
|
|
23
|
-
* 打印 Error 日志
|
|
24
|
-
* @param name 来源名称
|
|
25
|
-
*/
|
|
26
|
-
export declare const consoleError: (name: string, message?: any) => void;
|
|
27
|
-
/**
|
|
28
|
-
* 抛出错误
|
|
29
|
-
* @param name 来源名称
|
|
30
|
-
*/
|
|
31
|
-
export declare const throwError: (name: string, message?: any) => never;
|
package/lib/console/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),e=require("lodash-unified"),o=require("../error/index.js"),s=r.reactive({uniAppPlusSplit:!1}),t=(r,...o)=>{s.uniAppPlusSplit&&"undefined"!=typeof uni&&"undefined"!=typeof plus?o.forEach(o=>{e.isNil(o)||console[r.toLowerCase()](e.isString(o)?o:JSON.stringify(o,null,2))}):console[r.toLowerCase()](...o)},i=r=>(e,o,s)=>{const i=`[Fast-${r}-${e}]`;s?t(r,`${i}${o?` ${o}`:""}`,s):t(r,`${i}${o?` ${o}`:""}`)},n=i("Log"),l=i("Warn"),p=i("Debug");exports.consoleDebug=p,exports.consoleError=(r,s)=>{e.isNil(s)||(e.isString(s)?console.error(new o.FastError(`[Fast-${r}] ${s}`)):t("Error",`[Fast-Error-${r}]`,s))},exports.consoleLog=n,exports.consoleWarn=l,exports.throwError=(r,e)=>{throw new o.FastError(`[Fast-${r}] ${e}`)},exports.useConsole=()=>({setUniAppPlusSplit(r){s.uniAppPlusSplit=r}});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/console/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/console/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { isNil, isString } from \"lodash-unified\";\nimport { FastError } from \"../error\";\n\nconst state = reactive({\n\t/** @description Uni-App 在 APP-PLUS 下是否拆分输出 @default false */\n\tuniAppPlusSplit: false,\n});\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types\nexport const useConsole = () => {\n\treturn {\n\t\t/**\n\t\t * 设置 Uni-App 在 APP-PLUS 下是否拆分输出\n\t\t */\n\t\tsetUniAppPlusSplit(value: boolean): void {\n\t\t\tstate.uniAppPlusSplit = value;\n\t\t},\n\t};\n};\n\ntype LogLevel = \"Log\" | \"Warn\" | \"Debug\" | \"Error\";\n\nconst vConsole = (level: LogLevel, ...args: any[]): void => {\n\tif (state.uniAppPlusSplit) {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tif (typeof plus !== \"undefined\") {\n\t\t\t\t// 循环 arg 参数,每个参数单独输出\n\t\t\t\targs.forEach((item) => {\n\t\t\t\t\tif (isNil(item)) return;\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole[level.toLowerCase()](isString(item) ? item : JSON.stringify(item, null, 2));\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t// eslint-disable-next-line no-console\n\tconsole[level.toLowerCase()](...args);\n};\n\nconst makeConsole = (level: LogLevel) => {\n\treturn (name: string, message?: string | false, error?: any): void => {\n\t\tconst prefix = `[Fast-${level}-${name}]`;\n\t\tif (error) {\n\t\t\tvConsole(level, `${prefix}${message ? ` ${message}` : \"\"}`, error);\n\t\t} else {\n\t\t\tvConsole(level, `${prefix}${message ? ` ${message}` : \"\"}`);\n\t\t}\n\t};\n};\n\n/**\n * 打印 Log 日志\n * @param name 来源名称\n */\nexport const consoleLog = makeConsole(\"Log\");\n\n/**\n * 打印 Warn 日志\n * @param name 来源名称\n */\nexport const consoleWarn = makeConsole(\"Warn\");\n\n/**\n * 打印 Debug 日志\n * @param name 来源名称\n */\nexport const consoleDebug = makeConsole(\"Debug\");\n\n/**\n * 打印 Error 日志\n * @param name 来源名称\n */\nexport const consoleError = (name: string, message?: any): void => {\n\tif (isNil(message)) {\n\t\treturn;\n\t}\n\tif (isString(message)) {\n\t\tconsole.error(new FastError(`[Fast-${name}] ${message}`));\n\t} else {\n\t\tvConsole(\"Error\", `[Fast-Error-${name}]`, message);\n\t}\n};\n\n/**\n * 抛出错误\n * @param name 来源名称\n */\nexport const throwError = (name: string, message?: any): never => {\n\tthrow new FastError(`[Fast-${name}] ${message}`);\n};\n"],"names":["state","reactive","uniAppPlusSplit","vConsole","level","args","uni","plus","forEach","item","isNil","console","toLowerCase","isString","JSON","stringify","makeConsole","name","message","error","prefix","consoleLog","consoleWarn","consoleDebug","FastError","setUniAppPlusSplit","value"],"mappings":"kKAIMA,EAAQC,EAAAA,SAAS,CAEtBC,iBAAiB,IAiBZC,EAAW,CAACC,KAAoBC,KACjCL,EAAME,iBACU,oBAARI,KACU,oBAATC,KAEVF,EAAKG,QAASC,IACTC,EAAAA,MAAMD,IAEVE,QAAQP,EAAMQ,eAAeC,EAAAA,SAASJ,GAAQA,EAAOK,KAAKC,UAAUN,EAAM,KAAM,MAOpFE,QAAQP,EAAMQ,kBAAkBP,IAG3BW,EAAeZ,GACb,CAACa,EAAcC,EAA0BC,KAC/C,MAAMC,EAAS,SAAShB,KAASa,KAC7BE,EACHhB,EAASC,EAAO,GAAGgB,IAASF,EAAU,IAAIA,IAAY,KAAMC,GAE5DhB,EAASC,EAAO,GAAGgB,IAASF,EAAU,IAAIA,IAAY,OAS5CG,EAAaL,EAAY,OAMzBM,EAAcN,EAAY,QAM1BO,EAAeP,EAAY,qDAMZ,CAACC,EAAcC,KACtCR,EAAAA,MAAMQ,KAGNL,EAAAA,SAASK,GACZP,QAAQQ,MAAM,IAAIK,EAAAA,UAAU,SAASP,MAASC,MAE9Cf,EAAS,QAAS,eAAec,KAASC,mEAQlB,CAACD,EAAcC,KACxC,MAAM,IAAIM,EAAAA,UAAU,SAASP,MAASC,yBAhFb,KAClB,CAIN,kBAAAO,CAAmBC,GAClB1B,EAAME,gBAAkBwB,CACzB"}
|
package/lib/crypto/index.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 加密解密
|
|
3
|
-
*/
|
|
4
|
-
export declare const cryptoUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* AES
|
|
7
|
-
*/
|
|
8
|
-
aes: {
|
|
9
|
-
/**
|
|
10
|
-
* AES加密
|
|
11
|
-
* @param dataStr 要加密的字符串
|
|
12
|
-
* @param key 用于加密的密钥
|
|
13
|
-
* @param vector 用于加密的向量(IV)
|
|
14
|
-
* @param cipherMode 加密模式,默认为CBC模式
|
|
15
|
-
*/
|
|
16
|
-
encrypt(dataStr: string, key: string, vector: string, cipherMode?: any): string;
|
|
17
|
-
/**
|
|
18
|
-
* AES解密
|
|
19
|
-
* @param dataStr 要解密的Base64编码字符串
|
|
20
|
-
* @param key 用于解密的密钥
|
|
21
|
-
* @param vector 用于解密的向量(IV)
|
|
22
|
-
* @param cipherMode 解密模式,默认为CBC模式
|
|
23
|
-
*/
|
|
24
|
-
decrypt<T = string>(dataStr: string, key: string, vector: string, cipherMode?: any): T | null;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* SHA1
|
|
28
|
-
*/
|
|
29
|
-
sha1: {
|
|
30
|
-
/**
|
|
31
|
-
* SHA1加密
|
|
32
|
-
* @param dataStr 要加密的字符串
|
|
33
|
-
*/
|
|
34
|
-
encrypt(dataStr: string): string;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* MD5
|
|
38
|
-
*/
|
|
39
|
-
MD5: {
|
|
40
|
-
/**
|
|
41
|
-
* MD5加密
|
|
42
|
-
* @param dataStr 要加密的字符串
|
|
43
|
-
*/
|
|
44
|
-
encrypt(dataStr: string): string;
|
|
45
|
-
};
|
|
46
|
-
};
|
package/lib/crypto/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("crypto-js"),t=require("../console/index.js"),n={aes:{encrypt:(t,n,r,s=e.mode.CBC)=>t?(n.length<32&&(n=n.padEnd(32,"f")),n.length>32&&(n=n.substring(0,32)),r.length<16&&(r=r.padEnd(16,"f")),r.length>16&&(r=r.substring(0,16)),e.AES.encrypt(t,e.enc.Utf8.parse(n),{iv:e.enc.Utf8.parse(r),mode:s}).toString()):t,decrypt(n,r,s,o=e.mode.CBC){if(!n)return null;r.length<32&&(r=r.padEnd(32,"f")),r.length>32&&(r=r.substring(0,32)),s.length<16&&(s=s.padEnd(16,"f")),s.length>16&&(s=s.substring(0,16));const p=e.AES.decrypt(n,e.enc.Utf8.parse(r),{iv:e.enc.Utf8.parse(s),mode:o});try{const t=p.toString(e.enc.Utf8);return JSON.parse(t)}catch(c){return t.consoleError("AESCrypto",c),null}}},sha1:{encrypt:t=>t?e.SHA1(t).toString(e.enc.Hex).toUpperCase():t},MD5:{encrypt:t=>t?e.MD5(t).toString(e.enc.Hex).toUpperCase():t}};exports.cryptoUtil=n;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/crypto/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/crypto/index.ts"],"sourcesContent":["import { AES, MD5, SHA1, enc, mode } from \"crypto-js\";\nimport { consoleError } from \"../console\";\n\n/**\n * 加密解密\n */\nexport const cryptoUtil = {\n\t/**\n\t * AES\n\t */\n\taes: {\n\t\t/**\n\t\t * AES加密\n\t\t * @param dataStr 要加密的字符串\n\t\t * @param key 用于加密的密钥\n\t\t * @param vector 用于加密的向量(IV)\n\t\t * @param cipherMode 加密模式,默认为CBC模式\n\t\t */\n\t\tencrypt(dataStr: string, key: string, vector: string, cipherMode: any = mode.CBC): string {\n\t\t\tif (!dataStr) {\n\t\t\t\treturn dataStr;\n\t\t\t}\n\n\t\t\t// 处理Key不足32位的问题\n\t\t\tif (key.length < 32) {\n\t\t\t\t// 不足\n\t\t\t\tkey = key.padEnd(32, \"f\");\n\t\t\t}\n\n\t\t\t// 处理Key超过32位的问题\n\t\t\tif (key.length > 32) {\n\t\t\t\t// 超过\n\t\t\t\tkey = key.substring(0, 32);\n\t\t\t}\n\n\t\t\t// 处理IV不足16位的问题\n\t\t\tif (vector.length < 16) {\n\t\t\t\t// 不足\n\t\t\t\tvector = vector.padEnd(16, \"f\");\n\t\t\t}\n\n\t\t\t// 处理IV超过16位的问题\n\t\t\tif (vector.length > 16) {\n\t\t\t\t// 超过\n\t\t\t\tvector = vector.substring(0, 16);\n\t\t\t}\n\n\t\t\treturn AES.encrypt(dataStr, enc.Utf8.parse(key), {\n\t\t\t\tiv: enc.Utf8.parse(vector),\n\t\t\t\tmode: cipherMode,\n\t\t\t}).toString();\n\t\t},\n\t\t/**\n\t\t * AES解密\n\t\t * @param dataStr 要解密的Base64编码字符串\n\t\t * @param key 用于解密的密钥\n\t\t * @param vector 用于解密的向量(IV)\n\t\t * @param cipherMode 解密模式,默认为CBC模式\n\t\t */\n\t\tdecrypt<T = string>(dataStr: string, key: string, vector: string, cipherMode: any = mode.CBC): T | null {\n\t\t\tif (!dataStr) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// 处理Key不足32位的问题\n\t\t\tif (key.length < 32) {\n\t\t\t\t// 不足\n\t\t\t\tkey = key.padEnd(32, \"f\");\n\t\t\t}\n\n\t\t\t// 处理Key超过32位的问题\n\t\t\tif (key.length > 32) {\n\t\t\t\t// 超过\n\t\t\t\tkey = key.substring(0, 32);\n\t\t\t}\n\n\t\t\t// 处理IV不足16位的问题\n\t\t\tif (vector.length < 16) {\n\t\t\t\t// 不足\n\t\t\t\tvector = vector.padEnd(16, \"f\");\n\t\t\t}\n\n\t\t\t// 处理IV超过16位的问题\n\t\t\tif (vector.length > 16) {\n\t\t\t\t// 超过\n\t\t\t\tvector = vector.substring(0, 16);\n\t\t\t}\n\n\t\t\tconst resAESData = AES.decrypt(dataStr, enc.Utf8.parse(key), {\n\t\t\t\tiv: enc.Utf8.parse(vector),\n\t\t\t\tmode: cipherMode,\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tconst result = resAESData.toString(enc.Utf8);\n\t\t\t\treturn JSON.parse(result) as T;\n\t\t\t} catch (error) {\n\t\t\t\tconsoleError(\"AESCrypto\", error);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t},\n\t/**\n\t * SHA1\n\t */\n\tsha1: {\n\t\t/**\n\t\t * SHA1加密\n\t\t * @param dataStr 要加密的字符串\n\t\t */\n\t\tencrypt(dataStr: string): string {\n\t\t\tif (!dataStr) {\n\t\t\t\treturn dataStr;\n\t\t\t}\n\n\t\t\treturn SHA1(dataStr).toString(enc.Hex).toUpperCase();\n\t\t},\n\t},\n\t/**\n\t * MD5\n\t */\n\tMD5: {\n\t\t/**\n\t\t * MD5加密\n\t\t * @param dataStr 要加密的字符串\n\t\t */\n\t\tencrypt(dataStr: string): string {\n\t\t\tif (!dataStr) {\n\t\t\t\treturn dataStr;\n\t\t\t}\n\n\t\t\treturn MD5(dataStr).toString(enc.Hex).toUpperCase();\n\t\t},\n\t},\n};\n"],"names":["cryptoUtil","aes","encrypt","dataStr","key","vector","cipherMode","mode","CBC","length","padEnd","substring","AES","enc","Utf8","parse","iv","toString","decrypt","resAESData","result","JSON","error","consoleError","sha1","SHA1","Hex","toUpperCase","MD5"],"mappings":"8IAMaA,EAAa,CAIzBC,IAAK,CAQJC,SAAQC,EAAiBC,EAAaC,EAAgBC,EAAkBC,EAAAA,KAAKC,MACvEL,GAKDC,EAAIK,OAAS,KAEhBL,EAAMA,EAAIM,OAAO,GAAI,MAIlBN,EAAIK,OAAS,KAEhBL,EAAMA,EAAIO,UAAU,EAAG,KAIpBN,EAAOI,OAAS,KAEnBJ,EAASA,EAAOK,OAAO,GAAI,MAIxBL,EAAOI,OAAS,KAEnBJ,EAASA,EAAOM,UAAU,EAAG,KAGvBC,EAAAA,IAAIV,QAAQC,EAASU,EAAAA,IAAIC,KAAKC,MAAMX,GAAM,CAChDY,GAAIH,EAAAA,IAAIC,KAAKC,MAAMV,GACnBE,KAAMD,IACJW,YA9BKd,EAuCT,OAAAe,CAAoBf,EAAiBC,EAAaC,EAAgBC,EAAkBC,EAAAA,KAAKC,KACxF,IAAKL,EACJ,OAAO,KAIJC,EAAIK,OAAS,KAEhBL,EAAMA,EAAIM,OAAO,GAAI,MAIlBN,EAAIK,OAAS,KAEhBL,EAAMA,EAAIO,UAAU,EAAG,KAIpBN,EAAOI,OAAS,KAEnBJ,EAASA,EAAOK,OAAO,GAAI,MAIxBL,EAAOI,OAAS,KAEnBJ,EAASA,EAAOM,UAAU,EAAG,KAG9B,MAAMQ,EAAaP,EAAAA,IAAIM,QAAQf,EAASU,EAAAA,IAAIC,KAAKC,MAAMX,GAAM,CAC5DY,GAAIH,EAAAA,IAAIC,KAAKC,MAAMV,GACnBE,KAAMD,IAEP,IACC,MAAMc,EAASD,EAAWF,SAASJ,EAAAA,IAAIC,MACvC,OAAOO,KAAKN,MAAMK,EACnB,OAASE,GAER,OADAC,EAAAA,aAAa,YAAaD,GACnB,IACR,CACD,GAKDE,KAAM,CAKLtB,QAAQC,GACFA,EAIEsB,EAAAA,KAAKtB,GAASc,SAASJ,EAAAA,IAAIa,KAAKC,cAH/BxB,GASVyB,IAAK,CAKJ1B,QAAQC,GACFA,EAIEyB,EAAAA,IAAIzB,GAASc,SAASJ,EAAAA,IAAIa,KAAKC,cAH9BxB"}
|
package/lib/date/index.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date工具类
|
|
3
|
-
*/
|
|
4
|
-
export declare const dateUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* 根据当前时间生成问候语
|
|
7
|
-
*/
|
|
8
|
-
getGreet(): string;
|
|
9
|
-
/**
|
|
10
|
-
* 时间处理翻译
|
|
11
|
-
*/
|
|
12
|
-
dateTimeFix(date: number | string | Date | null | undefined): string;
|
|
13
|
-
/**
|
|
14
|
-
* 获取简单的日期时间
|
|
15
|
-
* @returns xxxx-xx-xx 00:00:00
|
|
16
|
-
*/
|
|
17
|
-
getSimpleTime(): Date;
|
|
18
|
-
/**
|
|
19
|
-
* 获取默认时间
|
|
20
|
-
* @param isFuture 是否为未来时间
|
|
21
|
-
* @returns [00:00:00, 23:59:59]
|
|
22
|
-
*/
|
|
23
|
-
getDefaultTime(isFuture?: boolean): Date[];
|
|
24
|
-
/**
|
|
25
|
-
* 获取简单的日期时间范围
|
|
26
|
-
* @param isFuture 是否为未来时间
|
|
27
|
-
*/
|
|
28
|
-
getSimpleShortcuts(isFuture?: boolean): {
|
|
29
|
-
text: string;
|
|
30
|
-
value: () => Date;
|
|
31
|
-
}[];
|
|
32
|
-
/**
|
|
33
|
-
* 获取日期范围
|
|
34
|
-
* @param isFuture 是否为未来时间
|
|
35
|
-
*/
|
|
36
|
-
getShortcuts(isFuture?: boolean): {
|
|
37
|
-
text: string;
|
|
38
|
-
value: () => Date[];
|
|
39
|
-
}[];
|
|
40
|
-
/**
|
|
41
|
-
* 判断传入的时间是否大于当前时间
|
|
42
|
-
*/
|
|
43
|
-
getDisabledDate(time: Date): boolean;
|
|
44
|
-
};
|
package/lib/date/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("lodash-unified"),t={getGreet(){const e=(new Date).getHours();let t="";return t=e<5?"夜深了,注意身体哦!":e<9?"早上好!欢迎回来!":e<12?"上午好!欢迎回来!":e<14?"中午好!欢迎回来!":e<18?"下午好!欢迎回来!":e<24?"晚上好!欢迎回来!":"您好!欢迎回来!",t},dateTimeFix(t){if(e.isNil(t))return"";let s;s="string"==typeof t?new Date(t).getTime():"number"==typeof t?t.toString().length<=10?1e3*t:t:t.getTime();const n=36e5,r=(new Date).getTime(),a=r-s,u=Math.abs(a)/6e4,o=Math.abs(a)/n,D=Math.abs(a)/864e5,l=new Date(r),w=new Date(s),g=12*(l.getFullYear()-w.getFullYear())+(l.getMonth()-w.getMonth()),H=a<0?"后":"前";if(Math.abs(g)>=12){return`${Math.floor(Math.abs(g)/12)}年${H}`}if(Math.abs(g)>=6)return`半年${H}`;if(Math.abs(g)>=1)return`${Math.abs(g)}月${H}`;if(D>=15)return`半月${H}`;if(D>=7){return`${Math.floor(D/7)}周${H}`}return D>=1?`${Math.floor(D)}天${H}`:o>=1?`${Math.floor(o)}小时${H}`:u>=1?`${Math.floor(u)}分钟${H}`:"刚刚"},getSimpleTime(){const e=new Date;return e.setHours(0,0,0),e},getDefaultTime(e=!1){const t=new Date,s=new Date;return e?t.setMonth(t.getMonth()+1):s.setMonth(s.getMonth()-1),s.setHours(0,0,0),t.setHours(23,59,59),[s,t]},getSimpleShortcuts:(e=!1)=>e?[{text:"今天",value:()=>{const e=new Date;return e.setHours(0,0,0),e}},{text:"明天",value:()=>{const e=new Date;return e.setDate(e.getDate()+1),e.setHours(0,0,0),e}},{text:"一周后",value:()=>{const e=new Date;return e.setDate(e.getDate()+7),e.setHours(0,0,0),e}},{text:"一月后",value:()=>{const e=new Date;return e.setMonth(e.getMonth()+1),e.setHours(0,0,0),e}},{text:"一年后",value:()=>{const e=new Date;return e.setFullYear(e.getFullYear()+1),e.setHours(0,0,0),e}}]:[{text:"今天",value:()=>{const e=new Date;return e.setHours(0,0,0),e}},{text:"昨天",value:()=>{const e=new Date;return e.setDate(e.getDate()-1),e.setHours(0,0,0),e}},{text:"一周前",value:()=>{const e=new Date;return e.setDate(e.getDate()-7),e.setHours(0,0,0),e}},{text:"一月前",value:()=>{const e=new Date;return e.setMonth(e.getMonth()-1),e.setHours(0,0,0),e}},{text:"一年前",value:()=>{const e=new Date;return e.setFullYear(e.getFullYear()-1),e.setHours(0,0,0),e}}],getShortcuts:(e=!1)=>e?[{text:"后1天",value:()=>{const e=new Date,t=new Date;return e.setDate(e.getDate()+1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后3天",value:()=>{const e=new Date,t=new Date;return e.setDate(e.getDate()+3),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后1周",value:()=>{const e=new Date,t=new Date;return e.setDate(e.getDate()+7),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后1月",value:()=>{const e=new Date,t=new Date;return e.setMonth(e.getMonth()+1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后3月",value:()=>{const e=new Date,t=new Date;return e.setMonth(e.getMonth()+3),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后6月",value:()=>{const e=new Date,t=new Date;return e.setMonth(e.getMonth()+6),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"后1年",value:()=>{const e=new Date,t=new Date;return e.setFullYear(e.getFullYear()+1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}}]:[{text:"近1天",value:()=>{const e=new Date,t=new Date;return t.setDate(t.getDate()-1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近3天",value:()=>{const e=new Date,t=new Date;return t.setDate(t.getDate()-3),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近1周",value:()=>{const e=new Date,t=new Date;return t.setDate(t.getDate()-7),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近1月",value:()=>{const e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近3月",value:()=>{const e=new Date,t=new Date;return t.setMonth(t.getMonth()-3),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近6月",value:()=>{const e=new Date,t=new Date;return t.setMonth(t.getMonth()-6),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}},{text:"近1年",value:()=>{const e=new Date,t=new Date;return t.setFullYear(t.getFullYear()-1),t.setHours(0,0,0),e.setHours(23,59,59),[t,e]}}],getDisabledDate:e=>e.getTime()>Date.now()};exports.dateUtil=t;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/date/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/date/index.ts"],"sourcesContent":["import { isNil } from \"lodash-unified\";\n\n/**\n * Date工具类\n */\nexport const dateUtil = {\n\t/**\n\t * 根据当前时间生成问候语\n\t */\n\tgetGreet(): string {\n\t\tconst now = new Date();\n\t\tconst hour = now.getHours();\n\t\tlet greet = \"\";\n\n\t\tif (hour < 5) {\n\t\t\tgreet = \"夜深了,注意身体哦!\";\n\t\t} else if (hour < 9) {\n\t\t\tgreet = \"早上好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 12) {\n\t\t\tgreet = \"上午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 14) {\n\t\t\tgreet = \"中午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 18) {\n\t\t\tgreet = \"下午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 24) {\n\t\t\tgreet = \"晚上好!\" + \"欢迎回来!\";\n\t\t} else {\n\t\t\tgreet = \"您好!\" + \"欢迎回来!\";\n\t\t}\n\t\treturn greet;\n\t},\n\t/**\n\t * 时间处理翻译\n\t */\n\tdateTimeFix(date: number | string | Date | null | undefined): string {\n\t\tif (isNil(date)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// 获取时间戳\n\t\tlet timestamp: number;\n\t\tif (typeof date === \"string\") {\n\t\t\ttimestamp = new Date(date).getTime();\n\t\t} else if (typeof date === \"number\") {\n\t\t\t// 更安全的秒级时间戳判断:小于10位数字认为是秒级\n\t\t\ttimestamp = date.toString().length <= 10 ? date * 1000 : date;\n\t\t} else {\n\t\t\ttimestamp = date.getTime();\n\t\t}\n\n\t\tconst minute = 1000 * 60;\n\t\tconst hour = minute * 60;\n\t\tconst day = hour * 24;\n\n\t\t// 获取当前时间\n\t\tconst curTime = new Date().getTime();\n\t\t// 计算差异\n\t\tconst diffValue = curTime - timestamp;\n\n\t\t// 计算差异时间的量级\n\t\tconst minC = Math.abs(diffValue) / minute;\n\t\tconst hourC = Math.abs(diffValue) / hour;\n\t\tconst dayC = Math.abs(diffValue) / day;\n\n\t\t// 使用Date对象来准确计算月份和年份差异\n\t\tconst curDate = new Date(curTime);\n\t\tconst targetDate = new Date(timestamp);\n\n\t\tconst yearDiff = curDate.getFullYear() - targetDate.getFullYear();\n\t\tconst monthDiff = curDate.getMonth() - targetDate.getMonth();\n\t\tconst totalMonthDiff = yearDiff * 12 + monthDiff;\n\n\t\t// 时间后缀\n\t\tconst suffix = diffValue < 0 ? \"后\" : \"前\";\n\n\t\t// 计算显示逻辑\n\t\tif (Math.abs(totalMonthDiff) >= 12) {\n\t\t\tconst years = Math.floor(Math.abs(totalMonthDiff) / 12);\n\t\t\treturn `${years}年${suffix}`;\n\t\t} else if (Math.abs(totalMonthDiff) >= 6) {\n\t\t\treturn `半年${suffix}`;\n\t\t} else if (Math.abs(totalMonthDiff) >= 1) {\n\t\t\treturn `${Math.abs(totalMonthDiff)}月${suffix}`;\n\t\t} else if (dayC >= 15) {\n\t\t\treturn `半月${suffix}`;\n\t\t} else if (dayC >= 7) {\n\t\t\tconst weeks = Math.floor(dayC / 7);\n\t\t\treturn `${weeks}周${suffix}`;\n\t\t} else if (dayC >= 1) {\n\t\t\treturn `${Math.floor(dayC)}天${suffix}`;\n\t\t} else if (hourC >= 1) {\n\t\t\treturn `${Math.floor(hourC)}小时${suffix}`;\n\t\t} else if (minC >= 1) {\n\t\t\treturn `${Math.floor(minC)}分钟${suffix}`;\n\t\t}\n\n\t\treturn \"刚刚\";\n\t},\n\t/**\n\t * 获取简单的日期时间\n\t * @returns xxxx-xx-xx 00:00:00\n\t */\n\tgetSimpleTime(): Date {\n\t\tconst start = new Date();\n\t\tstart.setHours(0, 0, 0);\n\t\treturn start;\n\t},\n\t/**\n\t * 获取默认时间\n\t * @param isFuture 是否为未来时间\n\t * @returns [00:00:00, 23:59:59]\n\t */\n\tgetDefaultTime(isFuture = false): Date[] {\n\t\tconst end = new Date();\n\t\tconst start = new Date();\n\t\tif (isFuture) {\n\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t} else {\n\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t}\n\t\tstart.setHours(0, 0, 0);\n\t\tend.setHours(23, 59, 59);\n\t\treturn [start, end];\n\t},\n\t/**\n\t * 获取简单的日期时间范围\n\t * @param isFuture 是否为未来时间\n\t */\n\tgetSimpleShortcuts(isFuture = false): {\n\t\ttext: string;\n\t\tvalue: () => Date;\n\t}[] {\n\t\tif (isFuture) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttext: \"今天\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"明天\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setDate(date.getDate() + 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一周后\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setDate(date.getDate() + 7);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一月后\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setMonth(date.getMonth() + 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一年后\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setFullYear(date.getFullYear() + 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttext: \"今天\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"昨天\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setDate(date.getDate() - 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一周前\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setDate(date.getDate() - 7);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一月前\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setMonth(date.getMonth() - 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"一年前\",\n\t\t\t\t\tvalue: (): Date => {\n\t\t\t\t\t\tconst date = new Date();\n\t\t\t\t\t\tdate.setFullYear(date.getFullYear() - 1);\n\t\t\t\t\t\tdate.setHours(0, 0, 0);\n\t\t\t\t\t\treturn date;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t},\n\t/**\n\t * 获取日期范围\n\t * @param isFuture 是否为未来时间\n\t */\n\tgetShortcuts(isFuture = false): {\n\t\ttext: string;\n\t\tvalue: () => Date[];\n\t}[] {\n\t\tif (isFuture) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttext: \"后1天\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setDate(end.getDate() + 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后3天\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setDate(end.getDate() + 3);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后1周\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setDate(end.getDate() + 7);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后1月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后3月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 3);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后6月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 6);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"后1年\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\ttext: \"近1天\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setDate(start.getDate() - 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近3天\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setDate(start.getDate() - 3);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近1周\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setDate(start.getDate() - 7);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近1月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近3月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 3);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近6月\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 6);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: \"近1年\",\n\t\t\t\t\tvalue: (): Date[] => {\n\t\t\t\t\t\tconst end = new Date();\n\t\t\t\t\t\tconst start = new Date();\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 1);\n\t\t\t\t\t\tstart.setHours(0, 0, 0);\n\t\t\t\t\t\tend.setHours(23, 59, 59);\n\t\t\t\t\t\treturn [start, end];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t},\n\t/**\n\t * 判断传入的时间是否大于当前时间\n\t */\n\tgetDisabledDate(time: Date): boolean {\n\t\treturn time.getTime() > Date.now();\n\t},\n};\n"],"names":["dateUtil","getGreet","hour","Date","getHours","greet","dateTimeFix","date","isNil","timestamp","getTime","toString","length","minute","curTime","diffValue","minC","Math","abs","hourC","dayC","curDate","targetDate","totalMonthDiff","getFullYear","getMonth","suffix","floor","getSimpleTime","start","setHours","getDefaultTime","isFuture","end","setMonth","getSimpleShortcuts","text","value","setDate","getDate","setFullYear","getShortcuts","getDisabledDate","time","now"],"mappings":"kHAKaA,EAAW,CAIvB,QAAAC,GACC,MACMC,OADUC,MACCC,WACjB,IAAIC,EAAQ,GAiBZ,OAdCA,EADGH,EAAO,EACF,aACEA,EAAO,EACT,YACEA,EAAO,GACT,YACEA,EAAO,GACT,YACEA,EAAO,GACT,YACEA,EAAO,GACT,YAEA,WAEFG,CACR,EAIA,WAAAC,CAAYC,GACX,GAAIC,EAAAA,MAAMD,GACT,MAAO,GAIR,IAAIE,EAEHA,EADmB,iBAATF,EACE,IAAIJ,KAAKI,GAAMG,UACD,iBAATH,EAELA,EAAKI,WAAWC,QAAU,GAAY,IAAPL,EAAcA,EAE7CA,EAAKG,UAGlB,MACMR,EAAOW,KAIPC,GAAA,IAAcX,MAAOO,UAErBK,EAAYD,EAAUL,EAGtBO,EAAOC,KAAKC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IlB,OAHA0B,EAAMK,SAASL,EAAMJ,WAAa,GAClCI,EAAMC,SAAS,EAAG,EAAG,GACrBG,EAAIH,SAAS,GAAI,GAAI,IACd,CAACD,EAAOI,KAGjB,CACCG,KAAM,MACNC,MAAO,KACN,MAAMJ,MAAU9B,KACV0B,MAAY1B,KAIlB,OAHA0B,EAAMW,YAAYX,EAAML,cAAgB,GACxCK,EAAMC,SAAS,EAAG,EAAG,GACrBG,EAAIH,SAAS,GAAI,GAAI,IACd,CAACD,EAAOI,MASpBS,gBAAgBC,GACRA,EAAKjC,UAAYP,KAAKyC"}
|
package/lib/dom/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './style';
|
package/lib/dom/index.js
DELETED
package/lib/dom/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/dom/style.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 添加单位
|
|
3
|
-
* @param value 字符串或数字类型
|
|
4
|
-
* @param defaultUnit 单位
|
|
5
|
-
*/
|
|
6
|
-
export declare const addUnit: (value?: string | number, defaultUnit?: string) => string;
|
|
7
|
-
/**
|
|
8
|
-
* 将样式对象转换为内联 style 字符串(kebab-case 格式)
|
|
9
|
-
* @param style 样式对象(CSSStyleDeclaration)
|
|
10
|
-
* @returns 返回符合 HTML 内联格式的样式字符串,例如 "font-size: 14px; color: red;"
|
|
11
|
-
*/
|
|
12
|
-
export declare const styleToString: (styles: Partial<CSSStyleDeclaration> | Partial<CSSStyleDeclaration>[] | string) => string;
|
package/lib/dom/style.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("lodash-unified"),r=require("../console/index.js"),i=r=>r?e.isArray(r)?r.filter(e=>e&&e?.length>0).map(e=>i(e)).join(" "):e.isString(r)?r.trimEnd().endsWith(";")?r.trimEnd():`${r.trimEnd()};`:Object.entries(r).filter(([e,r])=>null!==r&&""!==r).map(([e,r])=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${r};`).join(" "):"";exports.addUnit=(i,t="px")=>{return i?e.isNumber(i)||(n=i,e.isString(n)&&!Number.isNaN(Number(n)))?`${i}${t}`:e.isString(i)?i:void r.consoleWarn("document","binding value must be a string or number"):"";var n},exports.styleToString=i;
|
|
2
|
-
//# sourceMappingURL=style.js.map
|
package/lib/dom/style.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../../src/dom/style.ts"],"sourcesContent":["import { isArray, isNumber, isString } from \"lodash-unified\";\nimport { consoleWarn } from \"../console\";\n\nconst isStringNumber = (val: string): boolean => {\n\tif (!isString(val)) {\n\t\treturn false;\n\t}\n\treturn !Number.isNaN(Number(val));\n};\n\n/**\n * 添加单位\n * @param value 字符串或数字类型\n * @param defaultUnit 单位\n */\nexport const addUnit = (value?: string | number, defaultUnit = \"px\"): string => {\n\tif (!value) return \"\";\n\tif (isNumber(value) || isStringNumber(value)) {\n\t\treturn `${value}${defaultUnit}`;\n\t} else if (isString(value)) {\n\t\treturn value;\n\t}\n\tconsoleWarn(\"document\", \"binding value must be a string or number\");\n};\n\n/**\n * 将样式对象转换为内联 style 字符串(kebab-case 格式)\n * @param style 样式对象(CSSStyleDeclaration)\n * @returns 返回符合 HTML 内联格式的样式字符串,例如 \"font-size: 14px; color: red;\"\n */\nexport const styleToString = (styles: Partial<CSSStyleDeclaration> | Partial<CSSStyleDeclaration>[] | string): string => {\n\tif (!styles) return \"\";\n\tif (isArray(styles)) {\n\t\treturn styles\n\t\t\t.filter((item) => item && item?.length > 0)\n\t\t\t.map((item) => styleToString(item))\n\t\t\t.join(\" \");\n\t} else if (isString(styles)) {\n\t\treturn styles.trimEnd().endsWith(\";\") ? styles.trimEnd() : `${styles.trimEnd()};`;\n\t} else {\n\t\treturn Object.entries(styles)\n\t\t\t.filter(([_, value]) => value !== null && value !== \"\")\n\t\t\t.map(([key, value]) => {\n\t\t\t\tconst keyName = key.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\t\t\t\treturn `${keyName}:${value};`;\n\t\t\t})\n\t\t\t.join(\" \");\n\t}\n};\n"],"names":["styleToString","styles","isArray","filter","item","length","map","join","isString","trimEnd","endsWith","Object","entries","_","value","key","replace","toLowerCase","defaultUnit","isNumber","val","Number","isNaN","consoleWarn"],"mappings":"mJA8BaA,EAAiBC,GACxBA,EACDC,EAAAA,QAAQD,GACJA,EACLE,OAAQC,GAASA,GAAQA,GAAMC,OAAS,GACxCC,IAAKF,GAASJ,EAAcI,IAC5BG,KAAK,KACGC,WAASP,GACZA,EAAOQ,UAAUC,SAAS,KAAOT,EAAOQ,UAAY,GAAGR,EAAOQ,aAE9DE,OAAOC,QAAQX,GACpBE,OAAO,EAAEU,EAAGC,KAAqB,OAAVA,GAA4B,KAAVA,GACzCR,IAAI,EAAES,EAAKD,KAEJ,GADSC,EAAIC,QAAQ,WAAY,OAAOC,iBAC1BH,MAErBP,KAAK,KAfY,mBAhBE,CAACO,EAAyBI,EAAc,QAC9D,OAAKJ,EACDK,EAAAA,SAASL,KAdUM,EAceN,EAbjCN,EAAAA,SAASY,KAGNC,OAAOC,MAAMD,OAAOD,KAWpB,GAAGN,IAAQI,IACRV,WAASM,GACZA,OAERS,EAAAA,YAAY,WAAY,4CANL,GAbG,IAACH"}
|
package/lib/env/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 环境工具类
|
|
3
|
-
*/
|
|
4
|
-
export declare const envUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* 是否为 Uni 环境
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
isUni(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* 是否为 Web 环境(浏览器环境)
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
isWeb(): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 是否为手机设备
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
isMobile(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* 是否为平板设备
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
isIpad(): boolean;
|
|
25
|
-
};
|
package/lib/env/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={isUni:()=>"undefined"!=typeof uni,isWeb:()=>"undefined"!=typeof window&&void 0!==window.document,isMobile(){if(!this.isWeb())return!1;const e=navigator.userAgent||"";return/Mobile|iPhone|Android.*Mobile|Windows Phone/i.test(e)},isIpad(){if(!this.isWeb())return!1;const e=navigator.userAgent||"";return/iPad|Android(?!.*Mobile)|Tablet/i.test(e)}};exports.envUtil=e;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/env/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/env/index.ts"],"sourcesContent":["/**\n * 环境工具类\n */\nexport const envUtil = {\n\t/**\n\t * 是否为 Uni 环境\n\t * @returns\n\t */\n\tisUni(): boolean {\n\t\treturn typeof uni !== \"undefined\";\n\t},\n\t/**\n\t * 是否为 Web 环境(浏览器环境)\n\t * @returns\n\t */\n\tisWeb(): boolean {\n\t\treturn typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\t},\n\t/**\n\t * 是否为手机设备\n\t * @returns\n\t */\n\tisMobile(): boolean {\n\t\tif (!this.isWeb()) return false;\n\t\tconst ua = navigator.userAgent || \"\";\n\t\t// Windows Phone 也归类为手机\n\t\treturn /Mobile|iPhone|Android.*Mobile|Windows Phone/i.test(ua);\n\t},\n\t/**\n\t * 是否为平板设备\n\t * @returns\n\t */\n\tisIpad(): boolean {\n\t\tif (!this.isWeb()) return false;\n\t\tconst ua = navigator.userAgent || \"\";\n\t\t// iPad 或 Android 平板通常不带 Mobile 字符串\n\t\treturn /iPad|Android(?!.*Mobile)|Tablet/i.test(ua);\n\t},\n};\n"],"names":["envUtil","isUni","uni","isWeb","window","document","isMobile","this","ua","navigator","userAgent","test","isIpad"],"mappings":"gFAGO,MAAMA,EAAU,CAKtBC,MAAA,IACuB,oBAARC,IAMfC,MAAA,IAC0B,oBAAXC,aAAqD,IAApBA,OAAOC,SAMvD,QAAAC,GACC,IAAKC,KAAKJ,QAAS,OAAO,EAC1B,MAAMK,EAAKC,UAAUC,WAAa,GAElC,MAAO,+CAA+CC,KAAKH,EAC5D,EAKA,MAAAI,GACC,IAAKL,KAAKJ,QAAS,OAAO,EAC1B,MAAMK,EAAKC,UAAUC,WAAa,GAElC,MAAO,mCAAmCC,KAAKH,EAChD"}
|
package/lib/error/index.d.ts
DELETED
package/lib/error/index.js
DELETED
package/lib/error/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/error/index.ts"],"sourcesContent":["export class FastError extends Error {\n\tconstructor(m: string) {\n\t\tsuper(m);\n\t\tthis.name = \"FastError\";\n\t}\n}\n"],"names":["FastError","Error","constructor","m","super","this","name"],"mappings":"gFAAO,MAAMA,UAAkBC,MAC9B,WAAAC,CAAYC,GACXC,MAAMD,GACNE,KAAKC,KAAO,WACb"}
|
package/lib/identity/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare const state: {
|
|
2
|
-
cacheKey: string;
|
|
3
|
-
deviceId: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* 生成设备Id
|
|
7
|
-
* @param deviceID 覆盖的设备Id
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
declare const makeIdentity: (deviceID?: string) => string;
|
|
11
|
-
export declare const useIdentity: () => typeof state & {
|
|
12
|
-
makeIdentity: typeof makeIdentity;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
package/lib/identity/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("../storage/index.js"),c=require("../string/index.js"),i=e.reactive({cacheKey:"__DEVICE_ID",deviceId:""}),a=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,d=e=>(e??=i.deviceId,e&&a.test(e)?(t.Local.set(i.cacheKey,e),i.deviceId=e,i.deviceId):(e=t.Local.get(i.cacheKey))&&a.test(e)?(i.deviceId=e,e):(e=c.stringUtil.generateUUID(),t.Local.set(i.cacheKey,e),i.deviceId=e,e));exports.useIdentity=()=>({...i,makeIdentity:d});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/identity/index.ts"],"sourcesContent":["import { reactive } from \"vue\";\nimport { Local } from \"../storage\";\nimport { stringUtil } from \"../string\";\n\nconst state = reactive({\n\tcacheKey: \"__DEVICE_ID\",\n\tdeviceId: \"\",\n});\n\nconst uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/**\n * 生成设备Id\n * @param deviceID 覆盖的设备Id\n * @returns\n */\nconst makeIdentity = (deviceID?: string): string => {\n\tdeviceID ??= state.deviceId;\n\t// 判断是否存在\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tLocal.set(state.cacheKey, deviceID);\n\t\tstate.deviceId = deviceID;\n\t\treturn state.deviceId;\n\t}\n\t// 生成浏览器唯一 UUID\n\tdeviceID = Local.get(state.cacheKey);\n\tif (deviceID && uuidRegExp.test(deviceID)) {\n\t\tstate.deviceId = deviceID;\n\t\treturn deviceID;\n\t}\n\tdeviceID = stringUtil.generateUUID();\n\tLocal.set(state.cacheKey, deviceID);\n\tstate.deviceId = deviceID;\n\treturn deviceID;\n};\n\nexport const useIdentity = (): typeof state & { makeIdentity: typeof makeIdentity } => {\n\treturn {\n\t\t...state,\n\t\tmakeIdentity,\n\t};\n};\n"],"names":["state","reactive","cacheKey","deviceId","uuidRegExp","makeIdentity","deviceID","test","Local","set","get","stringUtil","generateUUID"],"mappings":"wKAIMA,EAAQC,EAAAA,SAAS,CACtBC,SAAU,cACVC,SAAU,KAGLC,EAAa,kEAObC,EAAgBC,IACrBA,IAAaN,EAAMG,SAEfG,GAAYF,EAAWG,KAAKD,IAC/BE,EAAAA,MAAMC,IAAIT,EAAME,SAAUI,GAC1BN,EAAMG,SAAWG,EACVN,EAAMG,WAGdG,EAAWE,EAAAA,MAAME,IAAIV,EAAME,YACXE,EAAWG,KAAKD,IAC/BN,EAAMG,SAAWG,EACVA,IAERA,EAAWK,EAAAA,WAAWC,eACtBJ,EAAAA,MAAMC,IAAIT,EAAME,SAAUI,GAC1BN,EAAMG,SAAWG,EACVA,wBAGmB,KACnB,IACHN,EACHK"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './array';
|
|
2
|
-
export * from './base64';
|
|
3
|
-
export * from './click';
|
|
4
|
-
export * from './color';
|
|
5
|
-
export * from './console';
|
|
6
|
-
export * from './crypto';
|
|
7
|
-
export * from './date';
|
|
8
|
-
export * from './dom';
|
|
9
|
-
export * from './env';
|
|
10
|
-
export * from './error';
|
|
11
|
-
export * from './identity';
|
|
12
|
-
export * from './object';
|
|
13
|
-
export * from './storage';
|
|
14
|
-
export * from './string';
|
|
15
|
-
export * from './vue';
|
package/lib/index.es.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./array/index.js"),r=require("./base64/index.js"),s=require("./click/index.js"),t=require("./color/index.js"),o=require("./console/index.js"),i=require("./crypto/index.js"),n=require("./date/index.js");require("./dom/index.js");const l=require("./env/index.js"),u=require("./error/index.js"),x=require("./identity/index.js"),p=require("./object/index.js"),c=require("./storage/index.js"),a=require("./string/index.js");require("./vue/index.js");const d=require("./dom/style.js"),j=require("./vue/emits.js"),q=require("./vue/expose.js"),U=require("./vue/func.js"),E=require("./vue/install.js"),y=require("./vue/props.js"),v=require("./vue/slots.js"),g=require("./vue/useRender.js"),I=require("./vue/with.js");exports.arrayUtil=e.arrayUtil,exports.base64Util=r.base64Util,exports.clickUtil=s.clickUtil,exports.colorUtil=t.colorUtil,exports.consoleDebug=o.consoleDebug,exports.consoleError=o.consoleError,exports.consoleLog=o.consoleLog,exports.consoleWarn=o.consoleWarn,exports.throwError=o.throwError,exports.useConsole=o.useConsole,exports.cryptoUtil=i.cryptoUtil,exports.dateUtil=n.dateUtil,exports.envUtil=l.envUtil,exports.FastError=u.FastError,exports.useIdentity=x.useIdentity,exports.objectUtil=p.objectUtil,exports.CACHE_EXPIRE_SUFFIX=c.CACHE_EXPIRE_SUFFIX,exports.CACHE_PREFIX=c.CACHE_PREFIX,exports.Local=c.Local,exports.Session=c.Session,exports.useStorage=c.useStorage,exports.stringUtil=a.stringUtil,exports.addUnit=d.addUnit,exports.styleToString=d.styleToString,exports.useEmits=j.useEmits,exports.useExpose=q.useExpose,exports.execFunction=U.execFunction,exports.withInstall=E.withInstall,exports.withInstallDirective=E.withInstallDirective,exports.withNoopInstall=E.withNoopInstall,exports.definePropType=y.definePropType,exports.useProps=y.useProps,exports.makeSlots=v.makeSlots,exports.useRender=g.useRender,exports.withDefineType=I.withDefineType;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/object/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 对象工具类
|
|
3
|
-
*/
|
|
4
|
-
export declare const objectUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* 对象URL参数化
|
|
7
|
-
*/
|
|
8
|
-
objectToQueryString(obj: any): string;
|
|
9
|
-
/**
|
|
10
|
-
* 将外部传入的样式格式化成可读的 CSS 样式。
|
|
11
|
-
*/
|
|
12
|
-
objectToStyle(styles: string | Record<string, any> | Record<string, any>[]): string;
|
|
13
|
-
};
|
package/lib/object/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("lodash-unified"),t=require("../string/index.js"),n={objectToQueryString(e){let t="";for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`);return t},objectToStyle:o=>e.isArray(o)?o.filter(function(e){return null!=e&&""!==e}).map(function(e){return n.objectToStyle(e)}).join(";"):e.isString(o)?o:e.isObject(o)?Object.keys(o).filter(function(e){return null!=o[e]&&""!==o[e]}).map(function(e){return[t.stringUtil.toCamelCase(e),o[e]].join(":")}).join(";"):""};exports.objectUtil=n;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/object/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/object/index.ts"],"sourcesContent":["import { isArray, isObject, isString } from \"lodash-unified\";\nimport { stringUtil } from \"../string\";\n\n/**\n * 对象工具类\n */\nexport const objectUtil = {\n\t/**\n\t * 对象URL参数化\n\t */\n\tobjectToQueryString(obj: any): string {\n\t\tlet params = \"\";\n\t\tfor (const key in obj) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t\t\t\tif (params !== \"\") {\n\t\t\t\t\tparams += \"&\";\n\t\t\t\t}\n\t\t\t\tparams += `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`;\n\t\t\t}\n\t\t}\n\t\treturn params;\n\t},\n\t/**\n\t * 将外部传入的样式格式化成可读的 CSS 样式。\n\t */\n\tobjectToStyle(styles: string | Record<string, any> | Record<string, any>[]): string {\n\t\tif (isArray(styles)) {\n\t\t\treturn styles\n\t\t\t\t.filter(function (item) {\n\t\t\t\t\treturn item != null && item !== \"\";\n\t\t\t\t})\n\t\t\t\t.map(function (item) {\n\t\t\t\t\treturn objectUtil.objectToStyle(item);\n\t\t\t\t})\n\t\t\t\t.join(\";\");\n\t\t}\n\n\t\tif (isString(styles)) {\n\t\t\treturn styles;\n\t\t}\n\n\t\tif (isObject(styles)) {\n\t\t\treturn Object.keys(styles)\n\t\t\t\t.filter(function (key) {\n\t\t\t\t\treturn styles[key] != null && styles[key] !== \"\";\n\t\t\t\t})\n\t\t\t\t.map(function (key) {\n\t\t\t\t\treturn [stringUtil.toCamelCase(key), styles[key]].join(\":\");\n\t\t\t\t})\n\t\t\t\t.join(\";\");\n\t\t}\n\n\t\treturn \"\";\n\t},\n};\n"],"names":["objectUtil","objectToQueryString","obj","params","key","Object","prototype","hasOwnProperty","call","encodeURIComponent","objectToStyle","styles","isArray","filter","item","map","join","isString","isObject","keys","stringUtil","toCamelCase"],"mappings":"kJAMaA,EAAa,CAIzB,mBAAAC,CAAoBC,GACnB,IAAIC,EAAS,GACb,IAAA,MAAWC,KAAOF,EACbG,OAAOC,UAAUC,eAAeC,KAAKN,EAAKE,KAC9B,KAAXD,IACHA,GAAU,KAEXA,GAAU,GAAGM,mBAAmBL,MAAQK,mBAAmBP,EAAIE,OAGjE,OAAOD,CACR,EAIAO,cAAcC,GACTC,EAAAA,QAAQD,GACJA,EACLE,OAAO,SAAUC,GACjB,OAAe,MAARA,GAAyB,KAATA,CACxB,GACCC,IAAI,SAAUD,GACd,OAAOd,EAAWU,cAAcI,EACjC,GACCE,KAAK,KAGJC,EAAAA,SAASN,GACLA,EAGJO,EAAAA,SAASP,GACLN,OAAOc,KAAKR,GACjBE,OAAO,SAAUT,GACjB,OAAsB,MAAfO,EAAOP,IAAgC,KAAhBO,EAAOP,EACtC,GACCW,IAAI,SAAUX,GACd,MAAO,CAACgB,EAAAA,WAAWC,YAAYjB,GAAMO,EAAOP,IAAMY,KAAK,IACxD,GACCA,KAAK,KAGD"}
|
package/lib/storage/index.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本地缓存前缀 Key
|
|
3
|
-
*/
|
|
4
|
-
export declare const CACHE_PREFIX: import('vue').ComputedRef<string>;
|
|
5
|
-
/**
|
|
6
|
-
* 本地缓存过期值后缀 Key
|
|
7
|
-
*/
|
|
8
|
-
export declare const CACHE_EXPIRE_SUFFIX: import('vue').ComputedRef<string>;
|
|
9
|
-
export declare const useStorage: () => {
|
|
10
|
-
/**
|
|
11
|
-
* 设置缓存前缀 Key
|
|
12
|
-
* @param key
|
|
13
|
-
*/
|
|
14
|
-
setPrefix(key: string): void;
|
|
15
|
-
/**
|
|
16
|
-
* 缓存过期值后缀 Key
|
|
17
|
-
* @param key
|
|
18
|
-
*/
|
|
19
|
-
setExpireSuffix(key: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* 设置缓存是否加密
|
|
22
|
-
* @description 请在初始化的时候确认,后续不可再修改,否则所有数据都将失效
|
|
23
|
-
* @param crypto
|
|
24
|
-
*/
|
|
25
|
-
setCrypto(crypto: boolean): void;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* window.localStorage
|
|
29
|
-
* - 如果是 UniApp 环境则使用的是 uni.xxxStorage
|
|
30
|
-
*/
|
|
31
|
-
export declare const Local: {
|
|
32
|
-
/**
|
|
33
|
-
* 设置
|
|
34
|
-
* @param key 缓存的Key
|
|
35
|
-
* @param val 缓存值
|
|
36
|
-
* @param expire 过期时间,单位分钟
|
|
37
|
-
* @param encrypt 是否对缓存的数据加密
|
|
38
|
-
*/
|
|
39
|
-
set(key: string, val: any, expire?: number, encrypt?: boolean): void;
|
|
40
|
-
/**
|
|
41
|
-
* 获取
|
|
42
|
-
* @param key 缓存的Key
|
|
43
|
-
* @param decrypt 是否对缓存的数据解密
|
|
44
|
-
* @returns {T} 传入的对象类型,默认为 string
|
|
45
|
-
*/
|
|
46
|
-
get<T = string>(key: string, decrypt?: boolean): T;
|
|
47
|
-
/**
|
|
48
|
-
* 移除
|
|
49
|
-
* @param key 缓存的Key
|
|
50
|
-
*/
|
|
51
|
-
remove(key: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* 根据前缀移除
|
|
54
|
-
* @param key 缓存的Key
|
|
55
|
-
*/
|
|
56
|
-
removeByPrefix(key: string): void;
|
|
57
|
-
/**
|
|
58
|
-
* 移除全部
|
|
59
|
-
*/
|
|
60
|
-
clear(): void;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* window.sessionStorage
|
|
64
|
-
* - UniApp 环境下不可用
|
|
65
|
-
*/
|
|
66
|
-
export declare const Session: {
|
|
67
|
-
/**
|
|
68
|
-
* 设置会话缓存
|
|
69
|
-
* @param key 缓存的Key
|
|
70
|
-
* @param val 缓存值
|
|
71
|
-
* @param expire 过期时间,单位分钟
|
|
72
|
-
* @param encrypt 是否对缓存的数据加密
|
|
73
|
-
*/
|
|
74
|
-
set(key: string, val: any, expire?: number, encrypt?: boolean): void;
|
|
75
|
-
/**
|
|
76
|
-
* 获取会话缓存
|
|
77
|
-
* @param key 缓存的Key
|
|
78
|
-
* @param decrypt 是否对缓存的数据解密
|
|
79
|
-
* @returns {T} 传入的对象类型,默认为 string
|
|
80
|
-
*/
|
|
81
|
-
get<T = string>(key: string, decrypt?: boolean): T;
|
|
82
|
-
/**
|
|
83
|
-
* 移除会话缓存
|
|
84
|
-
* @param key 缓存的Key
|
|
85
|
-
*/
|
|
86
|
-
remove(key: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* 根据前缀移除会话缓存
|
|
89
|
-
* @param key 缓存的Key
|
|
90
|
-
*/
|
|
91
|
-
removeByPrefix(key: string): void;
|
|
92
|
-
/**
|
|
93
|
-
* 移除全部会话缓存
|
|
94
|
-
*/
|
|
95
|
-
clear(): void;
|
|
96
|
-
};
|
package/lib/storage/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),r=require("../base64/index.js"),o=require("../console/index.js"),i=require("../error/index.js"),t=e.reactive({prefix:"fast__",expireSuffix:"__Expire",crypto:!1}),n=e.computed(()=>t.prefix),s=e.computed(()=>t.expireSuffix),f={set(e,r){"undefined"!=typeof uni?uni.setStorageSync(e,r):window.localStorage.setItem(e,r)},get:e=>"undefined"!=typeof uni?uni.getStorageSync(e):window.localStorage.getItem(e),remove(e){"undefined"!=typeof uni?uni.removeStorageSync(e):window.localStorage.removeItem(e)},clear(){"undefined"!=typeof uni?uni.clearStorageSync():window.localStorage.clear()},keys:()=>"undefined"!=typeof uni?uni.getStorageInfoSync().keys:window.localStorage},c={set(e,n,s,c){try{if(c??=t.crypto,s){if(isNaN(s)||s<1)throw new i.FastError("有效期应为一个有效数值");const r={time:Date.now(),expire:s},o=JSON.stringify(r);f.set(`${t.prefix}${e}${t.expireSuffix}`,o)}let o=JSON.stringify(n);c&&(o=r.base64Util.toBase64(o)),f.set(`${t.prefix}${e}`,o)}catch(p){o.consoleError("Local",p)}},get(e,i){try{i??=t.crypto;let o=f.get(`${t.prefix}${e}`);if(o){i&&(o=r.base64Util.base64ToStr(o));const n=f.get(`${t.prefix}${e}${t.expireSuffix}`);if(n){const r=JSON.parse(n);if(Date.now()>r.time+60*r.expire*1e3)return f.remove(`${t.prefix}${e}`),f.remove(`${t.prefix}${e}${t.expireSuffix}`),null}try{return JSON.parse(o)}catch{return o}}return null}catch(n){o.consoleError("Local",n)}},remove(e){try{f.remove(`${t.prefix}${e}`),f.remove(`${t.prefix}${e}${t.expireSuffix}`)}catch(r){o.consoleError("Local",r)}},removeByPrefix(e){try{for(const r in f.keys)-1!==r.indexOf(`${t.prefix}${e}`)&&f.remove(r)}catch(r){o.consoleError("Local",r)}},clear(){try{f.clear()}catch(e){o.consoleError("Local",e)}}},p={set(e,n,s,f){if("undefined"==typeof uni)try{if(f??=t.crypto,s){if(isNaN(s)||s<1)throw new i.FastError("有效期应为一个有效数值");const r={time:Date.now(),expire:s},o=JSON.stringify(r);window.sessionStorage.setItem(`${t.prefix}${e}${t.expireSuffix}`,o)}let o=JSON.stringify(n);f&&(o=r.base64Util.toBase64(o)),window.sessionStorage.setItem(`${t.prefix}${e}`,o)}catch(c){o.consoleError("Session",c)}else o.consoleError("Session","UniApp 环境下 [Session] 不可用。")},get(e,i){if("undefined"==typeof uni)try{i??=t.crypto;let o=window.sessionStorage.getItem(`${t.prefix}${e}`);if(o){i&&(o=r.base64Util.base64ToStr(o));const n=window.sessionStorage.getItem(`${t.prefix}${e}${t.expireSuffix}`);if(n){const r=JSON.parse(n);if(Date.now()>r.time+60*r.expire*1e3)return window.sessionStorage.removeItem(`${t.prefix}${e}`),window.sessionStorage.removeItem(`${t.prefix}${e}${t.expireSuffix}`),null}try{return JSON.parse(o)}catch{return o}}return null}catch(n){o.consoleError("Session",n)}else o.consoleError("Session","UniApp 环境下 [Session] 不可用。")},remove(e){if("undefined"==typeof uni)try{window.sessionStorage.removeItem(`${t.prefix}${e}`),window.sessionStorage.removeItem(`${t.prefix}${e}${t.expireSuffix}`)}catch(r){o.consoleError("Session",r)}else o.consoleError("Session","UniApp 环境下 [Session] 不可用。")},removeByPrefix(e){if("undefined"==typeof uni)try{for(const r in window.sessionStorage)-1!==r.indexOf(`${t.prefix}${e}`)&&window.sessionStorage.removeItem(r)}catch(r){o.consoleError("Session",r)}else o.consoleError("Session","UniApp 环境下 [Session] 不可用。")},clear(){if("undefined"==typeof uni)try{window.sessionStorage.clear()}catch(e){o.consoleError("Session",e)}else o.consoleError("Session","UniApp 环境下 [Session] 不可用。")}};exports.CACHE_EXPIRE_SUFFIX=s,exports.CACHE_PREFIX=n,exports.Local=c,exports.Session=p,exports.useStorage=()=>({setPrefix(e){t.prefix=e},setExpireSuffix(e){t.expireSuffix=e},setCrypto(e){t.crypto=e}});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/storage/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/storage/index.ts"],"sourcesContent":["import { computed, reactive } from \"vue\";\nimport { base64Util } from \"../base64\";\nimport { consoleError } from \"../console\";\nimport { FastError } from \"../error\";\n\nconst state = reactive({\n\tprefix: \"fast__\",\n\texpireSuffix: \"__Expire\",\n\tcrypto: false,\n});\n\n/**\n * 本地缓存前缀 Key\n */\nexport const CACHE_PREFIX = computed(() => state.prefix);\n\n/**\n * 本地缓存过期值后缀 Key\n */\nexport const CACHE_EXPIRE_SUFFIX = computed(() => state.expireSuffix);\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types\nexport const useStorage = () => {\n\treturn {\n\t\t/**\n\t\t * 设置缓存前缀 Key\n\t\t * @param key\n\t\t */\n\t\tsetPrefix(key: string): void {\n\t\t\tstate.prefix = key;\n\t\t},\n\t\t/**\n\t\t * 缓存过期值后缀 Key\n\t\t * @param key\n\t\t */\n\t\tsetExpireSuffix(key: string): void {\n\t\t\tstate.expireSuffix = key;\n\t\t},\n\t\t/**\n\t\t * 设置缓存是否加密\n\t\t * @description 请在初始化的时候确认,后续不可再修改,否则所有数据都将失效\n\t\t * @param crypto\n\t\t */\n\t\tsetCrypto(crypto: boolean): void {\n\t\t\tstate.crypto = crypto;\n\t\t},\n\t};\n};\n\nconst storage = {\n\tset(key: string, val: any): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tuni.setStorageSync(key, val);\n\t\t} else {\n\t\t\twindow.localStorage.setItem(key, val);\n\t\t}\n\t},\n\tget(key: string): string | any | null {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\treturn uni.getStorageSync(key);\n\t\t} else {\n\t\t\treturn window.localStorage.getItem(key);\n\t\t}\n\t},\n\tremove(key: string): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tuni.removeStorageSync(key);\n\t\t} else {\n\t\t\twindow.localStorage.removeItem(key);\n\t\t}\n\t},\n\tclear(): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tuni.clearStorageSync();\n\t\t} else {\n\t\t\twindow.localStorage.clear();\n\t\t}\n\t},\n\tkeys(): string[] | Storage {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\treturn uni.getStorageInfoSync().keys;\n\t\t} else {\n\t\t\treturn window.localStorage;\n\t\t}\n\t},\n};\n\n/**\n * window.localStorage\n * - 如果是 UniApp 环境则使用的是 uni.xxxStorage\n */\nexport const Local = {\n\t/**\n\t * 设置\n\t * @param key 缓存的Key\n\t * @param val 缓存值\n\t * @param expire 过期时间,单位分钟\n\t * @param encrypt 是否对缓存的数据加密\n\t */\n\tset(key: string, val: any, expire?: number, encrypt?: boolean): void {\n\t\ttry {\n\t\t\tencrypt ??= state.crypto;\n\t\t\t// 判断是否存在缓存过期时间\n\t\t\tif (expire) {\n\t\t\t\tif (isNaN(expire) || expire < 1) {\n\t\t\t\t\tthrow new FastError(\"有效期应为一个有效数值\");\n\t\t\t\t}\n\t\t\t\t// 设置过期时间的缓存\n\t\t\t\tconst expireData = {\n\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\texpire,\n\t\t\t\t};\n\t\t\t\tconst expireJson = JSON.stringify(expireData);\n\t\t\t\tstorage.set(`${state.prefix}${key}${state.expireSuffix}`, expireJson);\n\t\t\t}\n\t\t\tlet valJson = JSON.stringify(val);\n\t\t\tif (encrypt) {\n\t\t\t\tvalJson = base64Util.toBase64(valJson);\n\t\t\t}\n\t\t\tstorage.set(`${state.prefix}${key}`, valJson);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 获取\n\t * @param key 缓存的Key\n\t * @param decrypt 是否对缓存的数据解密\n\t * @returns {T} 传入的对象类型,默认为 string\n\t */\n\tget<T = string>(key: string, decrypt?: boolean): T {\n\t\ttry {\n\t\t\tdecrypt ??= state.crypto;\n\t\t\t// 获取缓存 JSON 字符串\n\t\t\tlet valJson = storage.get(`${state.prefix}${key}`);\n\n\t\t\tif (valJson) {\n\t\t\t\t// 判断是否解密\n\t\t\t\tif (decrypt) {\n\t\t\t\t\tvalJson = base64Util.base64ToStr(valJson);\n\t\t\t\t}\n\t\t\t\t// 尝试获取缓存过期时间的 JSON 字符串\n\t\t\t\tconst expireJson = storage.get(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t\t\t// 判断是否存在过期时间\n\t\t\t\tif (expireJson) {\n\t\t\t\t\tconst expireData = JSON.parse(expireJson);\n\t\t\t\t\tif (Date.now() > expireData.time + expireData.expire * 60 * 1000) {\n\t\t\t\t\t\t// 过期了,删除对应的缓存数据\n\t\t\t\t\t\tstorage.remove(`${state.prefix}${key}`);\n\t\t\t\t\t\tstorage.remove(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(valJson) as T;\n\t\t\t\t} catch {\n\t\t\t\t\treturn valJson as T;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除\n\t * @param key 缓存的Key\n\t */\n\tremove(key: string): void {\n\t\ttry {\n\t\t\tstorage.remove(`${state.prefix}${key}`);\n\t\t\tstorage.remove(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 根据前缀移除\n\t * @param key 缓存的Key\n\t */\n\tremoveByPrefix(key: string): void {\n\t\ttry {\n\t\t\tfor (const itemKey in storage.keys) {\n\t\t\t\tif (itemKey.indexOf(`${state.prefix}${key}`) !== -1) {\n\t\t\t\t\tstorage.remove(itemKey);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除全部\n\t */\n\tclear(): void {\n\t\ttry {\n\t\t\tstorage.clear();\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n};\n\n/**\n * window.sessionStorage\n * - UniApp 环境下不可用\n */\nexport const Session = {\n\t/**\n\t * 设置会话缓存\n\t * @param key 缓存的Key\n\t * @param val 缓存值\n\t * @param expire 过期时间,单位分钟\n\t * @param encrypt 是否对缓存的数据加密\n\t */\n\tset(key: string, val: any, expire?: number, encrypt?: boolean): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tconsoleError(\"Session\", \"UniApp 环境下 [Session] 不可用。\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tencrypt ??= state.crypto;\n\t\t\t// 判断是否存在缓存过期时间\n\t\t\tif (expire) {\n\t\t\t\tif (isNaN(expire) || expire < 1) {\n\t\t\t\t\tthrow new FastError(\"有效期应为一个有效数值\");\n\t\t\t\t}\n\t\t\t\t// 设置过期时间的缓存\n\t\t\t\tconst expireData = {\n\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\texpire,\n\t\t\t\t};\n\t\t\t\tconst expireJson = JSON.stringify(expireData);\n\t\t\t\twindow.sessionStorage.setItem(`${state.prefix}${key}${state.expireSuffix}`, expireJson);\n\t\t\t}\n\t\t\tlet valJson = JSON.stringify(val);\n\t\t\tif (encrypt) {\n\t\t\t\tvalJson = base64Util.toBase64(valJson);\n\t\t\t}\n\t\t\twindow.sessionStorage.setItem(`${state.prefix}${key}`, valJson);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 获取会话缓存\n\t * @param key 缓存的Key\n\t * @param decrypt 是否对缓存的数据解密\n\t * @returns {T} 传入的对象类型,默认为 string\n\t */\n\tget<T = string>(key: string, decrypt?: boolean): T {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tconsoleError(\"Session\", \"UniApp 环境下 [Session] 不可用。\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tdecrypt ??= state.crypto;\n\t\t\t// 获取缓存 JSON 字符串\n\t\t\tlet valJson = window.sessionStorage.getItem(`${state.prefix}${key}`);\n\t\t\tif (valJson) {\n\t\t\t\t// 判断是否解密\n\t\t\t\tif (decrypt) {\n\t\t\t\t\tvalJson = base64Util.base64ToStr(valJson);\n\t\t\t\t}\n\t\t\t\t// 尝试获取缓存过期时间的 JSON 字符串\n\t\t\t\tconst expireJson = window.sessionStorage.getItem(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t\t\t// 判断是否存在过期时间\n\t\t\t\tif (expireJson) {\n\t\t\t\t\tconst expireData = JSON.parse(expireJson);\n\t\t\t\t\tif (Date.now() > expireData.time + expireData.expire * 60 * 1000) {\n\t\t\t\t\t\t// 过期了,删除对应的缓存数据\n\t\t\t\t\t\twindow.sessionStorage.removeItem(`${state.prefix}${key}`);\n\t\t\t\t\t\twindow.sessionStorage.removeItem(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(valJson) as T;\n\t\t\t\t} catch {\n\t\t\t\t\treturn valJson as T;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除会话缓存\n\t * @param key 缓存的Key\n\t */\n\tremove(key: string): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tconsoleError(\"Session\", \"UniApp 环境下 [Session] 不可用。\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\twindow.sessionStorage.removeItem(`${state.prefix}${key}`);\n\t\t\twindow.sessionStorage.removeItem(`${state.prefix}${key}${state.expireSuffix}`);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 根据前缀移除会话缓存\n\t * @param key 缓存的Key\n\t */\n\tremoveByPrefix(key: string): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tconsoleError(\"Session\", \"UniApp 环境下 [Session] 不可用。\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tfor (const itemKey in window.sessionStorage) {\n\t\t\t\tif (itemKey.indexOf(`${state.prefix}${key}`) !== -1) {\n\t\t\t\t\twindow.sessionStorage.removeItem(itemKey);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除全部会话缓存\n\t */\n\tclear(): void {\n\t\tif (typeof uni !== \"undefined\") {\n\t\t\tconsoleError(\"Session\", \"UniApp 环境下 [Session] 不可用。\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\twindow.sessionStorage.clear();\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n};\n"],"names":["state","reactive","prefix","expireSuffix","crypto","CACHE_PREFIX","computed","CACHE_EXPIRE_SUFFIX","storage","set","key","val","uni","setStorageSync","window","localStorage","setItem","get","getStorageSync","getItem","remove","removeStorageSync","removeItem","clear","clearStorageSync","keys","getStorageInfoSync","Local","expire","encrypt","isNaN","FastError","expireData","time","Date","now","expireJson","JSON","stringify","valJson","base64Util","toBase64","error","consoleError","decrypt","base64ToStr","parse","removeByPrefix","itemKey","indexOf","Session","sessionStorage","setPrefix","setExpireSuffix","setCrypto"],"mappings":"uMAKMA,EAAQC,EAAAA,SAAS,CACtBC,OAAQ,SACRC,aAAc,WACdC,QAAQ,IAMIC,EAAeC,EAAAA,SAAS,IAAMN,EAAME,QAKpCK,EAAsBD,EAAAA,SAAS,IAAMN,EAAMG,cA8BlDK,EAAU,CACf,GAAAC,CAAIC,EAAaC,GACG,oBAARC,IACVA,IAAIC,eAA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