@obr-fe/utils 0.0.4 → 1.0.4

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.
Files changed (110) hide show
  1. package/README.MD +1 -1
  2. package/dist/array.d.ts +13 -29
  3. package/dist/array.js +1 -1
  4. package/dist/array.mjs +1 -1
  5. package/dist/base.d.ts +43 -29
  6. package/dist/base.js +1 -1
  7. package/dist/base.mjs +1 -1
  8. package/dist/{chunk-OTVWATFI.mjs → chunk-3S54UGV2.mjs} +1 -1
  9. package/dist/chunk-44EYU7QJ.mjs +1 -0
  10. package/dist/chunk-525NDWM2.mjs +1 -0
  11. package/dist/chunk-5YPCN6WZ.mjs +1 -0
  12. package/dist/chunk-BJIYP2SP.mjs +1 -0
  13. package/dist/chunk-DKKF6DRJ.mjs +1 -0
  14. package/dist/chunk-E4SEMOGO.mjs +1 -0
  15. package/dist/chunk-G6V6TMDC.mjs +1 -0
  16. package/dist/chunk-HOXWKSQ2.mjs +1 -0
  17. package/dist/chunk-INFFTHYR.mjs +1 -0
  18. package/dist/chunk-JLA5ZFZI.mjs +1 -0
  19. package/dist/chunk-M7WM427S.mjs +1 -0
  20. package/dist/chunk-PE3DNHCL.mjs +1 -0
  21. package/dist/chunk-QFFI4BCG.mjs +1 -0
  22. package/dist/chunk-SAXMBV46.mjs +1 -0
  23. package/dist/chunk-SHNMDODE.mjs +1 -0
  24. package/dist/chunk-TQ5GXPYB.mjs +1 -0
  25. package/dist/chunk-VJPERUBQ.mjs +1 -0
  26. package/dist/chunk-WAYGIXU2.mjs +1 -0
  27. package/dist/chunk-WBQAMGXK.mjs +0 -0
  28. package/dist/chunk-WN7L4HYY.mjs +1 -0
  29. package/dist/chunk-XUFB5NAS.mjs +1 -0
  30. package/dist/dom/base.d.ts +3 -3
  31. package/dist/dom/base.js +1 -1
  32. package/dist/dom/base.mjs +1 -1
  33. package/dist/dom/css.js +1 -1
  34. package/dist/dom/css.mjs +1 -1
  35. package/dist/dom/find-dom-node.d.ts +1 -1
  36. package/dist/dom/find-dom-node.js +1 -1
  37. package/dist/dom/find-dom-node.mjs +1 -1
  38. package/dist/dom/iframe.d.ts +57 -0
  39. package/dist/dom/iframe.js +1 -0
  40. package/dist/dom/iframe.mjs +1 -0
  41. package/dist/dom/index.d.ts +5 -0
  42. package/dist/dom/index.js +1 -1
  43. package/dist/dom/index.mjs +1 -1
  44. package/dist/dom/storage.d.ts +20 -0
  45. package/dist/dom/storage.js +1 -0
  46. package/dist/dom/storage.mjs +1 -0
  47. package/dist/dom/style-checker.js +1 -1
  48. package/dist/dom/style-checker.mjs +1 -1
  49. package/dist/dom/style-names.js +1 -1
  50. package/dist/dom/style-names.mjs +1 -1
  51. package/dist/file.d.ts +2 -2
  52. package/dist/file.js +1 -1
  53. package/dist/file.mjs +1 -1
  54. package/dist/index.d.ts +10 -4
  55. package/dist/index.js +1 -1
  56. package/dist/index.mjs +1 -1
  57. package/dist/object.d.ts +11 -10
  58. package/dist/object.js +1 -1
  59. package/dist/object.mjs +1 -1
  60. package/dist/other.d.ts +23 -14
  61. package/dist/other.js +1 -1
  62. package/dist/other.mjs +1 -1
  63. package/dist/request/constant.d.ts +10 -0
  64. package/dist/request/constant.js +1 -0
  65. package/dist/request/constant.mjs +1 -0
  66. package/dist/request/handler.d.ts +10 -0
  67. package/dist/request/handler.js +1 -0
  68. package/dist/request/handler.mjs +1 -0
  69. package/dist/request/index.d.ts +4 -0
  70. package/dist/request/index.js +1 -0
  71. package/dist/request/index.mjs +1 -0
  72. package/dist/request/request.d.ts +89 -0
  73. package/dist/request/request.js +1 -0
  74. package/dist/request/request.mjs +1 -0
  75. package/dist/request/utils/cancel.d.ts +23 -0
  76. package/dist/request/utils/cancel.js +1 -0
  77. package/dist/request/utils/cancel.mjs +1 -0
  78. package/dist/request/utils/file.d.ts +6 -0
  79. package/dist/request/utils/file.js +1 -0
  80. package/dist/request/utils/file.mjs +1 -0
  81. package/dist/request/utils/format.d.ts +11 -0
  82. package/dist/request/utils/format.js +1 -0
  83. package/dist/request/utils/format.mjs +1 -0
  84. package/dist/safe-next-tick.d.ts +1 -1
  85. package/dist/safe-next-tick.js +1 -1
  86. package/dist/safe-next-tick.mjs +1 -1
  87. package/dist/types.d.ts +164 -0
  88. package/dist/types.js +1 -0
  89. package/dist/types.mjs +1 -0
  90. package/dist/vue/hooks/clipboard.d.ts +1 -1
  91. package/dist/vue/hooks/clipboard.js +1 -1
  92. package/dist/vue/hooks/clipboard.mjs +1 -1
  93. package/dist/vue/index.js +1 -1
  94. package/dist/vue/index.mjs +1 -1
  95. package/package.json +30 -32
  96. package/dist/chunk-4CSXS5HE.mjs +0 -1
  97. package/dist/chunk-AHENZTBD.mjs +0 -1
  98. package/dist/chunk-BM65Z3BA.mjs +0 -1
  99. package/dist/chunk-BTRFNTUR.mjs +0 -1
  100. package/dist/chunk-CV5ABO6S.mjs +0 -1
  101. package/dist/chunk-GQNODP36.mjs +0 -1
  102. package/dist/chunk-LHBVJBCG.mjs +0 -1
  103. package/dist/chunk-LZM3K4ZI.mjs +0 -1
  104. package/dist/chunk-PPOXYBWE.mjs +0 -1
  105. package/dist/chunk-PWYR6CSX.mjs +0 -1
  106. package/dist/chunk-UOQ77YOD.mjs +0 -1
  107. package/dist/document.d.ts +0 -24
  108. package/dist/document.js +0 -1
  109. package/dist/document.mjs +0 -1
  110. /package/dist/{chunk-QWDRQX5J.mjs → chunk-CYMHFZIC.mjs} +0 -0
