youtil 3.1.0-beta3 → 3.1.1
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/README.md +2 -3
- package/dist/index.mjs +14 -14
- package/dist/index.umd.js +14 -14
- package/dist/types/enum.d.ts +19 -11
- package/docs/404.html +20 -12
- package/docs/574.483e4d8b.async.js +15 -0
- package/docs/574.e8c51481.chunk.css +5 -0
- package/docs/762.1d61e7db.async.js +3 -0
- package/docs/831.f94499ec.async.js +137 -0
- package/docs/972.5b978da2.async.js +22 -0
- package/docs/CNAME +1 -1
- package/docs/api/functions/copy-to-clipboard/index.html +24 -0
- package/docs/api/functions/create-enum/index.html +24 -0
- package/docs/api/functions/decode-html/index.html +24 -0
- package/docs/api/functions/deep-copy/index.html +24 -0
- package/docs/api/functions/del-param/index.html +24 -0
- package/docs/api/functions/encode-html/index.html +24 -0
- package/docs/api/functions/format-date/index.html +24 -0
- package/docs/api/functions/format-json/index.html +24 -0
- package/docs/api/functions/get-id-card-last-char/index.html +24 -0
- package/docs/api/functions/get-param/index.html +24 -0
- package/docs/api/functions/get-param-int/index.html +24 -0
- package/docs/api/functions/get-params/index.html +24 -0
- package/docs/api/functions/get-random/index.html +24 -0
- package/docs/api/functions/get-random-str/index.html +24 -0
- package/docs/api/functions/hide-loading/index.html +24 -0
- package/docs/api/functions/init-window-message/index.html +24 -0
- package/docs/api/functions/parse-date/index.html +24 -0
- package/docs/api/functions/request/index.html +20 -12
- package/docs/api/functions/set-param/index.html +24 -0
- package/docs/api/functions/show-loading/index.html +24 -0
- package/docs/api/functions/sleep/index.html +20 -13
- package/docs/api/functions/to-hump/index.html +24 -0
- package/docs/api/functions/to-underline/index.html +24 -0
- package/docs/api/functions/to-url-params/index.html +24 -0
- package/docs/api/functions/validate-id-card/index.html +24 -0
- package/docs/api/globals/index.html +20 -12
- package/docs/api/interfaces/i-request-options/index.html +24 -0
- package/docs/api/interfaces/i-show-loading-config/index.html +24 -0
- package/docs/api/type-aliases/enum-item/index.html +24 -0
- package/docs/api/type-aliases/enum-type/index.html +24 -0
- package/docs/api/variables/key-codes/index.html +24 -0
- package/docs/api/variables/request/index.html +24 -0
- package/docs/dumi__tmp-production__dumi__theme__ContextWrapper.ab2cd1e2.async.js +1 -0
- package/docs/guide/enum/index.html +24 -0
- package/docs/guide/index.html +24 -0
- package/docs/guide/loading/index.html +24 -0
- package/docs/guide/message/index.html +24 -0
- package/docs/guide/request/index.html +24 -0
- package/docs/index.html +20 -12
- package/docs/markdown__api__functions__copyToClipboard.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__copyToClipboard.md.fa13570e.async.js +3 -0
- package/docs/markdown__api__functions__createEnum.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__createEnum.md.ab0957ee.async.js +8 -0
- package/docs/markdown__api__functions__decodeHtml.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__decodeHtml.md.922bf499.async.js +1 -0
- package/docs/markdown__api__functions__deepCopy.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__deepCopy.md.4dea99a7.async.js +1 -0
- package/docs/markdown__api__functions__delParam.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__delParam.md.dc0c2c8a.async.js +4 -0
- package/docs/markdown__api__functions__encodeHtml.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__encodeHtml.md.d4d7ef49.async.js +1 -0
- package/docs/markdown__api__functions__formatDate.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__formatDate.md.e43ecd6d.async.js +1 -0
- package/docs/markdown__api__functions__formatJson.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__formatJson.md.56d52c5d.async.js +2 -0
- package/docs/markdown__api__functions__getIdCardLastChar.md.1a9f4c4c.async.js +1 -0
- package/docs/markdown__api__functions__getIdCardLastChar.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getParam.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getParam.md.65c4baf1.async.js +5 -0
- package/docs/markdown__api__functions__getParamInt.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getParamInt.md.e53ccbcf.async.js +1 -0
- package/docs/markdown__api__functions__getParams.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getParams.md.86dccf75.async.js +2 -0
- package/docs/markdown__api__functions__getRandom.md.2c03a03a.async.js +6 -0
- package/docs/markdown__api__functions__getRandom.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getRandomStr.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__getRandomStr.md.7162c7eb.async.js +1 -0
- package/docs/markdown__api__functions__hideLoading.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__hideLoading.md.63141f59.async.js +1 -0
- package/docs/markdown__api__functions__initWindowMessage.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__initWindowMessage.md.4cecf804.async.js +1 -0
- package/docs/markdown__api__functions__parseDate.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__parseDate.md.43f68864.async.js +1 -0
- package/docs/markdown__api__functions__request.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__request.md.8100475a.async.js +1 -0
- package/docs/markdown__api__functions__setParam.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__setParam.md.6122453b.async.js +3 -0
- package/docs/markdown__api__functions__showLoading.md.23c9d9cf.async.js +1 -0
- package/docs/markdown__api__functions__showLoading.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__sleep.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__sleep.md.65b4d778.async.js +2 -0
- package/docs/markdown__api__functions__toHump.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__toHump.md.a648d9ca.async.js +3 -0
- package/docs/markdown__api__functions__toUnderline.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__toUnderline.md.ab7a4578.async.js +1 -0
- package/docs/markdown__api__functions__toUrlParams.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__toUrlParams.md.de7422f6.async.js +1 -0
- package/docs/markdown__api__functions__validateIdCard.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__functions__validateIdCard.md.ccfc4d2f.async.js +1 -0
- package/docs/markdown__api__globals.md.2389be1f.async.js +1 -0
- package/docs/markdown__api__globals.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__interfaces__IRequestOptions.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__interfaces__IRequestOptions.md.da2c2fdd.async.js +1 -0
- package/docs/markdown__api__interfaces__IShowLoadingConfig.md.09756000.async.js +1 -0
- package/docs/markdown__api__interfaces__IShowLoadingConfig.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__type-aliases__EnumItem.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__type-aliases__EnumItem.md.955a45d6.async.js +1 -0
- package/docs/markdown__api__type-aliases__EnumType.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__type-aliases__EnumType.md.efd1803a.async.js +1 -0
- package/docs/markdown__api__variables__Request.md.1dbabcda.async.js +1 -0
- package/docs/markdown__api__variables__Request.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__variables__keyCodes.md.33be0665.chunk.css +1 -0
- package/docs/markdown__api__variables__keyCodes.md.74858111.async.js +1 -0
- package/docs/markdown__guide__enum.md.33be0665.chunk.css +1 -0
- package/docs/markdown__guide__enum.md.b90b172d.async.js +1 -0
- package/docs/markdown__guide__index.md.33be0665.chunk.css +1 -0
- package/docs/markdown__guide__index.md.896aab37.async.js +13 -0
- package/docs/markdown__guide__loading.md.33be0665.chunk.css +1 -0
- package/docs/markdown__guide__loading.md.512e960b.async.js +1 -0
- package/docs/markdown__guide__message.md.0788a6e2.async.js +84 -0
- package/docs/markdown__guide__message.md.33be0665.chunk.css +1 -0
- package/docs/markdown__guide__request.md.33be0665.chunk.css +1 -0
- package/docs/markdown__guide__request.md.804eed5b.async.js +57 -0
- package/docs/markdown__index.md.33be0665.chunk.css +1 -0
- package/docs/markdown__index.md.9c254237.async.js +1 -0
- package/docs/meta__markdown.3bc0c0cf.async.js +310 -0
- package/docs/nm__dumi__dist__client__pages__404.816f7d6a.async.js +1 -0
- package/docs/nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css +1 -0
- package/docs/nm__dumi__dist__client__pages__Demo__index.088e9a8b.async.js +1 -0
- package/docs/nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css +1 -0
- package/docs/nm__dumi__theme-default__layouts__DocLayout__index.363dcde9.async.js +1 -0
- package/docs/preload_helper.a0360861.js +1 -0
- package/docs/umi.04710f8f.js +104 -0
- package/docs/umi.4e0bcd92.css +1 -0
- package/docs/~demos/:id/index.html +24 -0
- package/docs/~demos/markdown-guide-enum-demo-0/index.html +24 -0
- package/docs/~demos/markdown-guide-loading-demo-0/index.html +24 -0
- package/docs/~demos/markdown-guide-request-demo-0/index.html +24 -0
- package/docs/~demos/markdown-guide-request-demo-1/index.html +24 -0
- package/package.json +7 -8
- package/cjs/enum.d.ts +0 -30
- package/cjs/enum.js +0 -49
- package/cjs/index.d.ts +0 -8
- package/cjs/index.js +0 -13
- package/cjs/loading.d.ts +0 -19
- package/cjs/loading.js +0 -68
- package/cjs/message.d.ts +0 -12
- package/cjs/message.js +0 -220
- package/cjs/other.d.ts +0 -42
- package/cjs/other.js +0 -167
- package/cjs/param.d.ts +0 -48
- package/cjs/param.js +0 -80
- package/cjs/request.d.ts +0 -62
- package/cjs/request.js +0 -216
- package/cjs/string.d.ts +0 -42
- package/cjs/string.js +0 -108
- package/cjs/time.d.ts +0 -21
- package/cjs/time.js +0 -102
- package/docs/api/functions/copyToClipboard/index.html +0 -18
- package/docs/api/functions/createEnum/index.html +0 -23
- package/docs/api/functions/decodeHtml/index.html +0 -16
- package/docs/api/functions/deepCopy/index.html +0 -16
- package/docs/api/functions/delParam/index.html +0 -19
- package/docs/api/functions/encodeHtml/index.html +0 -16
- package/docs/api/functions/formatDate/index.html +0 -16
- package/docs/api/functions/formatJson/index.html +0 -17
- package/docs/api/functions/getIdCardLastChar/index.html +0 -16
- package/docs/api/functions/getParam/index.html +0 -20
- package/docs/api/functions/getParamInt/index.html +0 -16
- package/docs/api/functions/getParams/index.html +0 -17
- package/docs/api/functions/getRandom/index.html +0 -21
- package/docs/api/functions/getRandomStr/index.html +0 -16
- package/docs/api/functions/hideLoading/index.html +0 -16
- package/docs/api/functions/initWindowMessage/index.html +0 -16
- package/docs/api/functions/parseDate/index.html +0 -16
- package/docs/api/functions/setParam/index.html +0 -18
- package/docs/api/functions/showLoading/index.html +0 -16
- package/docs/api/functions/toHump/index.html +0 -18
- package/docs/api/functions/toUnderline/index.html +0 -16
- package/docs/api/functions/toUrlParams/index.html +0 -16
- package/docs/api/functions/validateIdCard/index.html +0 -16
- package/docs/api/index.html +0 -16
- package/docs/api/interfaces/IRequestOptions/index.html +0 -16
- package/docs/api/interfaces/IShowLoadingConfig/index.html +0 -16
- package/docs/api/variables/Request/index.html +0 -16
- package/docs/api/variables/keyCodes/index.html +0 -16
- package/docs/assets/css/styles.077146e6.css +0 -1
- package/docs/assets/images/iphoneX-1fc37282d0e9b32fcd03fd96f461e7d5.png +0 -0
- package/docs/assets/js/00078de9.40631b85.js +0 -1
- package/docs/assets/js/04050071.c7e3abde.js +0 -1
- package/docs/assets/js/08f709b9.a083fff8.js +0 -1
- package/docs/assets/js/094cfbf1.00977b14.js +0 -1
- package/docs/assets/js/0c2147ef.7be0fbdf.js +0 -1
- package/docs/assets/js/114.c257b8b0.js +0 -2
- package/docs/assets/js/114.c257b8b0.js.LICENSE.txt +0 -1
- package/docs/assets/js/1501a739.13d7c7be.js +0 -1
- package/docs/assets/js/1608b181.cbe9c45e.js +0 -1
- package/docs/assets/js/1774.902f2e94.js +0 -1
- package/docs/assets/js/17896441.7fc5704e.js +0 -1
- package/docs/assets/js/194adc5f.8a12cf8c.js +0 -1
- package/docs/assets/js/1be78505.71fee479.js +0 -1
- package/docs/assets/js/26a70007.f12496a6.js +0 -1
- package/docs/assets/js/2ac048f8.1f1f0188.js +0 -1
- package/docs/assets/js/2e314e38.32e955e9.js +0 -1
- package/docs/assets/js/3b14ef11.5bc3d469.js +0 -1
- package/docs/assets/js/3ec39cd5.55864cc1.js +0 -1
- package/docs/assets/js/479af78b.8e2443f4.js +0 -1
- package/docs/assets/js/5888.a314615c.js +0 -2
- package/docs/assets/js/5888.a314615c.js.LICENSE.txt +0 -14
- package/docs/assets/js/66592e46.de586a2b.js +0 -1
- package/docs/assets/js/6bc50bd8.3c68878f.js +0 -1
- package/docs/assets/js/7263d0e6.ab50c755.js +0 -1
- package/docs/assets/js/7830.006c8eaa.js +0 -1
- package/docs/assets/js/7891b53e.79b654b9.js +0 -1
- package/docs/assets/js/8b76e124.7c5e5eb2.js +0 -1
- package/docs/assets/js/901a7e9f.5cd13eb6.js +0 -1
- package/docs/assets/js/9104954f.c7d49874.js +0 -1
- package/docs/assets/js/92b7d874.a379eff4.js +0 -1
- package/docs/assets/js/9334cb7c.c2c6b902.js +0 -1
- package/docs/assets/js/935f2afb.6c90f018.js +0 -1
- package/docs/assets/js/969412eb.5a33260d.js +0 -1
- package/docs/assets/js/9be94766.3c374589.js +0 -1
- package/docs/assets/js/9dd5329b.14301248.js +0 -1
- package/docs/assets/js/a0c44371.6c889be4.js +0 -1
- package/docs/assets/js/ab2af742.46b7af8c.js +0 -1
- package/docs/assets/js/b01f3e06.62f3a014.js +0 -1
- package/docs/assets/js/ba6f0f15.39cd6e80.js +0 -1
- package/docs/assets/js/ccb851b4.bba2fb6b.js +0 -1
- package/docs/assets/js/d4323bca.ac481634.js +0 -1
- package/docs/assets/js/d9f162ad.2abc1769.js +0 -1
- package/docs/assets/js/e2aa7f69.620e7b98.js +0 -1
- package/docs/assets/js/ef3f9d02.479dddf7.js +0 -1
- package/docs/assets/js/f4c916b9.07c4240c.js +0 -1
- package/docs/assets/js/f7d87c57.9b13a5a8.js +0 -1
- package/docs/assets/js/f97ec998.449e16b8.js +0 -1
- package/docs/assets/js/f9953324.325f2a5d.js +0 -1
- package/docs/assets/js/fc1c80db.551e2052.js +0 -1
- package/docs/assets/js/fdb649b1.5d0fff7c.js +0 -1
- package/docs/assets/js/main.15afa47b.js +0 -2
- package/docs/assets/js/main.15afa47b.js.LICENSE.txt +0 -63
- package/docs/assets/js/runtime~main.1ee1dff9.js +0 -1
- package/docs/demos/IcePkgDemo_doc_01_request_0/index.html +0 -16
- package/docs/demos/IcePkgDemo_doc_01_request_1/index.html +0 -16
- package/docs/demos/IcePkgDemo_doc_02_time_0/index.html +0 -16
- package/docs/demos/IcePkgDemo_doc_03_loading_0/index.html +0 -16
- package/docs/loading/index.html +0 -128
- package/docs/request/index.html +0 -240
- package/docs/sitemap.xml +0 -1
- package/docs/time/index.html +0 -128
- package/es/89c27c69.esm.es5.production.mjs +0 -1
- package/es/index.mjs +0 -1
- package/esm/enum.d.ts +0 -30
- package/esm/enum.js +0 -50
- package/esm/index.d.ts +0 -8
- package/esm/index.js +0 -8
- package/esm/loading.d.ts +0 -19
- package/esm/loading.js +0 -57
- package/esm/message.d.ts +0 -12
- package/esm/message.js +0 -215
- package/esm/other.d.ts +0 -42
- package/esm/other.js +0 -158
- package/esm/param.d.ts +0 -48
- package/esm/param.js +0 -78
- package/esm/request.d.ts +0 -62
- package/esm/request.js +0 -202
- package/esm/string.d.ts +0 -42
- package/esm/string.js +0 -106
- package/esm/time.d.ts +0 -21
- package/esm/time.js +0 -91
- package/umd/index.js +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ conssole.log(parseDate('2023-02-14', 'yyyy-MM-dd'));
|
|
|
19
19
|
|
|
20
20
|
## API
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
本文档仅对一些重点模块进行单独介绍,很多简单函数未做一一介绍,完整函数列表请参见[API文档](https://youtil.haoji.me/api/globals)。
|
|
23
23
|
|
|
24
24
|
## 关于命名
|
|
25
25
|
|
|
@@ -42,9 +42,8 @@ conssole.log(parseDate('2023-02-14', 'yyyy-MM-dd'));
|
|
|
42
42
|
|
|
43
43
|
* 更新代码;
|
|
44
44
|
* 更新`package.json`和`changelog`;
|
|
45
|
+
* `npm run build:docs`,然后合并master;
|
|
45
46
|
* `npm publish`;
|
|
46
|
-
* `npm run after-publish`务必不能漏了!
|
|
47
|
-
* `git push`;
|
|
48
47
|
|
|
49
48
|
注意:@ice/pkg和@swc/helpers 升级到0.5.0以上版本时其他业务可能报错,非常坑!目前写死版本
|
|
50
49
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var P=Object.defineProperty,D=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var q=(e,n,t)=>n in e?P(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,
|
|
2
|
-
.${
|
|
1
|
+
var P=Object.defineProperty,D=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var q=(e,n,t)=>n in e?P(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,R=(e,n)=>{for(var t in n||(n={}))F.call(n,t)&&q(e,t,n[t]);if(S)for(var t of S(n))U.call(n,t)&&q(e,t,n[t]);return e},L=(e,n)=>D(e,_(n));function X(e){let n=[...e],t={},s={};return e.forEach(r=>{t[r.value]=r,s[r.label]=r,r.key&&(t[r.key]=r,typeof r.key=="number"?console.error("createEnum\u4E2D\u7684key\u4E0D\u80FD\u4E3A\u7EAF\u6570\u5B57"):n[r.key]=r.value)}),n.pick=r=>t[r],n.pickLabel=r=>{var o;return(o=n.pick(r))==null?void 0:o.label},n.pickValue=r=>{var o;return(o=n.pick(r))==null?void 0:o.value},n.pickKey=r=>{var o;return(o=n.pick(r))==null?void 0:o.key},n.pickByLabel=r=>s[r],n}var Z=(e="\u8BF7\u7A0D\u5019",n=10,t={})=>{t=Object.assign({},{hasMask:!1,maskColor:"#00000070",onCancel:null,cancelInline:!1,id:"com_global_page_loading"},t);let{id:r,hasMask:o,maskColor:l,onCancel:g,cancelInline:w}=t,x=`_${r}_timeout`;window[x]&&clearTimeout(window[x]);let u=document.getElementById(r);u||(u=document.createElement("div"),u.id=r,u.className=r,document.body.append(u));let i=`${r}_style`;if(!document.getElementById(i)){let c=document.createElement("style");c.id=i,c.innerHTML=`
|
|
2
|
+
.${r} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
left: 0;
|
|
5
5
|
top: 0;
|
|
@@ -11,14 +11,14 @@ var P=Object.defineProperty,D=Object.defineProperties;var _=Object.getOwnPropert
|
|
|
11
11
|
pointer-events: none;
|
|
12
12
|
z-index: 10000;
|
|
13
13
|
}
|
|
14
|
-
.${
|
|
14
|
+
.${r}.show-mask {
|
|
15
15
|
pointer-events: unset;
|
|
16
16
|
background: #00000070;
|
|
17
17
|
}
|
|
18
|
-
.${
|
|
18
|
+
.${r} .mask-wrapper {
|
|
19
19
|
position: fixed;
|
|
20
20
|
}
|
|
21
|
-
.${
|
|
21
|
+
.${r} .loading-wrapper {
|
|
22
22
|
width: 120px;
|
|
23
23
|
height: 120px;
|
|
24
24
|
z-index: 8000;
|
|
@@ -33,23 +33,23 @@ var P=Object.defineProperty,D=Object.defineProperties;var _=Object.getOwnPropert
|
|
|
33
33
|
pointer-events: initial;
|
|
34
34
|
line-height: 1.3;
|
|
35
35
|
}
|
|
36
|
-
.${
|
|
36
|
+
.${r} .loading-wrapper img {
|
|
37
37
|
width: 50px;
|
|
38
38
|
height: 50px;
|
|
39
39
|
margin-bottom: 10px;
|
|
40
40
|
}
|
|
41
|
-
.${
|
|
41
|
+
.${r} .loading-wrapper a {
|
|
42
42
|
color: #6ab2ff;
|
|
43
|
-
}`,document.head.appendChild(
|
|
43
|
+
}`,document.head.appendChild(c)}if(u.innerHTML=`
|
|
44
44
|
<div class="loading-wrapper">
|
|
45
45
|
<img src="https://img.alicdn.com/tfs/TB1bnUsQBLoK1RjSZFuXXXn0XXa-32-32.svg" alt="\u52A0\u8F7D\u4E2D">
|
|
46
46
|
<div>
|
|
47
47
|
<span>${e}</span>
|
|
48
48
|
${w?"":"<br />"}
|
|
49
|
-
${
|
|
49
|
+
${g?'<a href="javascript:;" class="cancel">\u53D6\u6D88</a>':""}
|
|
50
50
|
</div>
|
|
51
|
-
</div>`,
|
|
52
|
-
`;for(let
|
|
53
|
-
`:"";let l=typeof e[
|
|
54
|
-
`:""}`,t+=!l||l&&leftBracesInSameLine&&!
|
|
55
|
-
${getIndentStr(n)}${
|
|
51
|
+
</div>`,g){let c=u.querySelector(".cancel");c&&c.addEventListener("click",()=>{I(),g()})}u.addEventListener("click",()=>{I()}),u.style.display="flex",u.style.background=o?l:"transparent",u.className=`${r} ${o?"show-mask":""}`,n>0&&(window[x]=setTimeout(()=>{I()},n*1e3))},I=()=>{let n=document.getElementById("com_global_page_loading");n&&(n.style.display="none")};function Y(e,n){!n&&window!==window.parent&&(n=window.parent),!n&&window.opener&&(n=window.opener);let t=new Map,s=new Map,r=()=>Math.random().toString(36).substring(2),o={},l="_local_function_";function g(i){let c=`${l}${r()}`;return o[c]=i,c}let w=(i,c)=>(i==null?void 0:i.map(d=>{if(typeof d=="object")for(let k in d)d[k]=c(d[k]);return c(d)}))||[];function x(i,...c){if(!n){console.warn("TargetWindow is null.");return}return new Promise((d,k)=>{let f=r();t.set(f,{resolve:d,reject:k}),n.postMessage({scene:e,type:"event",eventName:i,payload:w(c,m=>typeof m=="function"?g(m):m),callbackId:f},"*")})}window.addEventListener("message",async i=>{if(!i.data||i.data.scene!==e)return;n=i.source;let{type:c,eventName:d,payload:k,callbackId:f}=i.data;if(c==="event"){let m=w(k,y=>{if(typeof y=="string"&&y.startsWith(l)){let p=`getFn_${y}`;return(...b)=>x("executeLocalFunction",p,...b)}return y}),h=s.get(d)||[],O=s.get("*")||[];try{let y=await Promise.all(h.map(b=>Promise.resolve(b(...m)))),p=await Promise.all(O.map(b=>Promise.resolve(b(d,...m))));if(f){let b=y[y.length-1]||p[p.length-1];if(!h.length&&!b)return;n.postMessage({scene:e,type:"callback",callbackId:f,payload:b},"*")}}catch(y){console.error(y),f&&n.postMessage({scene:e,type:"callback",callbackId:f,error:y||"unknown error"},"*")}}else if(c==="callback"&&f){let m=t.get(f);m&&(i.data.error?m.reject(i.data.error):m.resolve(i.data.payload),t.delete(f))}});function u(i,c){s.has(i)||s.set(i,[]),s.get(i).push(c)}return u("executeLocalFunction",(i,...c)=>{if(i=(i==null?void 0:i.replace("getFn_",""))||"",!o[i])throw new Error(`\u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u65B9\u6CD5\uFF1A${i}`);return o[i](...c)}),x("auto-connect"),{postMessage:x,onMessage:u}}var Q=e=>!e||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),B=e=>{if(typeof e=="string"){let n=document.createElement("div");return n.innerText=e,n.innerHTML}else if(typeof e=="object"&&e)for(let n in e)e[n]=B(e[n]);return e},A=e=>{if(typeof e=="string"){let n=document.createElement("div");return n.innerHTML=e,n.innerText}else if(typeof e=="object"&&e)for(let n in e)e[n]=A(e[n]);return e},W=(e,n,t)=>{if(!e)throw new Error("text can not be empty.");return n=n||(s=>console.error(`\u590D\u5236\u5230\u526A\u8D34\u677F\u5931\u8D25\uFF1A${s||""}`)),navigator.clipboard&&!t?navigator.clipboard.writeText(e).catch(s=>{throw n(s.message),s}):new Promise((s,r)=>{let o=document.createElement("input");o.value=e,o.style.cssText="position:fixed;left:0;top:0;opacity:0;",document.body.appendChild(o),o.select();try{if(document.execCommand("copy"))s();else{let l="Failed to execute 'document.execCommand'.";n(l),r(new Error(l))}}catch(l){n(l.message),r(l)}finally{document.body.removeChild(o)}})},K=e=>{if(!e||e.length<17)throw new Error("\u4F20\u5165\u7684\u8EAB\u4EFD\u8BC1\u53F7\u957F\u5EA6\u5FC5\u987B>=17");let n=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2],t=["1","0","X","9","8","7","6","5","4","3","2"],s=0;for(let r=0;r<17;r++)s+=parseInt(e.charAt(r),10)*n[r];return t[s%11]},ee=e=>!e||e.length!==18?(console.error("\u8EAB\u4EFD\u8BC1\u53F7\u4E0D\u662F18\u4F4D\uFF01"),!1):`${K(e)}`===e.charAt(17),ne=(()=>{let e={backspace:8,tab:9,clear:12,enter:13,shift:16,ctrl:17,alt:18,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46};for(let n=48;n<=57;n++)e[String.fromCharCode(n)]=n;for(let n=65;n<=90;n++)e[String.fromCharCode(n).toLowerCase()]=n;for(let n=96;n<=105;n++)e[`num${n-96}`]=n;for(let n=112;n<=123;n++)e[`f${n-111}`]=n;return e})();var H=(e,n=location.search)=>(new RegExp(`(^|\\?|&)${e}=(.*?)(?=&|#|$)`,"g").exec(n)||[])[2],re=(e,n=location.search)=>parseInt(H(e,n)||"0",10),se=(e=location.search)=>{let n=((e||"").split("?").pop()||"").split("#")[0]||"",t={};return n.split("&").map(s=>s.split("=")).forEach(([s,r])=>{t[s]=r||""}),t},oe=(e,n,t)=>{if(t=t||`${location.pathname}${location.search}`,H(e,t)!==void 0)return t.replace(new RegExp(`(^|\\?|&)${e}=(.*?)(?=&|#|$)`,"g"),`$1${e}=${n}`);let[s,r]=t.split("#");return`${s}${s.indexOf("?")<0?"?":"&"}${e}=${n}${r?"#":""}${r||""}`},ae=(e,n)=>(n=n||`${location.pathname}${location.search}`,n.replace(new RegExp(`(^|\\?|&)${e}=.*?(&|#|$)`,"g"),(t,s,r)=>r==="&"?s:r)),M=e=>Object.keys(e||{}).filter(n=>e[n]!==void 0).map(n=>{let t=typeof e[n]=="object"?JSON.stringify(e[n]):e[n];return`${encodeURIComponent(n)}=${encodeURIComponent(t)}`}).join("&");var T=(e,n)=>{let t=Object.assign({},(e==null?void 0:e.headers)||{},(n==null?void 0:n.headers)||{}),s=Object.assign({},(e==null?void 0:e.fetchOptions)||{},(n==null?void 0:n.fetchOptions)||{});return Object.assign({},e||{},n||{},{headers:t,fetchOptions:s})},E=class extends Error{constructor(n,t){super(n),Object.assign(this,t||{})}},v=async(e,n)=>{var b,C;n=T({errorMessage:"\u7CFB\u7EDF\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",errorHandler:a=>{var $;throw!(n!=null&&n.silent)&&a&&(($=n==null?void 0:n.toastHandler)==null||$.call(n,a)),new Error(a)},baseUrl:"",headers:{},fetchOptions:{credentials:"include"},checkSuccess:a=>(a==null?void 0:a.code)==0||(a==null?void 0:a.code)==200,toastHandler:a=>console.error(`[\u60A8\u8FD8\u6CA1\u6709\u914D\u7F6EtoastHandler\uFF0C\u8BF7\u6839\u636E\u60A8\u7684UI\u7EC4\u4EF6\u5E93\u914D\u7F6E\u5408\u9002\u7684\u63D0\u793A\u65B9\u6CD5] ${a||""}`),onFetchResponse:a=>{if(a.status===200)return a.json();throw new E(a.statusText,{response:L(R({},a),{code:a.status,message:a.statusText,isHttpResponse:!0})})}},n);let{params:s,data:r,formData:o,json:l,method:g,headers:w,baseUrl:x,fetchOptions:u,checkSuccess:i,afterRequest:c,errorHandler:d,errorMessage:k,responseConverter:f,onFetchResponse:m,setLoading:h,overrideMessage:O}=n||{},y=(n==null?void 0:n.defaultErrorMessage)||k;if(u.headers=R(R({},w||{}),u.headers||{}),s&&(u.method=g||"GET",e=`${e}${e.indexOf("?")>=0?"&":"?"}${M(s)}`),r)Object.assign(u,{method:g||"POST",body:M(r),headers:R({"Content-Type":"application/x-www-form-urlencoded;charset=utf-8"},u.headers||{})});else if(o){let a=o;if(!(o instanceof FormData)){a=new FormData;for(let $ in o)a.append($,o[$])}Object.assign(u,{method:g||"POST",body:a})}else l&&Object.assign(u,{method:g||"POST",body:JSON.stringify(l),headers:R({"Content-Type":"application/json;charset=utf-8"},u.headers||{})});let p=null;h==null||h(!0);try{let a=`${/^(http|\/\/)/g.test(e)?"":x||""}${e}`;a.indexOf("//")===0&&location.protocol==="blob:"&&(a=`${(b=location.pathname.split(":"))==null?void 0:b[0]}:${a}`),p=await fetch(a,u).then(m)}catch(a){console.error(a),h==null||h(!1),c==null||c(!1,a.response);let $=typeof O=="function"?O(a.response):O;d==null||d($!=null?$:((C=a.response)==null?void 0:C.message)||y,a.response,n);return}if(h==null||h(!1),p=f?f(p):p,i!=null&&i(p))return c==null||c(!0,p),p.data;{c==null||c(!1,p);let a=typeof O=="function"?O(p):O;d==null||d(a!=null?a:p.message||y,p,n);return}},j=function(e){let n=T(this.overrideDefaultOptions,e),t=(s,r)=>v(s,T(n,r));return t.overrideDefaultOptions=n,t.create=j.bind(t),t};v.create=j.bind(v);var le=function(e,n){let t=n;return n||(t=e,e=v),(s,r)=>e(s,R(R({},t||{}),r||{}))};var de=(e,n)=>{if(!e)return"";if(typeof e=="number")e=new Date(e);else if(typeof e=="string")if(/^\d{12,13}$/g.test(e))e=new Date(parseInt(e,10));else if(/^.{10}T.{8,12}Z?$/g.test(e))e=new Date(e);else return e;if(!(e instanceof Date))throw new Error("formatDate error: not date.");if(isNaN(e==null?void 0:e.getFullYear()))throw new Error("formatDate error: invalid date.");n=n||"yyyy-MM-dd HH:mm:ss";let t={y:e.getFullYear(),M:e.getMonth()+1,d:e.getDate(),q:Math.floor((e.getMonth()+3)/3),w:e.getDay(),H:e.getHours(),h:e.getHours()%12===0?12:e.getHours()%12,m:e.getMinutes(),s:e.getSeconds(),S:e.getMilliseconds()},s=["\u5929","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"];for(let r in t)n=n.replace(new RegExp(`${r}+`,"g"),o=>{let l=`${t[r]}`;if(r==="w")return`${o.length>2?"\u661F\u671F":"\u5468"}${s[l]}`;for(let g=0,w=l.length;g<o.length-w;g++)l=`0${l}`;return o.length===1?l:l.substring(l.length-o.length)});return n},pe=(e,n)=>{n=n||"yyyy-MM-dd";let t={y:0,M:1,d:0,H:0,h:0,m:0,s:0,S:0};n.replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g,(r,o,l,g,w)=>(e=e.replace(new RegExp(`${o}(\\d{${l.length}})${w}`),(x,u)=>(t[g]=parseInt(u,10),"")),"")),t.M--;let s=new Date(t.y,t.M,t.d,t.H,t.m,t.s);return t.S!==0&&s.setMilliseconds(t.S),s},fe=e=>new Promise(n=>setTimeout(n,e||0));var me=(json,indent,leftBracesInSameLine)=>{function getIndentStr(e){let n="";for(let t=0;t<e;t++)n+=indent||" ";return n}function format(e,n){n=n===void 0?0:n;let t="";if(typeof e=="object"&&e!=null){let s=e instanceof Array,r=0;t+=`${s?"[":"{"}
|
|
52
|
+
`;for(let o in e){t+=r++>0?`,
|
|
53
|
+
`:"";let l=typeof e[o]=="object"&&e[o]!=null,g=getIndentStr(n+1);t+=s&&l?"":g,t+=s?"":`"${o}": ${l&&!leftBracesInSameLine?`
|
|
54
|
+
`:""}`,t+=!l||l&&leftBracesInSameLine&&!s?"":g,t+=format(e[o],n+1)}t+=`
|
|
55
|
+
${getIndentStr(n)}${s?"]":"}"}`}else{let s=typeof e=="string"?'"':"";t+=`${s}${e}${s}`}return t}return format(eval(`(${json})`))},N=(e,n)=>typeof e=="number"?(typeof n=="undefined"&&(n=e,e=0),e+Math.floor(Math.random()*(n-e))):e instanceof Array?typeof n=="undefined"?e.length===0?null:e.length===1?e[0]:e[Math.floor(Math.random()*e.length)]:(e.sort(()=>Math.random()>.5?1:-1),e.slice(0,n)):Math.random(),he=(e,n)=>{e=e||18;let t="ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789".split("");n==="number"&&(t="0123456789".split(""));let s="";for(let r=0;r<e;r++)s+=N(t);return s},be=(e,n)=>e.replace(/([A-Z])/g,(t,s)=>`${n||"_"}${s.toLowerCase()}`),we=(e,n)=>e.replace(new RegExp(`${n||"_"}(\\w)`,"g"),(t,s)=>s.toUpperCase());export{le as Request,W as copyToClipboard,X as createEnum,A as decodeHtml,Q as deepCopy,ae as delParam,B as encodeHtml,de as formatDate,me as formatJson,K as getIdCardLastChar,H as getParam,re as getParamInt,se as getParams,N as getRandom,he as getRandomStr,I as hideLoading,Y as initWindowMessage,ne as keyCodes,pe as parseDate,v as request,oe as setParam,Z as showLoading,fe as sleep,we as toHump,be as toUnderline,M as toUrlParams,ee as validateIdCard};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var youtil=(()=>{var I=Object.defineProperty,
|
|
2
|
-
.${
|
|
1
|
+
var youtil=(()=>{var I=Object.defineProperty,A=Object.defineProperties,K=Object.getOwnPropertyDescriptor,N=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var H=(e,n,t)=>n in e?I(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,R=(e,n)=>{for(var t in n||(n={}))j.call(n,t)&&H(e,t,n[t]);if(L)for(var t of L(n))X.call(n,t)&&H(e,t,n[t]);return e},P=(e,n)=>A(e,N(n));var J=(e,n)=>{for(var t in n)I(e,t,{get:n[t],enumerable:!0})},Z=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of V(n))!j.call(e,r)&&r!==t&&I(e,r,{get:()=>n[r],enumerable:!(s=K(n,r))||s.enumerable});return e};var z=e=>Z(I({},"__esModule",{value:!0}),e);var ye={};J(ye,{Request:()=>ie,copyToClipboard:()=>ee,createEnum:()=>Y,decodeHtml:()=>_,deepCopy:()=>W,delParam:()=>ae,encodeHtml:()=>D,formatDate:()=>ce,formatJson:()=>ge,getIdCardLastChar:()=>F,getParam:()=>E,getParamInt:()=>re,getParams:()=>se,getRandom:()=>B,getRandomStr:()=>de,hideLoading:()=>M,initWindowMessage:()=>Q,keyCodes:()=>te,parseDate:()=>le,request:()=>v,setParam:()=>oe,showLoading:()=>G,sleep:()=>ue,toHump:()=>fe,toUnderline:()=>pe,toUrlParams:()=>T,validateIdCard:()=>ne});function Y(e){let n=[...e],t={},s={};return e.forEach(r=>{t[r.value]=r,s[r.label]=r,r.key&&(t[r.key]=r,typeof r.key=="number"?console.error("createEnum\u4E2D\u7684key\u4E0D\u80FD\u4E3A\u7EAF\u6570\u5B57"):n[r.key]=r.value)}),n.pick=r=>t[r],n.pickLabel=r=>{var o;return(o=n.pick(r))==null?void 0:o.label},n.pickValue=r=>{var o;return(o=n.pick(r))==null?void 0:o.value},n.pickKey=r=>{var o;return(o=n.pick(r))==null?void 0:o.key},n.pickByLabel=r=>s[r],n}var G=(e="\u8BF7\u7A0D\u5019",n=10,t={})=>{t=Object.assign({},{hasMask:!1,maskColor:"#00000070",onCancel:null,cancelInline:!1,id:"com_global_page_loading"},t);let{id:r,hasMask:o,maskColor:l,onCancel:g,cancelInline:w}=t,x=`_${r}_timeout`;window[x]&&clearTimeout(window[x]);let u=document.getElementById(r);u||(u=document.createElement("div"),u.id=r,u.className=r,document.body.append(u));let i=`${r}_style`;if(!document.getElementById(i)){let c=document.createElement("style");c.id=i,c.innerHTML=`
|
|
2
|
+
.${r} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
left: 0;
|
|
5
5
|
top: 0;
|
|
@@ -11,14 +11,14 @@ var youtil=(()=>{var I=Object.defineProperty,B=Object.defineProperties,K=Object.
|
|
|
11
11
|
pointer-events: none;
|
|
12
12
|
z-index: 10000;
|
|
13
13
|
}
|
|
14
|
-
.${
|
|
14
|
+
.${r}.show-mask {
|
|
15
15
|
pointer-events: unset;
|
|
16
16
|
background: #00000070;
|
|
17
17
|
}
|
|
18
|
-
.${
|
|
18
|
+
.${r} .mask-wrapper {
|
|
19
19
|
position: fixed;
|
|
20
20
|
}
|
|
21
|
-
.${
|
|
21
|
+
.${r} .loading-wrapper {
|
|
22
22
|
width: 120px;
|
|
23
23
|
height: 120px;
|
|
24
24
|
z-index: 8000;
|
|
@@ -33,23 +33,23 @@ var youtil=(()=>{var I=Object.defineProperty,B=Object.defineProperties,K=Object.
|
|
|
33
33
|
pointer-events: initial;
|
|
34
34
|
line-height: 1.3;
|
|
35
35
|
}
|
|
36
|
-
.${
|
|
36
|
+
.${r} .loading-wrapper img {
|
|
37
37
|
width: 50px;
|
|
38
38
|
height: 50px;
|
|
39
39
|
margin-bottom: 10px;
|
|
40
40
|
}
|
|
41
|
-
.${
|
|
41
|
+
.${r} .loading-wrapper a {
|
|
42
42
|
color: #6ab2ff;
|
|
43
|
-
}`,document.head.appendChild(
|
|
43
|
+
}`,document.head.appendChild(c)}if(u.innerHTML=`
|
|
44
44
|
<div class="loading-wrapper">
|
|
45
45
|
<img src="https://img.alicdn.com/tfs/TB1bnUsQBLoK1RjSZFuXXXn0XXa-32-32.svg" alt="\u52A0\u8F7D\u4E2D">
|
|
46
46
|
<div>
|
|
47
47
|
<span>${e}</span>
|
|
48
48
|
${w?"":"<br />"}
|
|
49
|
-
${
|
|
49
|
+
${g?'<a href="javascript:;" class="cancel">\u53D6\u6D88</a>':""}
|
|
50
50
|
</div>
|
|
51
|
-
</div>`,
|
|
52
|
-
`;for(let
|
|
53
|
-
`:"";let l=typeof e[
|
|
54
|
-
`:""}`,t+=!l||l&&leftBracesInSameLine&&!
|
|
55
|
-
${getIndentStr(n)}${
|
|
51
|
+
</div>`,g){let c=u.querySelector(".cancel");c&&c.addEventListener("click",()=>{M(),g()})}u.addEventListener("click",()=>{M()}),u.style.display="flex",u.style.background=o?l:"transparent",u.className=`${r} ${o?"show-mask":""}`,n>0&&(window[x]=setTimeout(()=>{M()},n*1e3))},M=()=>{let n=document.getElementById("com_global_page_loading");n&&(n.style.display="none")};function Q(e,n){!n&&window!==window.parent&&(n=window.parent),!n&&window.opener&&(n=window.opener);let t=new Map,s=new Map,r=()=>Math.random().toString(36).substring(2),o={},l="_local_function_";function g(i){let c=`${l}${r()}`;return o[c]=i,c}let w=(i,c)=>(i==null?void 0:i.map(d=>{if(typeof d=="object")for(let k in d)d[k]=c(d[k]);return c(d)}))||[];function x(i,...c){if(!n){console.warn("TargetWindow is null.");return}return new Promise((d,k)=>{let f=r();t.set(f,{resolve:d,reject:k}),n.postMessage({scene:e,type:"event",eventName:i,payload:w(c,m=>typeof m=="function"?g(m):m),callbackId:f},"*")})}window.addEventListener("message",async i=>{if(!i.data||i.data.scene!==e)return;n=i.source;let{type:c,eventName:d,payload:k,callbackId:f}=i.data;if(c==="event"){let m=w(k,y=>{if(typeof y=="string"&&y.startsWith(l)){let p=`getFn_${y}`;return(...b)=>x("executeLocalFunction",p,...b)}return y}),h=s.get(d)||[],O=s.get("*")||[];try{let y=await Promise.all(h.map(b=>Promise.resolve(b(...m)))),p=await Promise.all(O.map(b=>Promise.resolve(b(d,...m))));if(f){let b=y[y.length-1]||p[p.length-1];if(!h.length&&!b)return;n.postMessage({scene:e,type:"callback",callbackId:f,payload:b},"*")}}catch(y){console.error(y),f&&n.postMessage({scene:e,type:"callback",callbackId:f,error:y||"unknown error"},"*")}}else if(c==="callback"&&f){let m=t.get(f);m&&(i.data.error?m.reject(i.data.error):m.resolve(i.data.payload),t.delete(f))}});function u(i,c){s.has(i)||s.set(i,[]),s.get(i).push(c)}return u("executeLocalFunction",(i,...c)=>{if(i=(i==null?void 0:i.replace("getFn_",""))||"",!o[i])throw new Error(`\u672A\u627E\u5230\u672C\u5730\u7F13\u5B58\u65B9\u6CD5\uFF1A${i}`);return o[i](...c)}),x("auto-connect"),{postMessage:x,onMessage:u}}var W=e=>!e||typeof e!="object"?e:JSON.parse(JSON.stringify(e)),D=e=>{if(typeof e=="string"){let n=document.createElement("div");return n.innerText=e,n.innerHTML}else if(typeof e=="object"&&e)for(let n in e)e[n]=D(e[n]);return e},_=e=>{if(typeof e=="string"){let n=document.createElement("div");return n.innerHTML=e,n.innerText}else if(typeof e=="object"&&e)for(let n in e)e[n]=_(e[n]);return e},ee=(e,n,t)=>{if(!e)throw new Error("text can not be empty.");return n=n||(s=>console.error(`\u590D\u5236\u5230\u526A\u8D34\u677F\u5931\u8D25\uFF1A${s||""}`)),navigator.clipboard&&!t?navigator.clipboard.writeText(e).catch(s=>{throw n(s.message),s}):new Promise((s,r)=>{let o=document.createElement("input");o.value=e,o.style.cssText="position:fixed;left:0;top:0;opacity:0;",document.body.appendChild(o),o.select();try{if(document.execCommand("copy"))s();else{let l="Failed to execute 'document.execCommand'.";n(l),r(new Error(l))}}catch(l){n(l.message),r(l)}finally{document.body.removeChild(o)}})},F=e=>{if(!e||e.length<17)throw new Error("\u4F20\u5165\u7684\u8EAB\u4EFD\u8BC1\u53F7\u957F\u5EA6\u5FC5\u987B>=17");let n=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2],t=["1","0","X","9","8","7","6","5","4","3","2"],s=0;for(let r=0;r<17;r++)s+=parseInt(e.charAt(r),10)*n[r];return t[s%11]},ne=e=>!e||e.length!==18?(console.error("\u8EAB\u4EFD\u8BC1\u53F7\u4E0D\u662F18\u4F4D\uFF01"),!1):`${F(e)}`===e.charAt(17),te=(()=>{let e={backspace:8,tab:9,clear:12,enter:13,shift:16,ctrl:17,alt:18,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46};for(let n=48;n<=57;n++)e[String.fromCharCode(n)]=n;for(let n=65;n<=90;n++)e[String.fromCharCode(n).toLowerCase()]=n;for(let n=96;n<=105;n++)e[`num${n-96}`]=n;for(let n=112;n<=123;n++)e[`f${n-111}`]=n;return e})();var E=(e,n=location.search)=>(new RegExp(`(^|\\?|&)${e}=(.*?)(?=&|#|$)`,"g").exec(n)||[])[2],re=(e,n=location.search)=>parseInt(E(e,n)||"0",10),se=(e=location.search)=>{let n=((e||"").split("?").pop()||"").split("#")[0]||"",t={};return n.split("&").map(s=>s.split("=")).forEach(([s,r])=>{t[s]=r||""}),t},oe=(e,n,t)=>{if(t=t||`${location.pathname}${location.search}`,E(e,t)!==void 0)return t.replace(new RegExp(`(^|\\?|&)${e}=(.*?)(?=&|#|$)`,"g"),`$1${e}=${n}`);let[s,r]=t.split("#");return`${s}${s.indexOf("?")<0?"?":"&"}${e}=${n}${r?"#":""}${r||""}`},ae=(e,n)=>(n=n||`${location.pathname}${location.search}`,n.replace(new RegExp(`(^|\\?|&)${e}=.*?(&|#|$)`,"g"),(t,s,r)=>r==="&"?s:r)),T=e=>Object.keys(e||{}).filter(n=>e[n]!==void 0).map(n=>{let t=typeof e[n]=="object"?JSON.stringify(e[n]):e[n];return`${encodeURIComponent(n)}=${encodeURIComponent(t)}`}).join("&");var C=(e,n)=>{let t=Object.assign({},(e==null?void 0:e.headers)||{},(n==null?void 0:n.headers)||{}),s=Object.assign({},(e==null?void 0:e.fetchOptions)||{},(n==null?void 0:n.fetchOptions)||{});return Object.assign({},e||{},n||{},{headers:t,fetchOptions:s})},S=class extends Error{constructor(n,t){super(n),Object.assign(this,t||{})}},v=async(e,n)=>{var b,q;n=C({errorMessage:"\u7CFB\u7EDF\u7E41\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",errorHandler:a=>{var $;throw!(n!=null&&n.silent)&&a&&(($=n==null?void 0:n.toastHandler)==null||$.call(n,a)),new Error(a)},baseUrl:"",headers:{},fetchOptions:{credentials:"include"},checkSuccess:a=>(a==null?void 0:a.code)==0||(a==null?void 0:a.code)==200,toastHandler:a=>console.error(`[\u60A8\u8FD8\u6CA1\u6709\u914D\u7F6EtoastHandler\uFF0C\u8BF7\u6839\u636E\u60A8\u7684UI\u7EC4\u4EF6\u5E93\u914D\u7F6E\u5408\u9002\u7684\u63D0\u793A\u65B9\u6CD5] ${a||""}`),onFetchResponse:a=>{if(a.status===200)return a.json();throw new S(a.statusText,{response:P(R({},a),{code:a.status,message:a.statusText,isHttpResponse:!0})})}},n);let{params:s,data:r,formData:o,json:l,method:g,headers:w,baseUrl:x,fetchOptions:u,checkSuccess:i,afterRequest:c,errorHandler:d,errorMessage:k,responseConverter:f,onFetchResponse:m,setLoading:h,overrideMessage:O}=n||{},y=(n==null?void 0:n.defaultErrorMessage)||k;if(u.headers=R(R({},w||{}),u.headers||{}),s&&(u.method=g||"GET",e=`${e}${e.indexOf("?")>=0?"&":"?"}${T(s)}`),r)Object.assign(u,{method:g||"POST",body:T(r),headers:R({"Content-Type":"application/x-www-form-urlencoded;charset=utf-8"},u.headers||{})});else if(o){let a=o;if(!(o instanceof FormData)){a=new FormData;for(let $ in o)a.append($,o[$])}Object.assign(u,{method:g||"POST",body:a})}else l&&Object.assign(u,{method:g||"POST",body:JSON.stringify(l),headers:R({"Content-Type":"application/json;charset=utf-8"},u.headers||{})});let p=null;h==null||h(!0);try{let a=`${/^(http|\/\/)/g.test(e)?"":x||""}${e}`;a.indexOf("//")===0&&location.protocol==="blob:"&&(a=`${(b=location.pathname.split(":"))==null?void 0:b[0]}:${a}`),p=await fetch(a,u).then(m)}catch(a){console.error(a),h==null||h(!1),c==null||c(!1,a.response);let $=typeof O=="function"?O(a.response):O;d==null||d($!=null?$:((q=a.response)==null?void 0:q.message)||y,a.response,n);return}if(h==null||h(!1),p=f?f(p):p,i!=null&&i(p))return c==null||c(!0,p),p.data;{c==null||c(!1,p);let a=typeof O=="function"?O(p):O;d==null||d(a!=null?a:p.message||y,p,n);return}},U=function(e){let n=C(this.overrideDefaultOptions,e),t=(s,r)=>v(s,C(n,r));return t.overrideDefaultOptions=n,t.create=U.bind(t),t};v.create=U.bind(v);var ie=function(e,n){let t=n;return n||(t=e,e=v),(s,r)=>e(s,R(R({},t||{}),r||{}))};var ce=(e,n)=>{if(!e)return"";if(typeof e=="number")e=new Date(e);else if(typeof e=="string")if(/^\d{12,13}$/g.test(e))e=new Date(parseInt(e,10));else if(/^.{10}T.{8,12}Z?$/g.test(e))e=new Date(e);else return e;if(!(e instanceof Date))throw new Error("formatDate error: not date.");if(isNaN(e==null?void 0:e.getFullYear()))throw new Error("formatDate error: invalid date.");n=n||"yyyy-MM-dd HH:mm:ss";let t={y:e.getFullYear(),M:e.getMonth()+1,d:e.getDate(),q:Math.floor((e.getMonth()+3)/3),w:e.getDay(),H:e.getHours(),h:e.getHours()%12===0?12:e.getHours()%12,m:e.getMinutes(),s:e.getSeconds(),S:e.getMilliseconds()},s=["\u5929","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"];for(let r in t)n=n.replace(new RegExp(`${r}+`,"g"),o=>{let l=`${t[r]}`;if(r==="w")return`${o.length>2?"\u661F\u671F":"\u5468"}${s[l]}`;for(let g=0,w=l.length;g<o.length-w;g++)l=`0${l}`;return o.length===1?l:l.substring(l.length-o.length)});return n},le=(e,n)=>{n=n||"yyyy-MM-dd";let t={y:0,M:1,d:0,H:0,h:0,m:0,s:0,S:0};n.replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g,(r,o,l,g,w)=>(e=e.replace(new RegExp(`${o}(\\d{${l.length}})${w}`),(x,u)=>(t[g]=parseInt(u,10),"")),"")),t.M--;let s=new Date(t.y,t.M,t.d,t.H,t.m,t.s);return t.S!==0&&s.setMilliseconds(t.S),s},ue=e=>new Promise(n=>setTimeout(n,e||0));var ge=(json,indent,leftBracesInSameLine)=>{function getIndentStr(e){let n="";for(let t=0;t<e;t++)n+=indent||" ";return n}function format(e,n){n=n===void 0?0:n;let t="";if(typeof e=="object"&&e!=null){let s=e instanceof Array,r=0;t+=`${s?"[":"{"}
|
|
52
|
+
`;for(let o in e){t+=r++>0?`,
|
|
53
|
+
`:"";let l=typeof e[o]=="object"&&e[o]!=null,g=getIndentStr(n+1);t+=s&&l?"":g,t+=s?"":`"${o}": ${l&&!leftBracesInSameLine?`
|
|
54
|
+
`:""}`,t+=!l||l&&leftBracesInSameLine&&!s?"":g,t+=format(e[o],n+1)}t+=`
|
|
55
|
+
${getIndentStr(n)}${s?"]":"}"}`}else{let s=typeof e=="string"?'"':"";t+=`${s}${e}${s}`}return t}return format(eval(`(${json})`))},B=(e,n)=>typeof e=="number"?(typeof n=="undefined"&&(n=e,e=0),e+Math.floor(Math.random()*(n-e))):e instanceof Array?typeof n=="undefined"?e.length===0?null:e.length===1?e[0]:e[Math.floor(Math.random()*e.length)]:(e.sort(()=>Math.random()>.5?1:-1),e.slice(0,n)):Math.random(),de=(e,n)=>{e=e||18;let t="ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789".split("");n==="number"&&(t="0123456789".split(""));let s="";for(let r=0;r<e;r++)s+=B(t);return s},pe=(e,n)=>e.replace(/([A-Z])/g,(t,s)=>`${n||"_"}${s.toLowerCase()}`),fe=(e,n)=>e.replace(new RegExp(`${n||"_"}(\\w)`,"g"),(t,s)=>s.toUpperCase());return z(ye);})();
|
package/dist/types/enum.d.ts
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
type EnumItem<K extends string, V extends string | number> = {
|
|
1
|
+
export type EnumItem<K extends string, V extends string | number> = {
|
|
2
|
+
/** 显示出来的名称 */
|
|
2
3
|
label: string;
|
|
4
|
+
/** 实际传递的值 */
|
|
3
5
|
value: V;
|
|
4
|
-
|
|
6
|
+
/** 方便记忆的英文别名,可选 */
|
|
7
|
+
key?: K;
|
|
5
8
|
[key: string]: any;
|
|
6
9
|
};
|
|
7
|
-
type EnumType<T extends ReadonlyArray<EnumItem<string, string | number>>> = T & {
|
|
10
|
+
export type EnumType<T extends ReadonlyArray<EnumItem<string, string | number>>> = T & {
|
|
8
11
|
[K in T[number]['key']]: Extract<T[number], {
|
|
9
12
|
key: K;
|
|
10
13
|
}>['value'];
|
|
11
14
|
} & {
|
|
15
|
+
/** 根据 key 或者 value 查找整个对象 */
|
|
12
16
|
pick: (keyOrValue: string | number) => T[number] | undefined;
|
|
17
|
+
/** 根据 key 或者 value 查找 label */
|
|
13
18
|
pickLabel: (keyOrValue: string | number) => T[number]['label'] | undefined;
|
|
19
|
+
/** 根据 key 查找 value */
|
|
14
20
|
pickValue: (keyOrValue: string | number) => T[number]['value'] | undefined;
|
|
21
|
+
/** 根据 value 查找 key */
|
|
15
22
|
pickKey: (keyOrValue: string | number) => T[number]['key'] | undefined;
|
|
23
|
+
/** 根据 label 查找整个对象 */
|
|
24
|
+
pickByLabel: (label: string) => T[number] | undefined;
|
|
16
25
|
};
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
19
|
-
* const enums = createEnum([{ key: 'MAN', label: '男', value: 1 }])
|
|
20
|
-
* console.log(enums.MAN) // 1
|
|
21
|
-
* console.log(enums.pick('MAN')) //
|
|
22
|
-
* console.log(enums.pick(1)) //
|
|
23
|
-
* console.log(enums.pickLabel('MAN')) //
|
|
24
|
-
* console.log(enums.pickValue('MAN')) // 1
|
|
27
|
+
* 创建一个枚举,支持多种高级用法:<br>
|
|
28
|
+
* const enums = createEnum([{ key: 'MAN', label: '男', value: 1 }])<br>
|
|
29
|
+
* console.log(enums.MAN) // 1<br>
|
|
30
|
+
* console.log(enums.pick('MAN')) // 对象<br>
|
|
31
|
+
* console.log(enums.pick(1)) // 对象<br>
|
|
32
|
+
* console.log(enums.pickLabel('MAN')) // 男<br>
|
|
33
|
+
* console.log(enums.pickValue('MAN')) // 1<br>
|
|
25
34
|
* console.log(enums) // 数组对象
|
|
26
35
|
* @param items
|
|
27
36
|
* @returns
|
|
28
37
|
*/
|
|
29
38
|
export declare function createEnum<T extends ReadonlyArray<EnumItem<string, string | number>>>(items: T): EnumType<T>;
|
|
30
|
-
export {};
|
package/docs/404.html
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
<!
|
|
2
|
-
<html
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
3
|
<head>
|
|
4
|
-
<meta charset="
|
|
5
|
-
<meta name="
|
|
6
|
-
<
|
|
7
|
-
<link rel="
|
|
8
|
-
<
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
|
+
<link rel="shortcut icon" href="https://img10.360buyimg.com/imagetools/jfs/t1/316988/13/20626/79139/688a0b88F01a2c450/a6419401b21c0aef.png">
|
|
8
|
+
<style>
|
|
9
|
+
/* 隐藏二级导航 */
|
|
10
|
+
.dumi-default-navbar-collapse-btn {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
.dumi-default-navbar-dropdown {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
<link rel="stylesheet" href="/umi.4e0bcd92.css">
|
|
18
|
+
<script src="/preload_helper.a0360861.js"></script>
|
|
9
19
|
</head>
|
|
10
|
-
<body
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
<script src="/assets/js/runtime~main.1ee1dff9.js"></script>
|
|
14
|
-
<script src="/assets/js/main.15afa47b.js"></script>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="root"></div>
|
|
22
|
+
<script src="/umi.04710f8f.js"></script>
|
|
15
23
|
</body>
|
|
16
24
|
</html>
|