@@ -0,0 +1,89 @@
1
+ import { RequestBaseConfig, ObjectDataType, ObrAxiosRequestConfig, PageQueryType, RequestMethod, PageAlias, PageResType, OptionResAlias, BaseOptionType, ResDataType } from '../types.js';
2
+ import 'axios';
3
+
4
+ declare class ObrRequest {
5
+ private options;
6
+ private instance;
7
+ constructor(options: RequestBaseConfig);
8
+ private setupInterceptors;
9
+ /**
10
+ * @description: 请求本地文件
11
+ * @param {string} path
12
+ * @return {Promise<Response>}
13
+ * @autor: 刘 相卿
14
+ */
15
+ fetchLocalFile(path: string): Promise<Response>;
16
+ /**
17
+ * @description: get请求
18
+ * @param {string} url
19
+ * @param {ObjectDataType} params
20
+ * @param {ObrAxiosRequestConfig} config
21
+ * @return {*}
22
+ * @autor: 刘 相卿
23
+ */
24
+ get<T = any>(url: string, params?: ObjectDataType, config?: ObrAxiosRequestConfig): Promise<T>;
25
+ /**
26
+ * @description: post请求
27
+ * @param {string} url
28
+ * @param {ObjectDataType} params 请求参数
29
+ * @param {ObrAxiosRequestConfig} config 请求配置项
30
+ * @return {Promise<T>}
31
+ * @autor: 刘 相卿
32
+ */
33
+ post<T = any>(url: string, params?: ObjectDataType, config?: ObrAxiosRequestConfig): Promise<T>;
34
+ /**
35
+ * @description: post请求(json参数会转为FormData类型)
36
+ * @param {string} url
37
+ * @param {ObjectDataType} params 请求参数
38
+ * @param {ObrAxiosRequestConfig} config 请求配置项
39
+ * @return {Promise<T>}
40
+ * @autor: 刘 相卿
41
+ */
42
+ postForm<T = any>(url: string, params?: ObjectDataType, config?: ObrAxiosRequestConfig): Promise<T>;
43
+ /**
44
+ * @description: 请求分页接口
45
+ * @param {string} url
46
+ * @param {ObjectDataType} searchParams 请求参数
47
+ * @param {PageQueryType} pageParams 分页参数
48
+ * @param {RequestMethod} method 请求方法
49
+ * @param {Partial} alias 分页别名配置
50
+ * @param {ObrAxiosRequestConfig} config 请求配置项
51
+ * @return {Promise<PageResType<R>>}
52
+ * @autor: 刘 相卿
53
+ */
54
+ getPageRecords<R = ObjectDataType>(url: string, searchParams?: ObjectDataType, pageParams?: PageQueryType, method?: RequestMethod, alias?: Partial<PageAlias>, config?: ObrAxiosRequestConfig): Promise<PageResType<R>>;
55
+ /**
56
+ * @description: 获取options类型数据(下拉选择/字典等)
57
+ * @param {string} url
58
+ * @param {ObjectDataType} params
59
+ * @param {RequestMethod} method
60
+ * @param {Partial} alias
61
+ * @param {ObrAxiosRequestConfig} config
62
+ * @param {boolean} unique
63
+ * @return {Promise<BaseOptionType<T>[]>}
64
+ * @autor: 刘 相卿
65
+ */
66
+ getOptions<T = ObjectDataType>(url: string, params?: ObjectDataType, method?: RequestMethod, alias?: Partial<OptionResAlias>, config?: ObrAxiosRequestConfig, unique?: boolean): Promise<BaseOptionType<T>[]>;
67
+ /**
68
+ * @description: 强制取消请求
69
+ * @param {ObrAxiosRequestConfig} config
70
+ * @return {*}
71
+ * @autor: 刘 相卿
72
+ */
73
+ cancel(config: ObrAxiosRequestConfig): void;
74
+ /**
75
+ * @description: request请求
76
+ * @param {ObrAxiosRequestConfig} config
77
+ * @return {Promise<ResDataType<T>>}
78
+ * @autor: 刘 相卿
79
+ */
80
+ request<T = any>(config: ObrAxiosRequestConfig): Promise<ResDataType<T>>;
81
+ /**
82
+ * @description: 取消所有请求并销毁axios实例
83
+ * @return {*}
84
+ * @autor: 刘 相卿
85
+ */
86
+ destory(): void;
87
+ }
88
+
89
+ export { ObrRequest };
@@ -0,0 +1 @@
1
+ "use strict";var X=Object.create;var d=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},S=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Y(r))!ee.call(e,a)&&a!==t&&d(e,a,{get:()=>r[a],enumerable:!(n=W(r,a))||n.enumerable});return e};var f=(e,r,t)=>(t=e!=null?X(Z(e)):{},S(r||!e||!e.__esModule?d(t,"default",{value:e,enumerable:!0}):t,e)),re=e=>S(d({},"__esModule",{value:!0}),e);var oe={};te(oe,{ObrRequest:()=>C});module.exports=re(oe);var x=f(require("axios"));var w=f(require("lodash.clonedeep")),ne=f(require("lodash.debounce")),p=f(require("lodash.merge")),ae=f(require("lodash.clone"));var j=e=>typeof e=="string",b=e=>typeof e=="number";function N(e){return typeof e=="boolean"}var v=e=>Array.isArray(e);var D=e=>Object.prototype.toString.call(e)==="[object Object]",k=e=>Object.prototype.toString.call(e)==="[object Object]";function O(e){return e==null||e===""||typeof e=="number"&&Number.isNaN(e)}function B(e,r=[],t){if(e==null)return t||e;let a=Object.getOwnPropertyNames(e).reduce((s,o)=>(r.includes(o)||(s[o]=e[o]),s),{});return Object.assign(a,t)}function I(e={}){let r=new FormData;return Object.entries(e).forEach(([t,n])=>{r.append(t,n)}),r}var m={data:"data",code:"code",msg:"msg"},L={label:"label",value:"value",json:"json"},h={pageSize:"pageSize",pageNo:"pageNo",total:"total",records:"records"},U={baseURL:"",timeout:60*1e3,basePath:"",allowCancel:!1,allowNullValue:!0,successCode:200,whiteUrl:()=>[],alias:()=>m,token:{key:"x-access-token",get:()=>""}},A=401;var M=f(require("axios")),u=new Map;function _(e){let{url:r,method:t,params:n,data:a,headers:s}=e,o=a,c=n;typeof a=="string"&&(o=JSON.parse(a)),typeof n=="string"&&(c=JSON.parse(n));let i=[],l=s?.["X-Cancel-Rule"];return l==="path"?i=[`\u8BF7\u6C42\u8DEF\u5F84:${r}`]:l==="method"?i=[`\u8BF7\u6C42\u8DEF\u5F84:${r}`,`\u8BF7\u6C42\u65B9\u6CD5:${t}`]:i=[`\u8BF7\u6C42\u8DEF\u5F84:${r}`,`\u8BF7\u6C42\u65B9\u6CD5:${t}`,`\u8BF7\u6C42PARAMS:${JSON.stringify(c)}`,`\u8BF7\u6C42DATA:${JSON.stringify(o)}`],i.join(";")}function F(e){if(!e.headers?.neverCancel){let r=_(e);e.cancelToken=new M.default.CancelToken(t=>{u.has(r)||u.set(r,t)})}}function y(e,r=!1){if(!e.headers?.["X-Never-Cancel"]||r){let t=_(e);if(u.has(t)){let n=u.get(t);n&&n(t),u.delete(t)}}}function R(){Array.from(u.keys()).forEach(e=>{u.get(e)&&u.get(e)(e),u.delete(e)})}function Q(e){return new Promise(r=>{let t=new FileReader;t.readAsText(e);let n={code:200,data:null,msg:""};t.onloadend=()=>{e.type==="application/json"?n=JSON.parse(t.result):n.data=e,r(n)}})}function $(e,r){return e.reduce((n,a)=>(n.find(o=>r.every(c=>o[c]===a[c]))||n.push(a),n),[])}function K(e={}){return Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function V(e={}){return Object.keys(e).reduce((r,t)=>{let n=e[t];return O(n)||(b(n)&&String(n).length>=15?r[t]=String(n):r[t]=n),r},{})}function T(e,r=m){let{code:t="code",data:n="data",msg:a="msg"}=r;return{data:e[n],msg:e[a],code:e[t]}}function E(e,r=L,t=!0){let{label:n="label",value:a="value",json:s="json"}=r,o=e.reduce((c,i)=>(D(i)?c.push({label:i[n],value:i[a],json:i[s]??i}):(b(i)||j(i)||N(i))&&c.push({label:i,value:i,json:{}}),c),[]);return t?$(o,["value"]):o}function P(e={pageSize:10,pageNo:1},r=h){return Object.keys(e).reduce((t,n)=>(t[r[n]]=e[n],t),{})}function G(e,r=h){let{records:t="records",total:n="total"}=r;return{records:e[t]??[],total:e[n]??0}}var H=new Map;function se(e){let r={},t=e.split("?")[1];return t&&t.split("&").forEach(n=>{let[a="",s=""]=n.split("=");r[a]=s}),r}function J(e,r){H.get(A)&&!r.whiteUrl?.().includes(e.url??"")&&y(e,!0);let t=(0,p.default)({},e),[n=""]=(t.url??"").split("?"),a=K((0,p.default)({},se(t.url??""),t.params));r.allowNullValue||(a=V(a)),t.url=n,t.params=a,t.headers?.["Content-Type"]||(0,p.default)(t.headers,{"Content-Type":"application/json;charset=utf-8"});let{token:s}=r;if(s?.key&&s.get()){let o={[s.key]:s.get()};(0,p.default)(t.headers,o)}else s?.key&&t.headers&&Reflect.deleteProperty(t.headers,s.key);return r.allowCancel&&(y(t),F(t)),r.beforeRequest?r.beforeRequest(t):t}function g(e,r,t){let n={type:e,content:r,options:t};if(e==="REQUEST"&&r.code===401){if(R(),t[401])return t[401](r)}else{if(e==="CANCEL"&&t.cancel)return t.cancel(n);if(t.error)return t.error(n)}return Promise.reject(n)}async function z(e,r){let{data:t,config:n}=e,a=t,s=n;if(r.afterRequest){let{data:c,config:i}=r.afterRequest(e,r);a=c,s=i}let o=(0,p.default)({},m,r.alias?.());if(y(e.config),a[o.code]===401)return g("REQUEST",T(a,o),r);if(H.delete(A),s.responseType==="blob"){let c=await Q(a);return c.code===200?T(c,o):g("REQUEST",c,r)}else return a[o.code]===r.successCode?Promise.resolve(T(a,o)):g("REQUEST",T(a,o),r)}var C=class{options;instance;constructor(r){this.options=(0,p.default)({},U,r),this.instance=this.setupInterceptors(this.options)}setupInterceptors(r){let t=x.default.create(B(r,["basePath","allowCancel","allowNullValue","successCode","whiteUrl","alias","token","beforeRequest","afterRequest",401,"cancel","error"]));return t.interceptors.request.use(n=>J(n,this.options)),t.interceptors.response.use(n=>z(n,this.options),n=>g((0,x.isCancel)(n)?"CANCEL":"ERROR",n,this.options)),t}fetchLocalFile(r){return fetch((this.options.basePath??"")+r)}async get(r,t={},n){let{data:a}=await this.instance.get(r,{...n,params:t});return a}async post(r,t={},n){let{data:a}=await this.instance.post(r,t,n);return a}async postForm(r,t={},n){let a=I(t),{data:s}=await this.instance.post(r,a,(0,p.default)({},{headers:{"Content-Type":"multipart/form-data"},...n}));return s}async getPageRecords(r,t={},n={},a="GET",s,o){let c=a.toUpperCase()==="GET",i={...P(n,s),...t},{data:l}=await this.instance.request({...o,url:r,method:a,params:c?i:{...P(n,s)},data:c?{}:i});return G(l,s)}async getOptions(r,t={},n="GET",a,s,o=!0){let c=n.toUpperCase()==="GET",{data:i=[]}=await this.instance.request({...s,url:r,method:n,params:t,data:c?{}:t});if(v(i))return E(i,a,o);if(k(i)){let l=Object.entries(i).map(q=>({label:q[1],value:q[0]}));return E(l,void 0,o)}return[]}cancel(r){y(r,!0)}request(r){return this.instance.request(r)}destory(){R(),this.instance=null}};0&&(module.exports={ObrRequest});
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-525NDWM2.mjs";import"../chunk-WAYGIXU2.mjs";import"../chunk-VJPERUBQ.mjs";import"../chunk-XUFB5NAS.mjs";import"../chunk-G6V6TMDC.mjs";import"../chunk-44EYU7QJ.mjs";import"../chunk-M7WM427S.mjs";import"../chunk-SO3V4S32.mjs";import"../chunk-QFFI4BCG.mjs";import"../chunk-5YPCN6WZ.mjs";export{a as ObrRequest};
@@ -0,0 +1,23 @@
1
+ import { ObrAxiosRequestConfig } from '../../types.js';
2
+ import 'axios';
3
+
4
+ declare const pendingMap: Map<any, any>;
5
+ /**
6
+ * @description: 添加到pending队列
7
+ * @param {ObrAxiosRequestConfig} config
8
+ * @return {*}
9
+ * @autor: 刘 相卿
10
+ */
11
+ declare function addPending(config: ObrAxiosRequestConfig): void;
12
+ /**
13
+ * @description: 取消重复请求
14
+ * @param {ObrAxiosRequestConfig} config
15
+ * @param {boolean} force 强制执行
16
+ * @return {*}
17
+ * @autor: 刘 相卿
18
+ */
19
+ declare function removePending(config: ObrAxiosRequestConfig, force?: boolean): void;
20
+ declare function removeNdAddPending(config: ObrAxiosRequestConfig): void;
21
+ declare function removeAllPending(): void;
22
+
23
+ export { addPending, pendingMap, removeAllPending, removeNdAddPending, removePending };
@@ -0,0 +1 @@
1
+ "use strict";var x=Object.create;var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var v=(e,n)=>{for(var t in n)a(e,t,{get:n[t],enumerable:!0})},p=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of C(n))!O.call(e,i)&&i!==t&&a(e,i,{get:()=>n[i],enumerable:!(r=y(n,i))||r.enumerable});return e};var R=(e,n,t)=>(t=e!=null?x(h(e)):{},p(n||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),$=e=>p(a({},"__esModule",{value:!0}),e);var P={};v(P,{addPending:()=>u,pendingMap:()=>o,removeAllPending:()=>N,removeNdAddPending:()=>b,removePending:()=>m});module.exports=$(P);var c=R(require("axios")),o=new Map;function g(e){let{url:n,method:t,params:r,data:i,headers:A}=e,d=i,f=r;typeof i=="string"&&(d=JSON.parse(i)),typeof r=="string"&&(f=JSON.parse(r));let s=[],l=A?.["X-Cancel-Rule"];return l==="path"?s=[`\u8BF7\u6C42\u8DEF\u5F84:${n}`]:l==="method"?s=[`\u8BF7\u6C42\u8DEF\u5F84:${n}`,`\u8BF7\u6C42\u65B9\u6CD5:${t}`]:s=[`\u8BF7\u6C42\u8DEF\u5F84:${n}`,`\u8BF7\u6C42\u65B9\u6CD5:${t}`,`\u8BF7\u6C42PARAMS:${JSON.stringify(f)}`,`\u8BF7\u6C42DATA:${JSON.stringify(d)}`],s.join(";")}function u(e){if(!e.headers?.neverCancel){let n=g(e);e.cancelToken=new c.default.CancelToken(t=>{o.has(n)||o.set(n,t)})}}function m(e,n=!1){if(!e.headers?.["X-Never-Cancel"]||n){let t=g(e);if(o.has(t)){let r=o.get(t);r&&r(t),o.delete(t)}}}function b(e){m(e),u(e)}function N(){Array.from(o.keys()).forEach(e=>{o.get(e)&&o.get(e)(e),o.delete(e)})}0&&(module.exports={addPending,pendingMap,removeAllPending,removeNdAddPending,removePending});
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"../../chunk-44EYU7QJ.mjs";export{b as addPending,a as pendingMap,e as removeAllPending,d as removeNdAddPending,c as removePending};
@@ -0,0 +1,6 @@
1
+ import { ResDataType } from '../../types.js';
2
+ import 'axios';
3
+
4
+ declare function readBlobResponse(file: Blob): Promise<ResDataType>;
5
+
6
+ export { readBlobResponse };
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var d=(e,a)=>{for(var t in a)r(e,t,{get:a[t],enumerable:!0})},i=(e,a,t,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of p(a))!l.call(e,o)&&o!==t&&r(e,o,{get:()=>a[o],enumerable:!(s=n(a,o))||s.enumerable});return e};var y=e=>i(r({},"__esModule",{value:!0}),e);var m={};d(m,{readBlobResponse:()=>R});module.exports=y(m);function R(e){return new Promise(a=>{let t=new FileReader;t.readAsText(e);let s={code:200,data:null,msg:""};t.onloadend=()=>{e.type==="application/json"?s=JSON.parse(t.result):s.data=e,a(s)}})}0&&(module.exports={readBlobResponse});
@@ -0,0 +1 @@
1
+ import{a}from"../../chunk-VJPERUBQ.mjs";export{a as readBlobResponse};
@@ -0,0 +1,11 @@
1
+ import { ObjectDataType, ResDataType, ResAlias, OptionResAlias, BaseOptionType, PageQueryType, PageAlias, PageResType } from '../../types.js';
2
+ import 'axios';
3
+
4
+ declare function sort(object?: ObjectDataType): ObjectDataType<any, string>;
5
+ declare function format(object?: ObjectDataType): ObjectDataType<any, string>;
6
+ declare function formatData(object: ResDataType, alias?: ResAlias): ResDataType;
7
+ declare function formatOption<T = ObjectDataType>(array: any[], alias?: Partial<OptionResAlias>, unique?: boolean): BaseOptionType<T>[];
8
+ declare function formatPageQuery(object?: PageQueryType, alias?: Partial<PageAlias>): ObjectDataType<any, string>;
9
+ declare function formatPageRecords<T = ObjectDataType>(data: ObjectDataType, alias?: Partial<PageAlias>): PageResType<T>;
10
+
11
+ export { format, formatData, formatOption, formatPageQuery, formatPageRecords, sort };
@@ -0,0 +1 @@
1
+ "use strict";var D=Object.create;var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of R(t))!E.call(e,a)&&a!==n&&p(e,a,{get:()=>t[a],enumerable:!(r=h(t,a))||r.enumerable});return e};var c=(e,t,n)=>(n=e!=null?D(A(e)):{},g(t||!e||!e.__esModule?p(n,"default",{value:e,enumerable:!0}):n,e)),N=e=>g(p({},"__esModule",{value:!0}),e);var F={};S(F,{format:()=>I,formatData:()=>B,formatOption:()=>L,formatPageQuery:()=>_,formatPageRecords:()=>C,sort:()=>v});module.exports=N(F);var y={data:"data",code:"code",msg:"msg"},O={label:"label",value:"value",json:"json"},f={pageSize:"pageSize",pageNo:"pageNo",total:"total",records:"records"},U={baseURL:"",timeout:60*1e3,basePath:"",allowCancel:!1,allowNullValue:!0,successCode:200,whiteUrl:()=>[],alias:()=>y,token:{key:"x-access-token",get:()=>""}};var T=e=>typeof e=="string",u=e=>typeof e=="number";function d(e){return typeof e=="boolean"}var m=e=>Object.prototype.toString.call(e)==="[object Object]";function l(e){return e==null||e===""||typeof e=="number"&&Number.isNaN(e)}var x=c(require("lodash.clonedeep")),P=c(require("lodash.debounce")),w=c(require("lodash.merge")),k=c(require("lodash.clone"));function j(e,t){return e.reduce((r,a)=>(r.find(i=>t.every(s=>i[s]===a[s]))||r.push(a),r),[])}function v(e={}){return Object.keys(e).sort().reduce((n,r)=>(n[r]=e[r],n),{})}function I(e={}){return Object.keys(e).reduce((t,n)=>{let r=e[n];return l(r)||(u(r)&&String(r).length>=15?t[n]=String(r):t[n]=r),t},{})}function B(e,t=y){let{code:n="code",data:r="data",msg:a="msg"}=t;return{data:e[r],msg:e[a],code:e[n]}}function L(e,t=O,n=!0){let{label:r="label",value:a="value",json:b="json"}=t,i=e.reduce((s,o)=>(m(o)?s.push({label:o[r],value:o[a],json:o[b]??o}):(u(o)||T(o)||d(o))&&s.push({label:o,value:o,json:{}}),s),[]);return n?j(i,["value"]):i}function _(e={pageSize:10,pageNo:1},t=f){return Object.keys(e).reduce((n,r)=>(n[t[r]]=e[r],n),{})}function C(e,t=f){let{records:n="records",total:r="total"}=t;return{records:e[n]??[],total:e[r]??0}}0&&(module.exports={format,formatData,formatOption,formatPageQuery,formatPageRecords,sort});
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f}from"../../chunk-XUFB5NAS.mjs";import"../../chunk-G6V6TMDC.mjs";import"../../chunk-M7WM427S.mjs";import"../../chunk-SO3V4S32.mjs";import"../../chunk-QFFI4BCG.mjs";import"../../chunk-5YPCN6WZ.mjs";export{b as format,c as formatData,d as formatOption,e as formatPageQuery,f as formatPageRecords,a as sort};
@@ -1,4 +1,4 @@
1
- declare const delayTimer: (delay?: number) => Promise<unknown>;
1
+ declare function delayTimer(delay?: number): Promise<unknown>;
2
2
  declare function safeNextick(fn?: () => void, option?: {
3
3
  delay: number;
4
4
  }): void;
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(n,e)=>{for(var t in e)r(n,t,{get:e[t],enumerable:!0})},y=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!l.call(n,o)&&o!==t&&r(n,o,{get:()=>e[o],enumerable:!(s=p(e,o))||s.enumerable});return n};var b=n=>y(r({},"__esModule",{value:!0}),n);var x={};u(x,{delayTimer:()=>a,safeNextick:()=>m});module.exports=b(x);var i=n=>typeof n=="function";var a=async(n=0)=>new Promise(e=>{let t=setTimeout(()=>{e(!0),clearTimeout(t)},n)});async function m(n,e){await a(e?.delay),n&&i(n)&&n()}0&&(module.exports={delayTimer,safeNextick});
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var l=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},y=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of p(n))!u.call(t,r)&&r!==e&&o(t,r,{get:()=>n[r],enumerable:!(i=c(n,r))||i.enumerable});return t};var f=t=>y(o({},"__esModule",{value:!0}),t);var g={};l(g,{delayTimer:()=>a,safeNextick:()=>b});module.exports=f(g);var s=t=>typeof t=="function";async function a(t=0){return new Promise(n=>{let e=setTimeout(()=>{n(!0),clearTimeout(e)},t)})}async function b(t,n){await a(n?.delay),t&&s(t)&&t()}0&&(module.exports={delayTimer,safeNextick});
@@ -1 +1 @@
1
- import{a,b}from"./chunk-PPOXYBWE.mjs";import"./chunk-PWYR6CSX.mjs";export{a as delayTimer,b as safeNextick};
1
+ import{a,b}from"./chunk-BJIYP2SP.mjs";import"./chunk-5YPCN6WZ.mjs";export{a as delayTimer,b as safeNextick};
@@ -0,0 +1,164 @@
1
+ import { AxiosRequestConfig, AxiosResponse, AxiosStatic, CreateAxiosDefaults, AxiosInstance, AxiosInterceptorManager, Method } from 'axios';
2
+
3
+ type ObjectDataType<T = any, D extends string = string> = Record<D, T>;
4
+ /**
5
+ * @description: 树形结构数据类型
6
+ * @autor: 刘 相卿
7
+ */
8
+ interface TreeItemType extends ObjectDataType {
9
+ label?: string;
10
+ children?: TreeItemType[];
11
+ }
12
+ /**
13
+ * @description: 数据类型
14
+ * @autor: 刘 相卿
15
+ */
16
+ type DataType = 'set' | 'map' | 'function' | 'object' | 'array' | 'undefined' | 'null' | 'number' | 'symbol' | 'string' | 'boolean' | 'regexp' | 'date' | 'bigint' | 'blob' | 'formdata';
17
+ interface MappingType {
18
+ [x: string | number]: any;
19
+ default: any;
20
+ }
21
+ interface BaseOptionType<T = ObjectDataType> extends ObjectDataType {
22
+ label: string;
23
+ value: string | number;
24
+ json?: T;
25
+ }
26
+ interface OptionResAlias {
27
+ label: string;
28
+ value: string;
29
+ json: string;
30
+ }
31
+ /**
32
+ * @description: Token配置类型
33
+ * @param {string} key token的键名称
34
+ * @param {() => string} get 获取token的方法
35
+ * @autor: 刘 相卿
36
+ */
37
+ interface TokenConfig {
38
+ key: string;
39
+ get: () => string;
40
+ }
41
+ /**
42
+ * @description: header配置
43
+ * @param {boolean} `X-Never-Cancel` 是否永远不取消该请求
44
+ * @param {'path' | 'method' | 'params'} `X-Cancel-Rule` 取消规则(path: 同一路径; method: 同一路径+请求方法; params: 同一路径+请求方法+参数)
45
+ * @param {boolean} `X-Hide-Message` 是否隐藏请求消息提示
46
+ * @autor: 刘 相卿
47
+ */
48
+ interface HeadersType {
49
+ 'X-Never-Cancel'?: boolean;
50
+ 'X-Cancel-Rule'?: 'path' | 'method' | 'params';
51
+ 'X-Hide-Message'?: boolean;
52
+ }
53
+ interface ObrAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
54
+ headers?: AxiosRequestConfig['headers'] & HeadersType;
55
+ }
56
+ interface ObrAxiosResponse<T = any> extends Omit<AxiosResponse<T>, 'data'> {
57
+ data: ResDataType<T>;
58
+ }
59
+ interface ObrAxiosStatic extends Omit<AxiosStatic, 'create'> {
60
+ create: (config?: CreateAxiosDefaults) => ObrAxiosInstance;
61
+ }
62
+ interface ObrAxiosInstance extends Pick<AxiosInstance, 'defaults'> {
63
+ interceptors: {
64
+ request: AxiosInterceptorManager<ObrAxiosRequestConfig>;
65
+ response: AxiosInterceptorManager<ObrAxiosResponse<ResDataType>>;
66
+ };
67
+ <T = any, D = any>(config: AxiosRequestConfig<D>): Promise<ResDataType<T>>;
68
+ <T = any, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<ResDataType<T>>;
69
+ getUri: (config?: ObrAxiosRequestConfig) => string;
70
+ request: <T = any>(config: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
71
+ get: <T = any>(url: string, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
72
+ delete: <T = any>(url: string, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
73
+ head: <T = any>(url: string, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
74
+ options: <T = any>(url: string, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
75
+ post: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
76
+ put: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
77
+ postForm: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
78
+ putForm: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
79
+ patch: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
80
+ patchForm: <T = any, D = any>(url: string, data?: D, config?: ObrAxiosRequestConfig) => Promise<ResDataType<T>>;
81
+ }
82
+ /**
83
+ * @description: 响应字段别名
84
+ * @param {string} code 响应code别名
85
+ * @param {string} data 响应数据别名
86
+ * @param {string} msg 响应消息提示别名
87
+ * @autor: 刘 相卿
88
+ */
89
+ interface ResAlias {
90
+ code: string;
91
+ data: string;
92
+ msg: string;
93
+ }
94
+ interface PageAlias {
95
+ records: string;
96
+ total: string;
97
+ pageSize: string;
98
+ pageNo: string;
99
+ }
100
+ /**
101
+ * @description: 响应数据类型
102
+ * @param {number} code 响应code
103
+ * @param {T} data 响应数据
104
+ * @param {string} msg 响应消息提示
105
+ * @autor: 刘 相卿
106
+ */
107
+ interface ResDataType<T = any> extends ObjectDataType {
108
+ code: number;
109
+ data: T;
110
+ msg: string;
111
+ }
112
+ /**
113
+ * @description: 分页接口响应数据
114
+ * @param {R[]} records 分页数据
115
+ * @param {number} total 分页总数
116
+ * @autor: 刘 相卿
117
+ */
118
+ interface PageResType<R = ObjectDataType> {
119
+ records: R[];
120
+ total: number;
121
+ }
122
+ /**
123
+ * @description: 错误消息类型
124
+ * @param {number} type 错误类型
125
+ * @param {T} error 错误数据
126
+ * @autor: 刘 相卿
127
+ */
128
+ interface ErrorContentObject {
129
+ REQUEST: ResDataType;
130
+ CANCEL: any;
131
+ ERROR: any;
132
+ }
133
+ interface ErrorType<T extends keyof ErrorContentObject> {
134
+ type: T;
135
+ content: ErrorContentObject[T];
136
+ options: RequestBaseConfig;
137
+ }
138
+ /**
139
+ * @description: 分页查询请求参数
140
+ * @param {number} pageSize 分页大小 = 10
141
+ * @param {number} pageNo 分页页码 = 1
142
+ * @autor: 刘 相卿
143
+ */
144
+ interface PageQueryType {
145
+ pageSize?: number;
146
+ pageNo?: number;
147
+ }
148
+ interface RequestBaseConfig extends AxiosRequestConfig {
149
+ basePath?: string;
150
+ allowCancel?: boolean;
151
+ allowNullValue?: boolean;
152
+ successCode?: number;
153
+ whiteUrl?: () => string[];
154
+ alias?: () => Partial<ResAlias>;
155
+ token?: TokenConfig;
156
+ beforeRequest?: (config: ObrAxiosRequestConfig) => ObrAxiosRequestConfig;
157
+ afterRequest?: (response: ObrAxiosResponse<ResDataType>, options: RequestBaseConfig) => ObrAxiosResponse<ResDataType>;
158
+ 401?: (error: ResDataType) => any;
159
+ cancel?: (error: ErrorType<'CANCEL'>) => any;
160
+ error?: (error: ErrorType<'ERROR'>) => any;
161
+ }
162
+ type RequestMethod = Method;
163
+
164
+ export { BaseOptionType, DataType, ErrorContentObject, ErrorType, HeadersType, MappingType, ObjectDataType, ObrAxiosInstance, ObrAxiosRequestConfig, ObrAxiosResponse, ObrAxiosStatic, OptionResAlias, PageAlias, PageQueryType, PageResType, RequestBaseConfig, RequestMethod, ResAlias, ResDataType, TokenConfig, TreeItemType };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var g=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of i(e))!p.call(t,s)&&s!==n&&a(t,s,{get:()=>e[s],enumerable:!(r=o(e,s))||r.enumerable});return t};var T=t=>g(a({},"__esModule",{value:!0}),t);var y={};module.exports=T(y);
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ import"./chunk-WBQAMGXK.mjs";
@@ -1,6 +1,6 @@
1
1
  import { Ref, ComputedRef, ShallowRef } from 'vue';
2
2
 
3
- declare const useClipboard: (delay?: number) => {
3
+ declare function useClipboard(delay?: number): {
4
4
  copied: Ref<boolean, boolean>;
5
5
  copy: (text: string | Ref<string> | ComputedRef<string> | ShallowRef<string>) => void;
6
6
  };
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!u.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=p(e,n))||r.enumerable});return t};var f=t=>y(a({},"__esModule",{value:!0}),t);var C={};m(C,{useClipboard:()=>h});module.exports=f(C);var c=require("vue");function i(){return new DOMException("The request is not allowed","NotAllowedError")}async function w(t){if(!navigator.clipboard)throw i();return navigator.clipboard.writeText(t)}async function g(t){let e=document.createElement("span");e.textContent=t,e.style.whiteSpace="pre",e.style.webkitUserSelect="auto",e.style.userSelect="all",document.body.appendChild(e);let o=window.getSelection(),r=window.document.createRange();o.removeAllRanges(),r.selectNode(e),o.addRange(r);let n=!1;try{n=window.document.execCommand("copy")}finally{o.removeAllRanges(),window.document.body.removeChild(e)}if(!n)throw i()}async function s(t){try{await w(t)}catch(e){try{await g(t)}catch(o){throw o||e||i()}}}var h=(t=3e3)=>{let e=(0,c.ref)(!1);return{copied:e,copy:r=>{let n=(0,c.unref)(r);s(n).then(()=>{e.value=!0;let l=setTimeout(()=>{e.value=!1,clearTimeout(l)},t)})}}};0&&(module.exports={useClipboard});
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},f=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d(e))!u.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=p(e,n))||r.enumerable});return t};var y=t=>f(a({},"__esModule",{value:!0}),t);var C={};m(C,{useClipboard:()=>h});module.exports=y(C);var c=require("vue");function i(){return new DOMException("The request is not allowed","NotAllowedError")}async function w(t){if(!navigator.clipboard)throw i();return navigator.clipboard.writeText(t)}async function g(t){let e=document.createElement("span");e.textContent=t,e.style.whiteSpace="pre",e.style.webkitUserSelect="auto",e.style.userSelect="all",document.body.appendChild(e);let o=window.getSelection(),r=window.document.createRange();o.removeAllRanges(),r.selectNode(e),o.addRange(r);let n=!1;try{n=window.document.execCommand("copy")}finally{o.removeAllRanges(),window.document.body.removeChild(e)}if(!n)throw i()}async function l(t){try{await w(t)}catch(e){try{await g(t)}catch(o){throw o||e||i()}}}function h(t=3e3){let e=(0,c.ref)(!1);return{copied:e,copy:r=>{let n=(0,c.unref)(r);l(n).then(()=>{e.value=!0;let s=setTimeout(()=>{e.value=!1,clearTimeout(s)},t)})}}}0&&(module.exports={useClipboard});
@@ -1 +1 @@
1
- import{a}from"../../chunk-BTRFNTUR.mjs";import"../../chunk-6DX7ZFGR.mjs";export{a as useClipboard};
1
+ import{a}from"../../chunk-TQ5GXPYB.mjs";import"../../chunk-6DX7ZFGR.mjs";export{a as useClipboard};
package/dist/vue/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of l(n))!d.call(e,r)&&r!==t&&p(e,r,{get:()=>n[r],enumerable:!(o=c(n,r))||o.enumerable});return e};var w=e=>m(p({},"__esModule",{value:!0}),e);var j={};f(j,{anyType:()=>i,arrayType:()=>h,booleanType:()=>g,eventType:()=>R,functionType:()=>A,getEventValue:()=>N,numberType:()=>b,objectType:()=>C,runAsyncEvent:()=>E,runEvent:()=>k,someType:()=>v,stringType:()=>x,useClipboard:()=>y,vNodeType:()=>P});module.exports=w(j);function x(e){return{type:String,default:e}}function b(e){return{type:Number,default:e}}function g(e){return{type:Boolean,default:e}}function h(e){return{type:Array,default:e}}function C(e){return{type:Object,default:e}}function A(e){return{type:Function,default:e}}function i(e,n){let t={validator:()=>!0,default:e};return t}function P(){return{validator:()=>!0}}function v(e,n){return e?{type:e,default:n}:i(n)}function R(){return{type:[Function,Array]}}function k(e,...n){if(typeof e=="function")return e(...n);if(Array.isArray(e))return e.map(t=>t(...n))}async function E(e,...n){if(typeof e=="function")return await e(...n);if(Array.isArray(e))return await Promise.all(e.map(t=>t(...n)))}function N(e,n=0){return Array.isArray(e)?e[n]:e}var a=require("vue");function u(){return new DOMException("The request is not allowed","NotAllowedError")}async function S(e){if(!navigator.clipboard)throw u();return navigator.clipboard.writeText(e)}async function V(e){let n=document.createElement("span");n.textContent=e,n.style.whiteSpace="pre",n.style.webkitUserSelect="auto",n.style.userSelect="all",document.body.appendChild(n);let t=window.getSelection(),o=window.document.createRange();t.removeAllRanges(),o.selectNode(n),t.addRange(o);let r=!1;try{r=window.document.execCommand("copy")}finally{t.removeAllRanges(),window.document.body.removeChild(n)}if(!r)throw u()}async function s(e){try{await S(e)}catch(n){try{await V(e)}catch(t){throw t||n||u()}}}var y=(e=3e3)=>{let n=(0,a.ref)(!1);return{copied:n,copy:o=>{let r=(0,a.unref)(o);s(r).then(()=>{n.value=!0;let T=setTimeout(()=>{n.value=!1,clearTimeout(T)},e)})}}};0&&(module.exports={anyType,arrayType,booleanType,eventType,functionType,getEventValue,numberType,objectType,runAsyncEvent,runEvent,someType,stringType,useClipboard,vNodeType});
1
+ "use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of l(n))!d.call(e,r)&&r!==t&&p(e,r,{get:()=>n[r],enumerable:!(o=c(n,r))||o.enumerable});return e};var w=e=>m(p({},"__esModule",{value:!0}),e);var j={};f(j,{anyType:()=>i,arrayType:()=>h,booleanType:()=>g,eventType:()=>R,functionType:()=>A,getEventValue:()=>N,numberType:()=>b,objectType:()=>C,runAsyncEvent:()=>E,runEvent:()=>k,someType:()=>v,stringType:()=>x,useClipboard:()=>y,vNodeType:()=>P});module.exports=w(j);function x(e){return{type:String,default:e}}function b(e){return{type:Number,default:e}}function g(e){return{type:Boolean,default:e}}function h(e){return{type:Array,default:e}}function C(e){return{type:Object,default:e}}function A(e){return{type:Function,default:e}}function i(e,n){let t={validator:()=>!0,default:e};return t}function P(){return{validator:()=>!0}}function v(e,n){return e?{type:e,default:n}:i(n)}function R(){return{type:[Function,Array]}}function k(e,...n){if(typeof e=="function")return e(...n);if(Array.isArray(e))return e.map(t=>t(...n))}async function E(e,...n){if(typeof e=="function")return await e(...n);if(Array.isArray(e))return await Promise.all(e.map(t=>t(...n)))}function N(e,n=0){return Array.isArray(e)?e[n]:e}var a=require("vue");function u(){return new DOMException("The request is not allowed","NotAllowedError")}async function S(e){if(!navigator.clipboard)throw u();return navigator.clipboard.writeText(e)}async function V(e){let n=document.createElement("span");n.textContent=e,n.style.whiteSpace="pre",n.style.webkitUserSelect="auto",n.style.userSelect="all",document.body.appendChild(n);let t=window.getSelection(),o=window.document.createRange();t.removeAllRanges(),o.selectNode(n),t.addRange(o);let r=!1;try{r=window.document.execCommand("copy")}finally{t.removeAllRanges(),window.document.body.removeChild(n)}if(!r)throw u()}async function s(e){try{await S(e)}catch(n){try{await V(e)}catch(t){throw t||n||u()}}}function y(e=3e3){let n=(0,a.ref)(!1);return{copied:n,copy:o=>{let r=(0,a.unref)(o);s(r).then(()=>{n.value=!0;let T=setTimeout(()=>{n.value=!1,clearTimeout(T)},e)})}}}0&&(module.exports={anyType,arrayType,booleanType,eventType,functionType,getEventValue,numberType,objectType,runAsyncEvent,runEvent,someType,stringType,useClipboard,vNodeType});
@@ -1 +1 @@
1
- import"../chunk-G27KRYT2.mjs";import{a as n}from"../chunk-BTRFNTUR.mjs";import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../chunk-YA66RVVU.mjs";import"../chunk-6DX7ZFGR.mjs";export{g as anyType,d as arrayType,c as booleanType,j as eventType,f as functionType,m as getEventValue,b as numberType,e as objectType,l as runAsyncEvent,k as runEvent,i as someType,a as stringType,n as useClipboard,h as vNodeType};
1
+ import"../chunk-G27KRYT2.mjs";import{a as n}from"../chunk-TQ5GXPYB.mjs";import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../chunk-YA66RVVU.mjs";import"../chunk-6DX7ZFGR.mjs";export{g as anyType,d as arrayType,c as booleanType,j as eventType,f as functionType,m as getEventValue,b as numberType,e as objectType,l as runAsyncEvent,k as runEvent,i as someType,a as stringType,n as useClipboard,h as vNodeType};
package/package.json CHANGED
@@ -1,27 +1,35 @@
1
1
  {
2
2
  "name": "@obr-fe/utils",
3
- "version": "0.0.4",
4
- "description": "obr前端工具函数库",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "1.0.4",
4
+ "description": "欧倍尔前端工具函数库",
5
+ "author": "obr-fe",
6
+ "license": "ISC",
7
+ "keywords": [
8
+ "utils",
9
+ "axios",
10
+ "typescript",
11
+ "vue"
12
+ ],
7
13
  "exports": {
8
14
  ".": {
15
+ "types": "./dist/index.d.ts",
9
16
  "import": "./dist/index.js",
10
- "require": "./dist/index.cjs",
11
- "types": "./dist/index.d.ts"
17
+ "require": "./dist/index.cjs"
12
18
  },
13
19
  "./*": {
20
+ "types": "./dist/**/*.d.ts",
14
21
  "import": "./dist/**/*.js",
15
- "require": "./dist/**/*.cjs",
16
- "types": "./dist/**/*.d.ts"
22
+ "require": "./dist/**/*.cjs"
17
23
  },
18
24
  "./dist/*": {
25
+ "types": "./dist/**/*.d.ts",
19
26
  "import": "./dist/**/*.js",
20
- "require": "./dist/**/*.cjs",
21
- "types": "./dist/**/*.d.ts"
27
+ "require": "./dist/**/*.cjs"
22
28
  },
23
29
  "./package.json": "./package.json"
24
30
  },
31
+ "main": "dist/index.js",
32
+ "types": "dist/index.d.ts",
25
33
  "files": [
26
34
  "dist"
27
35
  ],
@@ -30,39 +38,29 @@
30
38
  "dev": "tsup --watch",
31
39
  "docs:dev": "vitepress dev docs",
32
40
  "docs:build": "vitepress build docs",
33
- "docs:preview": "vitepress preview docs"
41
+ "docs:preview": "vitepress preview docs",
42
+ "fix": "eslint . --fix",
43
+ "publish": "npm publish --registry https://dev-fe.oberyun.com/npm/"
34
44
  },
35
- "repository": {
36
- "type": "git",
37
- "url": "http://gitlab.oberyun.com/obr-fe-base/lib/obr-utils"
38
- },
39
- "keywords": [
40
- "前端工具函数库",
41
- "typescript",
42
- "vue"
43
- ],
44
- "author": "obr-fe",
45
- "license": "MIT",
46
- "publishConfig": {
47
- "access": "public"
45
+ "dependencies": {
46
+ "axios": "^1.7.7",
47
+ "lodash.clone": "^4.5.0",
48
+ "lodash.clonedeep": "^4.5.0",
49
+ "lodash.debounce": "^4.0.8",
50
+ "lodash.merge": "^4.6.2",
51
+ "vue": "^3.4.29"
48
52
  },
49
53
  "devDependencies": {
50
- "@antfu/eslint-config": "^2.18.1",
54
+ "@antfu/eslint-config": "^2.27.3",
51
55
  "@types/lodash.clone": "^4.5.9",
52
56
  "@types/lodash.clonedeep": "^4.5.9",
53
57
  "@types/lodash.debounce": "^4.0.9",
54
58
  "@types/lodash.merge": "^4.6.9",
55
59
  "@types/node": "^20.12.12",
60
+ "eslint": "^9.15.0",
56
61
  "fast-glob": "^3.3.1",
57
62
  "tsup": "^6.7.0",
58
63
  "typescript": "^4.9.5",
59
64
  "vitepress": "^1.0.2"
60
- },
61
- "dependencies": {
62
- "lodash.clone": "^4.5.0",
63
- "lodash.clonedeep": "^4.5.0",
64
- "lodash.debounce": "^4.0.8",
65
- "lodash.merge": "^4.6.2",
66
- "vue": "^3.4.29"
67
65
  }
68
66
  }
@@ -1 +0,0 @@
1
- var a=e=>{e&&e.parentNode?.removeChild(e)},s=(e,r)=>{let n=e.slice(1);return"rgba("+[parseInt("0x"+n.slice(0,2)),parseInt("0x"+n.slice(2,4)),parseInt("0x"+n.slice(4,6)),r].toString()+")"},o=(e,r)=>e[r]??e.default,i=e=>e.toString().replace(/\d+/,r=>r.replace(/(\d)(?=(\d{3})+$)/g,n=>n+","));export{a,s as b,o as c,i as d};
@@ -1 +0,0 @@
1
- var d=l=>{let e=l?.vnode?.el||l&&(l.$el||l);for(;e&&!e.tagName;)e=e.nextSibling;return e},o=d;export{o as a};
@@ -1 +0,0 @@
1
- var d=t=>{document.title=t},u=(t,e=1920,r=1080)=>{let o=document.documentElement.clientWidth||document.body.clientWidth||e,n=window.screen.height||document.body.clientHeight||e,c=e/r;return o/n/c*t},i=()=>{let t=document.querySelectorAll("[style*=z-index]"),e=0;return t.forEach(r=>{let o=window.getComputedStyle(r).zIndex;if(o!=="auto"){let n=parseInt(o,10);!isNaN(n)&&n>e&&(e=n)}}),e+1};export{d as a,u as b,i as c};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-6DX7ZFGR.mjs";import{ref as p,unref as f}from"vue";var m=(t=3e3)=>{let e=p(!1);return{copied:e,copy:r=>{let s=f(r);o(s).then(()=>{e.value=!0;let i=setTimeout(()=>{e.value=!1,clearTimeout(i)},t)})}}};export{m as a};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-KGXCJWE5.mjs";var i=n=>{if(o()&&window.document.documentElement){let t=Array.isArray(n)?n:[n],{documentElement:r}=window.document;return t.some(e=>e in r.style)}return!1},s=(n,t)=>{if(!i(n))return!1;let r=document.createElement("div"),e=r.style[n];return r.style[n]=t,r.style[n]!==e};function a(n,t){return!Array.isArray(n)&&t!==void 0?s(n,t):i(n)}export{a};
@@ -1 +0,0 @@
1
- var l=(n,c=4)=>{let s=[],i=1048576*c,e=0;for(;e<n.size;){let u=n.slice(e,e+i);s.push({file:u,size:u.size,index:e/i}),e+=i}return s};export{l as a};
@@ -1 +0,0 @@
1
- import{a as y}from"./chunk-SO3V4S32.mjs";import{h as m}from"./chunk-LZM3K4ZI.mjs";import{b as p,j as T,o as l,p as u}from"./chunk-PWYR6CSX.mjs";var j=(...t)=>t,D=(...t)=>t,E=t=>Array.isArray(t)?t:[t],v=(t=[],s="id",r="pid",o="children")=>{let a=[],i={},n=y(t);for(let e=0;e<n.length;e++)i[n[e][s]]=n[e];for(let e=0;e<n.length;e++)i[n[e][r]]&&n[e][s]!==n[e][r]?(i[n[e][r]][o]||(i[n[e][r]][o]=[]),i[n[e][r]][o].push(n[e])):a.push(n[e]);return a},I=(t,s)=>t.map(r=>({label:r[s.label],value:r[s.value]})),N=t=>t.filter(s=>!l(s)),b=(t=[],s,r)=>{let o={value:"value",children:"children",...m(r)},a=[],[i]=s,n=t.find(e=>e[o.value]===i);if(!l(i)&&!l(n)){let{[o.children]:e,...c}=n;return a.concat(c,...b(e??[],s.slice(1),o))}return a},A=(t=[],s="children")=>{let r=[],o=(a,i)=>{a.forEach(n=>{let{[i]:e,...c}=n;r.push(c),e&&o(e,i)})};return o(t,s),r},B=(t,s)=>t.reduce((o,a)=>(o.find(n=>s.every(e=>n[e]===a[e]))||o.push(a),o),[]),V=(t,s=[])=>t.filter(r=>!s.includes(r)),q=(t,s=[])=>t.filter(r=>!s.some(a=>T(a)&&T(r)?u(a)?u(r):Object.entries(a).every(([i,n])=>n===r[i]):p(a)&&isNaN(a)?p(r)&&isNaN(r):r===a));export{j as a,D as b,E as c,v as d,I as e,N as f,b as g,A as h,B as i,V as j,q as k};
@@ -1 +0,0 @@
1
- import{o}from"./chunk-PWYR6CSX.mjs";function i(e,n=[],t){if(e==null)return t||e;let r=Object.getOwnPropertyNames(e).reduce((s,c)=>(n.includes(c)&&(s[c]=e[c]),s),{});return Object.assign(r,t)}function u(e,n=[],t){if(e==null)return t||e;let r=Object.getOwnPropertyNames(e).reduce((s,c)=>(n.includes(c)||(s[c]=e[c]),s),{});return Object.assign(r,t)}var y=(e={},n=!0)=>{let t=Object.keys(e).sort();return n||t.reverse(),t.reduce((a,r)=>(a[r]=e[r],a),{})},O=(e={})=>Object.entries(e).reduce((n,[t,a])=>(o(a)||n.push(`${t}=${a}`),n),[]).join("&"),d=e=>{let n={},t=e.split("?")[1];return t&&t.split("&").forEach(a=>{let[r="",s=""]=a.split("=");n[r]=s}),n},j=(e={})=>{let n=new FormData;return Object.entries(e).forEach(([t,a])=>{n.append(t,a)}),n},T=e=>{let n={};for(let[t,a]of e.entries())n[t]=a;return n},b=(e={})=>Object.entries(e).reduce((n,[t,a])=>(o(a)||(n[t]=a),n),{}),f=(e,n)=>Object.keys(n).reduce((t,a)=>(t[a]=e[a],t),{}),D=(e,n)=>n.every(t=>Reflect.has(e,t)),m=(e,n)=>Object.entries(n).reduce((t,[a,r])=>(t[a]=e[r],t),{});export{i as a,u as b,y as c,O as d,d as e,j as f,T as g,b as h,f as i,D as j,m as k};
@@ -1 +0,0 @@
1
- import{d as i}from"./chunk-PWYR6CSX.mjs";var n=async(e=0)=>new Promise(o=>{let t=setTimeout(()=>{o(!0),clearTimeout(t)},e)});async function a(e,o){await n(o?.delay),e&&i(e)&&e()}export{n as a,a as b};
@@ -1 +0,0 @@
1
- var o=n=>typeof n=="string",r=n=>typeof n=="number",s=n=>typeof n=="boolean",y=n=>typeof n=="function",u=n=>Array.isArray(n),i=n=>typeof n>"u",b=n=>typeof n<"u",p=n=>n===null,a=n=>typeof n=="symbol",g=n=>Object.prototype.toString.call(n)==="[object Object]",x=n=>Object.prototype.toString.call(n)==="[object Date]",m=n=>o(n)||r(n)||s(n)||a(n)||i(n)||p(n),f=n=>/^(https?|mailto|tel|file):/.test(n),d=(n,t=!0)=>t&&n===void 0||n===null||n==="null",c=n=>n==null||n===""||typeof n=="number"&&isNaN(n),w=n=>!n||Object.getOwnPropertyNames(n).length===0;function l(n=[]){return Array.isArray(n)&&!n.length}var k=(n=[])=>Array.isArray(n)?l(n)||n.every(t=>c(t)):!1,j=n=>Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),T=n=>(n.match(/\.([^.]+)$/)?.[1]??"\u672A\u77E5").toUpperCase(),D=(n,t,e)=>n.replace(new RegExp("(.*)"+t),`$1${e}`),O=(n,t,e)=>n.replace(new RegExp(t,"g"),e),A=n=>n&&n>0?n:0;export{o as a,r as b,s as c,y as d,u as e,i as f,b as g,p as h,a as i,g as j,x as k,m as l,f as m,d as n,c as o,w as p,l as q,k as r,j as s,T as t,D as u,O as v,A as w};
@@ -1 +0,0 @@
1
- var i=/margin|padding|width|height|max|min|offset/,l={left:!0,top:!0},r={cssFloat:1,styleFloat:1,float:1};function s(e){return e.nodeType===1?e.ownerDocument.defaultView.getComputedStyle(e,null):{}}function u(e,t,n){if(t=t.toLowerCase(),n==="auto"){if(t==="height")return e.offsetHeight;if(t==="width")return e.offsetWidth}return t in l||(l[t]=i.test(t)),l[t]?parseFloat(n)||0:n}function f(e,t){let n=arguments.length,o=s(e);return t=r[t]?"cssFloat"in e.style?"cssFloat":"styleFloat":t,n===1?o:u(e,t,o[t]||e.style[t])}function d(e,t,n){let o=arguments.length;if(t=r[t]?"cssFloat"in e.style?"cssFloat":"styleFloat":t,o===3)return typeof n=="number"&&i.test(t)&&(n=`${n}px`),e.style[t]=n,n;for(let c in t)t.hasOwnProperty(c)&&d(e,c,t[c]);return s(e)}function m(e){return e===document.body?document.documentElement.clientWidth:e.offsetWidth}function g(e){return e===document.body?window.innerHeight||document.documentElement.clientHeight:e.offsetHeight}function h(){let e=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);return{width:e,height:t}}function a(){let e=document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{width:e,height:t}}function y(){return{scrollLeft:Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),scrollTop:Math.max(document.documentElement.scrollTop,document.body.scrollTop)}}function p(e){let t=e.getBoundingClientRect(),n=document.documentElement;return{left:t.left+(window.pageXOffset||n.scrollLeft)-(n.clientLeft||document.body.clientLeft||0),top:t.top+(window.pageYOffset||n.scrollTop)-(n.clientTop||document.body.clientTop||0)}}export{f as a,d as b,m as c,g as d,h as e,a as f,y as g,p as h};
@@ -1,24 +0,0 @@
1
- /**
2
- * @description: 设置文档标题
3
- * @param {string} title
4
- * @return {*}
5
- * @autor: 刘 相卿
6
- */
7
- declare const setDocumentTitle: (title: string) => void;
8
- /**
9
- * @description: 动态计算px
10
- * @param {number} px 原始px数值
11
- * @param {number} width 设计稿宽度 默认1920
12
- * @param {number} height 设计稿高度 默认1080
13
- * @return {*}
14
- * @autor: 刘 相卿
15
- */
16
- declare const getPx: (px: number, width?: number, height?: number) => number;
17
- /**
18
- * @description: 获取页面中最大的z-index并+1
19
- * @return {number} zIndex 最大的index
20
- * @autor: 刘 相卿
21
- */
22
- declare const getMaxZIndex: () => number;
23
-
24
- export { getMaxZIndex, getPx, setDocumentTitle };
package/dist/document.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},l=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!s.call(t,n)&&n!==o&&c(t,n,{get:()=>e[n],enumerable:!(r=u(e,n))||r.enumerable});return t};var x=t=>l(c({},"__esModule",{value:!0}),t);var p={};m(p,{getMaxZIndex:()=>g,getPx:()=>b,setDocumentTitle:()=>a});module.exports=x(p);var a=t=>{document.title=t},b=(t,e=1920,o=1080)=>{let r=document.documentElement.clientWidth||document.body.clientWidth||e,n=window.screen.height||document.body.clientHeight||e,d=e/o;return r/n/d*t},g=()=>{let t=document.querySelectorAll("[style*=z-index]"),e=0;return t.forEach(o=>{let r=window.getComputedStyle(o).zIndex;if(r!=="auto"){let n=parseInt(r,10);!isNaN(n)&&n>e&&(e=n)}}),e+1};0&&(module.exports={getMaxZIndex,getPx,setDocumentTitle});
package/dist/document.mjs DELETED
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-BM65Z3BA.mjs";export{c as getMaxZIndex,b as getPx,a as setDocumentTitle};
File without changes