@qy_better_lib/core 0.2.1 → 0.2.3

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/DOCUMENTATION.md CHANGED
@@ -865,28 +865,28 @@
865
865
 
866
866
  ### 5. 随机值生成工具 (random.ts)
867
867
 
868
- #### generate_id
868
+ #### random_id
869
869
  - **功能**: 生成[0-10000]的随机数,针对数据小量使用
870
870
  - **返回类型**: `number` - 随机数
871
871
  - **示例**:
872
872
  ```typescript
873
- import { generate_id } from '@qy_better_lib/core';
873
+ import { random_id } from '@qy_better_lib/core';
874
874
 
875
- generate_id(); // 生成0-10000之间的随机数
875
+ random_id(); // 生成0-10000之间的随机数
876
876
  ```
877
877
 
878
- #### get_random_int
878
+ #### random_int
879
879
  - **功能**: 生成[0-max]的随机数
880
880
  - **参数**: `max: number` - 最大值
881
881
  - **返回类型**: `number` - 随机数
882
882
  - **示例**:
883
883
  ```typescript
884
- import { get_random_int } from '@qy_better_lib/core';
884
+ import { random_int } from '@qy_better_lib/core';
885
885
 
886
- get_random_int(10); // 生成0-10之间的随机整数
886
+ random_int(10); // 生成0-10之间的随机整数
887
887
  ```
888
888
 
889
- #### get_random_int_range
889
+ #### random_int_range
890
890
  - **功能**: 生成指定范围的随机整数
891
891
  - **参数**:
892
892
  - `min: number` - 最小值
@@ -894,12 +894,12 @@
894
894
  - **返回类型**: `number` - 随机整数
895
895
  - **示例**:
896
896
  ```typescript
897
- import { get_random_int_range } from '@qy_better_lib/core';
897
+ import { random_int_range } from '@qy_better_lib/core';
898
898
 
899
- get_random_int_range(1, 10); // 生成1-10之间的随机整数
899
+ random_int_range(1, 10); // 生成1-10之间的随机整数
900
900
  ```
901
901
 
902
- #### get_random_float
902
+ #### random_float
903
903
  - **功能**: 生成随机浮点数
904
904
  - **参数**:
905
905
  - `min: number` - 最小值
@@ -908,32 +908,32 @@
908
908
  - **返回类型**: `number` - 随机浮点数
909
909
  - **示例**:
910
910
  ```typescript
911
- import { get_random_float } from '@qy_better_lib/core';
911
+ import { random_float } from '@qy_better_lib/core';
912
912
 
913
- get_random_float(1, 10, 2); // 生成1-10之间的随机小数,保留2位小数
913
+ random_float(1, 10, 2); // 生成1-10之间的随机小数,保留2位小数
914
914
  ```
915
915
 
916
- #### generate_guid
916
+ #### guid
917
917
  - **功能**: 生成GUID/UUID
918
918
  - **返回类型**: `string` - GUID/UUID字符串
919
919
  - **示例**:
920
920
  ```typescript
921
- import { generate_guid } from '@qy_better_lib/core';
921
+ import { guid } from '@qy_better_lib/core';
922
922
 
923
- generate_guid(); // 生成一个随机GUID/UUID
923
+ guid(); // 生成一个随机GUID/UUID
924
924
  ```
925
925
 
926
- #### generate_string
926
+ #### random_string
927
927
  - **功能**: 生成随机字符串
928
928
  - **返回类型**: `string` - 随机字符串
929
929
  - **示例**:
930
930
  ```typescript
931
- import { generate_string } from '@qy_better_lib/core';
931
+ import { random_string } from '@qy_better_lib/core';
932
932
 
933
- generate_string(); // 生成一个随机字符串
933
+ random_string(); // 生成一个随机字符串
934
934
  ```
935
935
 
936
- #### generate_random_string
936
+ #### random_len_string
937
937
  - **功能**: 生成指定长度的随机字符串
938
938
  - **参数**:
939
939
  - `length: number` - 字符串长度
@@ -941,35 +941,35 @@
941
941
  - **返回类型**: `string` - 随机字符串
942
942
  - **示例**:
943
943
  ```typescript
944
- import { generate_random_string } from '@qy_better_lib/core';
944
+ import { random_len_string } from '@qy_better_lib/core';
945
945
 
946
- generate_random_string(10); // 生成10位随机字符串
947
- generate_random_string(8, 'ABCDEFG'); // 生成8位只包含指定字符的随机字符串
946
+ random_len_string(10); // 生成10位随机字符串
947
+ random_len_string(8, 'ABCDEFG'); // 生成8位只包含指定字符的随机字符串
948
948
  ```
949
949
 
950
- #### get_random_boolean
950
+ #### random_boolean
951
951
  - **功能**: 生成随机布尔值
952
952
  - **返回类型**: `boolean` - 随机布尔值
953
953
  - **示例**:
954
954
  ```typescript
955
- import { get_random_boolean } from '@qy_better_lib/core';
955
+ import { random_boolean } from '@qy_better_lib/core';
956
956
 
957
- get_random_boolean(); // 50%概率为true
957
+ random_boolean(); // 50%概率为true
958
958
  ```
959
959
 
960
- #### get_random_element
960
+ #### random_element
961
961
  - **功能**: 从数组中随机选择一个元素
962
962
  - **参数**: `array: T[]` - 源数组
963
963
  - **返回类型**: `T | undefined` - 随机选中的元素
964
964
  - **示例**:
965
965
  ```typescript
966
- import { get_random_element } from '@qy_better_lib/core';
966
+ import { random_element } from '@qy_better_lib/core';
967
967
 
968
968
  const array = ['a', 'b', 'c', 'd'];
969
- get_random_element(array); // 随机返回数组中的一个元素
969
+ random_element(array); // 随机返回数组中的一个元素
970
970
  ```
971
971
 
972
- #### get_random_elements
972
+ #### random_elements
973
973
  - **功能**: 从数组中随机选择多个元素
974
974
  - **参数**:
975
975
  - `array: T[]` - 源数组
@@ -977,73 +977,73 @@
977
977
  - **返回类型**: `T[]` - 随机选中的元素数组
978
978
  - **示例**:
979
979
  ```typescript
980
- import { get_random_elements } from '@qy_better_lib/core';
980
+ import { random_elements } from '@qy_better_lib/core';
981
981
 
982
982
  const array = ['a', 'b', 'c', 'd'];
983
- get_random_elements(array, 2); // 随机返回数组中的2个元素
983
+ random_elements(array, 2); // 随机返回数组中的2个元素
984
984
  ```
985
985
 
986
- #### generate_random_color
986
+ #### random_color
987
987
  - **功能**: 生成随机颜色
988
988
  - **返回类型**: `string` - 随机颜色的十六进制值
989
989
  - **示例**:
990
990
  ```typescript
991
- import { generate_random_color } from '@qy_better_lib/core';
991
+ import { random_color } from '@qy_better_lib/core';
992
992
 
993
- generate_random_color(); // 生成一个随机十六进制颜色
993
+ random_color(); // 生成一个随机十六进制颜色
994
994
  ```
995
995
 
996
- #### generate_random_number_string
996
+ #### random_number_string
997
997
  - **功能**: 生成指定长度的随机数字字符串
998
998
  - **参数**: `length: number` - 字符串长度
999
999
  - **返回类型**: `string` - 随机数字字符串
1000
1000
  - **示例**:
1001
1001
  ```typescript
1002
- import { generate_random_number_string } from '@qy_better_lib/core';
1002
+ import { random_number_string } from '@qy_better_lib/core';
1003
1003
 
1004
- generate_random_number_string(6); // 生成6位随机数字字符串
1004
+ random_number_string(6); // 生成6位随机数字字符串
1005
1005
  ```
1006
1006
 
1007
- #### generate_random_password
1007
+ #### random_password
1008
1008
  - **功能**: 生成随机密码
1009
1009
  - **参数**: `length: number` - 密码长度,默认 8
1010
1010
  - **返回类型**: `string` - 随机密码
1011
1011
  - **示例**:
1012
1012
  ```typescript
1013
- import { generate_random_password } from '@qy_better_lib/core';
1013
+ import { random_password } from '@qy_better_lib/core';
1014
1014
 
1015
- generate_random_password(); // 生成8位随机密码
1016
- generate_random_password(12); // 生成12位随机密码
1015
+ random_password(); // 生成8位随机密码
1016
+ random_password(12); // 生成12位随机密码
1017
1017
  ```
1018
1018
 
1019
- #### generate_random_phone
1019
+ #### random_phone
1020
1020
  - **功能**: 生成随机手机号
1021
1021
  - **返回类型**: `string` - 随机手机号
1022
1022
  - **示例**:
1023
1023
  ```typescript
1024
- import { generate_random_phone } from '@qy_better_lib/core';
1024
+ import { random_phone } from '@qy_better_lib/core';
1025
1025
 
1026
- generate_random_phone(); // 生成一个随机手机号
1026
+ random_phone(); // 生成一个随机手机号
1027
1027
  ```
1028
1028
 
1029
- #### generate_random_email
1029
+ #### random_email
1030
1030
  - **功能**: 生成随机邮箱
1031
1031
  - **返回类型**: `string` - 随机邮箱
1032
1032
  - **示例**:
1033
1033
  ```typescript
1034
- import { generate_random_email } from '@qy_better_lib/core';
1034
+ import { random_email } from '@qy_better_lib/core';
1035
1035
 
1036
- generate_random_email(); // 生成一个随机邮箱
1036
+ random_email(); // 生成一个随机邮箱
1037
1037
  ```
1038
1038
 
1039
- #### generate_random_url
1039
+ #### random_url
1040
1040
  - **功能**: 生成随机URL
1041
1041
  - **返回类型**: `string` - 随机URL
1042
1042
  - **示例**:
1043
1043
  ```typescript
1044
- import { generate_random_url } from '@qy_better_lib/core';
1044
+ import { random_url } from '@qy_better_lib/core';
1045
1045
 
1046
- generate_random_url(); // 生成一个随机URL
1046
+ random_url(); // 生成一个随机URL
1047
1047
  ```
1048
1048
 
1049
1049
  #### shuffle_array
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Modified MIT License
2
+
3
+ Copyright (c) 2024 Swordsman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software for non-commercial purposes without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ 1. The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ 2. Commercial use of the Software requires explicit written authorization from the copyright holders.
16
+ For commercial licensing inquiries, please contact the project maintainers.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
package/dist/core.min.js CHANGED
@@ -1 +1 @@
1
- (function(i,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("dayjs")):typeof define=="function"&&define.amd?define(["exports","dayjs"],g):(i=typeof globalThis<"u"?globalThis:i||self,g(i.QyBetterLibCore={},i.dayjs))})(this,(function(i,g){"use strict";function st(){return Math.floor(Math.random()*1e4)}function at(t){return t<0?0:Math.floor(Math.random()*Math.floor(t))}function ft(t,e){return t>e&&([t,e]=[e,t]),Math.floor(Math.random()*(e-t+1))+t}function lt(t,e,n=2){t>e&&([t,e]=[e,t]);const r=Math.random()*(e-t)+t;return parseFloat(r.toFixed(n))}function _t(){const t=P;return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function P(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function N(t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){let n="";const r=e.length;for(let o=0;o<t;o++)n+=e.charAt(Math.floor(Math.random()*r));return n}function dt(){return Math.random()>.5}function v(t){if(!(!t||t.length===0))return t[Math.floor(Math.random()*t.length)]}function ht(t,e){return!t||t.length===0||e<=0?[]:e>=t.length?[...t]:[...t].sort(()=>.5-Math.random()).slice(0,e)}function gt(){const t="0123456789ABCDEF";let e="#";for(let n=0;n<6;n++)e+=t[Math.floor(Math.random()*16)];return e}function j(t){return N(t,"0123456789")}function mt(t=8){return N(t,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=")}function yt(){const e=v(["130","131","132","133","134","135","136","137","138","139","150","151","152","153","155","156","157","158","159","170","171","172","173","175","176","177","178","180","181","182","183","184","185","186","187","188","189"]),n=j(8);return`${e}${n}`}function bt(){const t=["gmail.com","yahoo.com","hotmail.com","outlook.com","163.com","126.com","qq.com","sina.com"],e=N(8),n=v(t);return`${e}@${n}`}function wt(){const t=["http","https"],e=["example.com","test.com","demo.com","sample.com"],n=["api","docs","about","contact","products"],r=v(t),o=v(e),c=v(n),u=N(4);return`${r}://www.${o}/${c}?id=${u}`}function pt(t){if(!t)return[];const e=[...t];for(let n=e.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1));[e[n],e[r]]=[e[r],e[n]]}return e}function vt(t){return t===void 0}function Mt(t){return t===null}function l(t){return Array.isArray(t)}function h(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"}function Nt(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function W(t){return Object.prototype.toString.call(t)==="[object Date]"}function $t(t){return W(t)&&!isNaN(t.getTime())}function Et(t){return typeof t=="boolean"}function w(t){return typeof t=="function"}function kt(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ot(t){return typeof t=="symbol"}function St(t){return typeof t=="object"&&t!==null&&typeof t.then=="function"&&typeof t.catch=="function"}function zt(t){return!t&&t!==0||l(t)&&t.length===0||h(t)&&!Object.keys(t).length}function At(t){return!!t}function It(t){return!t}function D(t){return typeof Element>"u"?!1:t instanceof Element}function Dt(t){return typeof HTMLElement>"u"?!1:t instanceof HTMLElement}const U=typeof window<"u";function m(t){return typeof t=="number"&&!isNaN(t)}function L(t){return typeof t=="string"}function Lt(t){return L(t)?!Number.isNaN(Number(t)):!1}function Ft(t){return/^1[3-9]\d{9}$/.test(t)}function Tt(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Ct(t){try{return new URL(t),!0}catch{return!1}}function Rt(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}function Ht(t){return/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t)}function Pt(t){return/^(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)$/.test(t)}function jt(t,e="key",n="children"){const r={};if(!l(t))return r;const o=[{nodes:t}];for(;o.length>0;){const{nodes:c,parent_key:u}=o.pop();for(const s of c){const a=s[e];if(a&&!r[a]){r[a]=s,u&&r[u]&&(r[a].parent=r[u]);const f=s[n];f&&l(f)&&f.length>0&&o.push({nodes:f,parent_key:a})}}}return r}function Wt(t,e="key",n="parentId",r="children"){if(!l(t))return[];const o={},c=[];for(const u of t)o[u[e]]={...u},o[u[e]][r]||(o[u[e]][r]=[]);for(const u of t){const s=u[n];!s||!o[s]?c.push(o[u[e]]):o[s][r].push(o[u[e]])}return c}function Ut(t,e,n="children"){if(!e||!w(e))return!1;let r=!1;const o=l(t)?t:[t],c=[];for(const u of o)c.push({node:u,depth:0});for(;c.length>0;){const{node:u,depth:s}=c.pop();if(e(u,s)===!1){r=!0;break}const f=u[n];if(f&&l(f)&&f.length>0)for(let _=f.length-1;_>=0;_--)c.push({node:f[_],depth:s+1})}return r}function Bt(t,e,n="children"){if(!e||!w(e))return!1;const r=[];if(l(t))for(const o of t)r.push({node:o,depth:0});else r.push({node:t,depth:0});for(;r.length>0;){const{node:o,depth:c}=r.shift();if(e(o,c)===!1)return!0;const s=o[n];if(s&&l(s))for(const a of s)r.push({node:a,depth:c+1})}return!1}function B(t,e,n="children"){if(!e||!w(e))return null;let r=null;const o=c=>{if(e(c))return r=c,!0;const u=c[n];if(u&&l(u)){for(const s of u)if(o(s))return!0}return!1};if(l(t)){for(const c of t)if(o(c))break}else o(t);return r}function F(t,e,n="key",r="children"){return B(t,o=>o[n]===e,r)}function qt(t,e,n="children"){if(!e||!w(e))return[];const r=o=>{const c=o[n],u=[];if(c&&l(c))for(const s of c){const a=r(s);a&&u.push(a)}return e(o)||u.length>0?{...o,[n]:u}:null};if(l(t)){const o=[];for(const c of t){const u=r(c);u&&o.push(u)}return o}else{const o=r(t);return o?[o]:[]}}function Yt(t,e,n="children"){if(!e||!w(e))return[];const r=o=>{const c=e(o),u=o[n];return u&&l(u)&&(c[n]=u.map(s=>r(s))),c};return l(t)?t.map(o=>r(o)):[r(t)]}function Jt(t,e="key",n="path",r="children"){const o=(c,u="")=>{const s=c[e],a=u?`${u}.${s}`:String(s),f={...c,[n]:a},_=c[r];return _&&l(_)&&(f[r]=_.map(d=>o(d,a))),f};return l(t)?t.map(c=>o(c)):[o(t)]}function Vt(t,e="children"){const n=[],r=o=>{const c=o[e];if(c&&l(c))for(const u of c)n.push(u),r(u)};return r(t),n}function Kt(t,e="parent"){const n=[];let r=t[e];for(;r;)n.unshift(r),r=r[e];return n}function Qt(t,e="children"){const n=r=>{const o=r[e];if(!o||!l(o)||o.length===0)return 1;const c=o.map(u=>n(u));return Math.max(...c)+1};if(l(t)){if(t.length===0)return 0;const r=t.map(o=>n(o));return Math.max(...r)}else return n(t)}function Gt(t,e="children"){const n=[],r=o=>{n.push(o);const c=o[e];if(c&&l(c))for(const u of c)r(u)};if(l(t))for(const o of t)r(o);else r(t);return n}function Xt(t,e,n,r="key",o="children"){const c=l(t)?t:[t],u=F(c,e,r,o);return u?(u[o]||(u[o]=[]),u[o].push(n)):c.push(n),c}function Zt(t,e,n="key",r="children"){const o=l(t)?t:[t];let c=null,u=null;const s=(a,f=null)=>{for(let _=0;_<a.length;_++){const d=a[_];if(d[n]===e)return c=d,u=f?f[r]:a,!0;const M=d[r];if(M&&l(M)&&s(M,d))return!0}return!1};if(s(o),c&&u){const a=u.findIndex(f=>f[n]===e);a>-1&&u.splice(a,1)}return o}function xt(t,e,n,r="key",o="children"){const c=l(t)?t:[t],u=F(c,e,r,o);return u&&Object.assign(u,n),c}function te(t,e,n=!0,r="children"){const o=l(t)?t:[t],c=typeof e=="string"?(s,a)=>{const f=s[e],_=a[e];return f<_?-1:f>_?1:0}:e,u=s=>{if(s.sort(c),n)for(const a of s){const f=a[r];f&&l(f)&&f.length>0&&u(f)}};return u(o),o}function ee(t,e="children"){const n=r=>{const o={...r},c=r[e];return c&&l(c)&&(o[e]=c.map(u=>n(u))),o};return l(t)?t.map(r=>n(r)):[n(t)]}function ne(t,e="key",n="children"){const r=[],o=new Set,c=new Set,u=(s,a="")=>{if(!h(s)){r.push(`Invalid node at ${a}: node must be an object`);return}if(o.has(s)){r.push(`Circular reference detected at ${a}`);return}o.add(s),e in s&&s[e]!==void 0&&(c.has(s[e])?r.push(`Duplicate key "${s[e]}" found at ${a}`):c.add(s[e]));const f=s[n];f!==void 0&&(l(f)?f.forEach((_,d)=>{u(_,`${a}[${d}]`)}):r.push(`Invalid children at ${a}: children must be an array`)),o.delete(s)};return l(t)?t.forEach((s,a)=>{u(s,`[${a}]`)}):u(t,"root"),{valid:r.length===0,errors:r}}function re(t,e,n="children"){const r=[],o=w(e)?e:u=>{if(!e||typeof e!="object")return!1;for(const[s,a]of Object.entries(e))if(u[s]!==a)return!1;return!0},c=u=>{typeof o=="function"&&o(u)&&r.push(u);const s=u[n];if(s&&l(s))for(const a of s)c(a)};if(l(t))for(const u of t)c(u);else c(t);return r}function q(t){if(!t&&t!==0)return"0";const e=k(t);return isNaN(e)?`${t}`:`${e}`.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,"$1,")}function k(t){if(m(t))return t;if(L(t)){const e=parseFloat(t);return isNaN(e)?Number.NaN:e}return Number.NaN}function Y(t,e){const n=k(t);return isNaN(n)?Number.NaN:Number(n.toFixed(e))}function oe(t,e="¥",n=2){if(!m(t))return e+"0.00";let r;n===0?r=Math.floor(t).toString():r=t.toFixed(n);const o=q(r);return e+o}function ie(t,e,n){return m(t)?Math.max(e,Math.min(n,t)):Number.NaN}function ce(t,e=2){const n=k(t);return isNaN(n)?"0%":(n*100).toFixed(e)+"%"}function ue(t){return m(t)?t%2===0:!1}function se(t){return m(t)?Math.trunc(t):Number.NaN}function ae(t){return m(t)?t-Math.trunc(t):Number.NaN}function fe(t,e=0){if(!m(t))return Number.NaN;const n=Math.pow(10,e);return Math.round(t*n)/n}function le(t,e=0){if(!m(t))return Number.NaN;const n=Math.pow(10,e);return Math.ceil(t*n)/n}function _e(t,e=0){if(!m(t))return Number.NaN;const n=Math.pow(10,e);return Math.floor(t*n)/n}function de(t,e,n=2){if(!m(t)||!m(e)||e===0)return Number.NaN;const r=t/e*100;return Y(r,n)}function y(t="local"){return t==="local"?localStorage:sessionStorage}function O(t,e=null){try{return JSON.parse(t)}catch(n){return console.error("JSON解析错误:",n),e}}function he(){const t=localStorage.getItem("token");if(!t)return null;const e=O(t);return e!==null?e.expiry!=null&&e.expiry<Date.now()?(localStorage.removeItem("token"),null):e.value:null}function ge(t,e=10080*60){const n=Date.now()+e*1e3,r={value:t,expiry:n};localStorage.setItem("token",JSON.stringify(r))}function me(){localStorage.removeItem("token")}function J(t,e,n="local"){const r=y(n);e!==void 0&&r.setItem(t,JSON.stringify(e))}function V(t,e="local"){const r=y(e).getItem(t);return r?O(r):null}function K(t,e="local"){y(e).removeItem(t)}function ye(t="local"){y(t).clear()}function be(t,e,n,r="local"){const o=y(r),c={value:e,expiry:Date.now()+n*1e3};o.setItem(t,JSON.stringify(c))}function we(t,e="local"){const n=y(e),r=n.getItem(t);if(!r)return null;const o=O(r);return o.expiry&&o.expiry<Date.now()?(n.removeItem(t),null):o.value}function pe(t,e="local"){return y(e).getItem(t)!==null}function Q(t="local"){const e=y(t),n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o&&n.push(o)}return n}function ve(t="local"){const e=y(t),n=Q(t);let r=0;return n.forEach(o=>{const c=e.getItem(o);if(c){const u=O(c);u.expiry&&u.expiry<Date.now()&&(e.removeItem(o),r++)}}),r}function Me(t){try{return btoa(unescape(encodeURIComponent(t)))}catch(e){return console.error("加密错误:",e),t}}function Ne(t){try{return decodeURIComponent(escape(atob(t)))}catch(e){return console.error("解密错误:",e),t}}function $e(t,e,n="local"){const r=y(n),o=JSON.stringify(e),c=Me(o);r.setItem(t,c)}function Ee(t,e="local"){const r=y(e).getItem(t);if(!r)return null;try{const o=Ne(r);return JSON.parse(o)}catch(o){return console.error("解密解析错误:",o),null}}function ke(t,e="local"){t.forEach(n=>{J(n.key,n.value,e)})}function Oe(t,e="local"){const n={};return t.forEach(r=>{n[r]=V(r,e)}),n}function Se(t,e="local"){t.forEach(n=>{K(n,e)})}function S(t){const e=Object.prototype.toString;if(!t||typeof t!="object")return t;if(t.nodeType&&"cloneNode"in t)return t.cloneNode(!0);if(e.call(t)==="[object Date]")return new Date(t.getTime());if(e.call(t)==="[object RegExp]"){const r=[];return t.global&&r.push("g"),t.multiline&&r.push("m"),t.ignoreCase&&r.push("i"),new RegExp(t.source,r.join(""))}if(e.call(t)==="[object FormData]"){const r=new FormData;for(const[o,c]of t.entries())r.append(o,c);return r}if(e.call(t)==="[object Map]"){const r=new Map;for(const[o,c]of t.entries())r.set(o,S(c));return r}if(e.call(t)==="[object Set]"){const r=new Set;for(const o of t.values())r.add(S(o));return r}const n=Array.isArray(t)?[]:t.constructor?new t.constructor:{};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=S(t[r]));return n}function G(...t){let e=t.length,n=t[0];h(n)||(n={});for(let r=1;r<e;r++){let o=t[r];if(h(o))for(let c in o)c==="__proto__"||n===o[c]||(h(o[c])?(h(n[c])||(n[c]=Array.isArray(o[c])?[]:{}),n[c]=G(n[c],o[c])):n[c]=o[c])}return n}function z(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let n,r,o;if(Array.isArray(t)){if(n=t.length,n!=e.length)return!1;for(r=n;r--!==0;)if(!z(t[r],e[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const c=o[r];if(!z(t[c],e[c]))return!1}return!0}return t!==t&&e!==e}function ze(t){return h(t)&&Object.keys(t).length===0}function Ae(t,e){if(!h(t))return{};const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function Ie(t,e){if(!h(t))return{};const n={};return Object.keys(t).forEach(r=>{e.includes(r)||(n[r]=t[r])}),n}function X(t,e=""){if(!h(t))return{};const n={};return Object.keys(t).forEach(r=>{const o=e?`${e}.${r}`:r;h(t[r])&&!Array.isArray(t[r])?Object.assign(n,X(t[r],o)):n[o]=t[r]}),n}function De(t){if(!h(t))return{};const e={};return Object.keys(t).forEach(n=>{const r=n.split(".");let o=e;r.forEach((c,u)=>{u===r.length-1?o[c]=t[n]:(o[c]||(o[c]={}),o=o[c])})}),e}function Le(t,e,n=void 0){if(!h(t))return n;const r=e.split(".");let o=t;for(const c of r){if(o==null)return n;o=o[c]}return o!==void 0?o:n}function Fe(t,e,n){h(t)||(t={});const r=e.split(".");let o=t;return r.forEach((c,u)=>{u===r.length-1?o[c]=n:(h(o[c])||(o[c]={}),o=o[c])}),t}function Te(...t){return Object.assign({},...t)}function Ce(t,e){const n={};return!h(t)&&!h(e)?n:h(t)?h(e)?(new Set([...Object.keys(t),...Object.keys(e)]).forEach(o=>{z(t[o],e[o])||(n[o]={oldValue:t[o],newValue:e[o]})}),n):t:e}function Z(t,e){return!t||t.tagName==="BODY"?null:t.classList.contains(e)?t:Z(t.parentElement,e)}function Re(t,e=!0){const n=document.getElementById(t);n&&n.scrollTo({top:n.scrollHeight,behavior:e?"smooth":void 0})}function He(t,e=document){return e.querySelector(t)}function Pe(t,e=document){return Array.from(e.querySelectorAll(t))}function je(t,e){t&&!t.classList.contains(e)&&t.classList.add(e)}function We(t,e){t&&t.classList.contains(e)&&t.classList.remove(e)}function Ue(t,e){return t?t.classList.toggle(e):!1}function Be(t,e){return t?t.classList.contains(e):!1}function qe(t,e){return t?window.getComputedStyle(t).getPropertyValue(e):""}function Ye(t,e,n){t&&"style"in t&&(t.style[e]=n)}function x(t,e){t&&"style"in t&&Object.entries(e).forEach(([n,r])=>{t.style[n]=r})}function Je(t,e){return t&&t.getAttribute(e)||""}function tt(t,e,n){t&&t.setAttribute(e,n)}function Ve(t,e){t&&t.removeAttribute(e)}function Ke(t,e,n,r){t&&t.addEventListener(e,n,r)}function Qe(t,e,n,r){t&&t.removeEventListener(e,n,r)}function Ge(t,e){const n=document.createElement(t);return e&&(e.class_name&&(n.className=e.class_name),e.style&&x(n,e.style),e.attributes&&Object.entries(e.attributes).forEach(([r,o])=>{tt(n,r,o)}),e.text&&(n.textContent=e.text)),n}function $(t){return t?t.getBoundingClientRect():null}function et(t){if(!t)return null;const e=$(t);return e?{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}:null}function Xe(t){if(!t)return null;const e=$(t);return e?{width:e.width,height:e.height}:null}function Ze(t,e){if(!t)return;const{behavior:n="smooth",offsetTop:r=0,offsetLeft:o=0}=e||{},c=et(t);c&&window.scrollTo({top:c.top-r,left:c.left-o,behavior:n})}function xe(t){if(!t)return!1;const e=$(t);return e?e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth):!1}function tn(t){if(!t)return!1;const e=$(t);return e?e.top>0&&e.left>0&&e.bottom<(window.innerHeight||document.documentElement.clientHeight)&&e.right<(window.innerWidth||document.documentElement.clientWidth):!1}function en(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function nn(){return{width:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.documentElement.clientWidth),height:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.documentElement.clientHeight)}}function T({path:t,name:e}){const n=document.createElement("a");n.href=t,n.target="_blank",e&&n.setAttribute("download",e),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function rn(t){t.forEach(e=>{T({path:e.url,name:e.name})})}async function on(t){if(!t)return;const e=new FileReader;return e.readAsDataURL(t),new Promise((n,r)=>{e.onload=o=>n(o.target?.result),e.onerror=o=>r(void 0)})}async function cn(t,e="UTF-8"){if(!t)return;const n=new FileReader;return n.readAsText(t,e),new Promise((r,o)=>{n.onload=c=>r(c.target?.result),n.onerror=()=>o(void 0)})}function A(t){if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.substring(e+1).toLowerCase()}function C(t){if(!t)return"";const e=t.lastIndexOf(".");return e===-1?t:t.substring(0,e)}function un(t,e){return t.size<=e}function sn(t,e){const n=A(t.name);return e.includes(n)}function an(t,e,n){return new File([t],e,{type:n})}function fn(t,e,n="text/plain"){const r=new Blob([t],{type:n}),o=URL.createObjectURL(r);T({path:o,name:e}),URL.revokeObjectURL(o)}async function ln(t,e=800,n=800,r=.8){if(t.type.startsWith("image/"))return new Promise(o=>{const c=document.createElement("canvas"),u=c.getContext("2d"),s=new Image;s.onload=()=>{let{width:a,height:f}=s;if(a>e||f>n){const _=Math.min(e/a,n/f);a*=_,f*=_}c.width=a,c.height=f,u?.drawImage(s,0,0,a,f),c.toBlob(_=>{if(_){const d=new File([_],t.name,{type:t.type});o(d)}else o(void 0)},t.type,r)},s.src=URL.createObjectURL(t)})}function _n(t){const e=A(t.name),n=C(t.name);let r="";return t.size<1024?r=`${t.size} B`:t.size<1024*1024?r=`${(t.size/1024).toFixed(2)} KB`:t.size<1024*1024*1024?r=`${(t.size/(1024*1024)).toFixed(2)} MB`:r=`${(t.size/(1024*1024*1024)).toFixed(2)} GB`,{name:t.name,size:t.size,size_text:r,type:t.type,extension:e,name_without_extension:n}}function dn(t){const e=A(t),n=C(t),r=Date.now(),o=Math.random().toString(36).substring(2,8);return e?`${n}_${r}_${o}.${e}`:`${n}_${r}_${o}`}function nt(t){return/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.test(t)}function hn(t,e,n){if(!nt(t)||!nt(e))return t;n=Math.max(Math.min(Number(n),1),0);const r=p(t),o=p(e);if(!r||!o)return t;const c=Math.round(r.r*(1-n)+o.r*n),u=Math.round(r.g*(1-n)+o.g*n),s=Math.round(r.b*(1-n)+o.b*n);return E(c,u,s)}function gn(t){const e=p(t);return e?`${e.r},${e.g},${e.b}`:"0,0,0"}function p(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function E(t,e,n){return t=Math.max(0,Math.min(255,Math.round(t))),e=Math.max(0,Math.min(255,Math.round(e))),n=Math.max(0,Math.min(255,Math.round(n))),`#${((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)}`}function mn(t,e,n,r){return E(t,e,n)}function yn(t,e){const n=p(t);if(!n)return t;e=Math.max(0,Math.min(1,e));const r=Math.min(255,Math.round(n.r+(255-n.r)*e)),o=Math.min(255,Math.round(n.g+(255-n.g)*e)),c=Math.min(255,Math.round(n.b+(255-n.b)*e));return E(r,o,c)}function bn(t,e){const n=p(t);if(!n)return t;e=Math.max(0,Math.min(1,e));const r=Math.max(0,Math.round(n.r*(1-e))),o=Math.max(0,Math.round(n.g*(1-e))),c=Math.max(0,Math.round(n.b*(1-e)));return E(r,o,c)}function R(t){const e=p(t);return e?(e.r*299+e.g*587+e.b*114)/1e3>128:!1}function wn(t){return!R(t)}function pn(t){return R(t)?"#000000":"#FFFFFF"}function vn(t,e="YYYY-MM-DD HH:mm:ss"){return g(t).format(e)}function Mn(t,e=-1,n="YYYY-MM-DD HH:mm:ss",r=!1){const o=g(),c=o.format(n);let u=o;switch(t){case"d":u=r?o.add(e,"day"):o.startOf("day");break;case"w":u=r?o.add(e,"week"):o.startOf("week");break;case"M":u=r?o.add(e,"month"):o.startOf("month");break;case"Q":u=r?o.add(e*3,"month"):o.startOf("month").subtract(o.month()%3,"month");break;case"y":u=r?o.add(e,"year"):o.startOf("year");break;case"h":u=o.add(e,"hour");break;case"m":u=o.add(e,"minute");break;case"s":u=o.add(e,"second");break}return[u.format(n),c]}function Nn(t,e,n="day"){return g(t).diff(g(e),n)}function $n(t,e,n,r){const o=g(t).add(e,n);return r?o.format(r):o.toDate()}function En(t,e,n,r){const o=g(t).subtract(e,n);return r?o.format(r):o.toDate()}function kn(t){const e=g(t).day();return e>0&&e<6}function On(t){const e=g(t).day();return e===0||e===6}function Sn(t){const e=g(),n=g(t),r=e.diff(n,"minute");if(r<1)return"刚刚";if(r<60)return`${r}分钟前`;const o=e.diff(n,"hour");if(o<24)return`${o}小时前`;const c=e.diff(n,"day");if(c<30)return`${c}天前`;const u=e.diff(n,"month");return u<12?`${u}个月前`:`${e.diff(n,"year")}年前`}function zn(t,e="zh"){const n=Math.floor(t/1e3),r=Math.floor(n/86400),o=Math.floor(n%86400/3600),c=Math.floor(n%3600/60),u=n%60,s=e==="zh"?{day:"天",hour:"时",minute:"分",second:"秒"}:{day:"D",hour:"H",minute:"M",second:"S"};let a="";return r>0&&(a+=`${r}${s.day}`),(o>0||r>0&&(c>0||u>0))&&(a+=`${o}${s.hour}`),(c>0||o>0&&u>0)&&(a+=`${c}${s.minute}`),(u>0||a==="")&&(a+=`${u}${s.second}`),a}function An(t,e=200,n=!1){let r;return function(...o){const c=this;if(r&&clearTimeout(r),n){const u=!r;if(r=setTimeout(()=>{r=void 0},e),u)return t.apply(c,o)}else r=setTimeout(()=>{t.apply(c,o)},e)}}function In(t,e=200,n={}){const{leading:r=!0,trailing:o=!0}=n;let c=0,u,s,a;return function(...f){const _=this,d=Date.now();if(c===0){r&&t.apply(_,f),c=d;return}s=f,a=_;const M=d-c;if(M>=e){u&&(clearTimeout(u),u=void 0),t.apply(_,f),c=d;return}!u&&o&&(u=setTimeout(()=>{s&&(t.apply(a,s),c=Date.now()),u=void 0,s=void 0,a=void 0},e-M))}}function Dn(t){const e=t.length;function n(...r){return r.length>=e?t.apply(this,r):function(...o){return n.apply(this,[...r,...o])}}return n}function Ln(...t){return function(e){return t.reduceRight((n,r)=>r(n),e)}}function Fn(...t){return function(e){return t.reduce((n,r)=>r(n),e)}}function Tn(t,e=1e3){return new Promise(n=>{setTimeout(()=>{n(t())},e)})}async function rt(t,e=3,n=1e3){try{return await t()}catch(r){if(e<=0)throw r;return await new Promise(o=>setTimeout(o,n)),rt(t,e-1,n)}}function Cn(t){let e=!1,n;return function(...r){return e||(e=!0,n=t.apply(this,r)),n}}function Rn(t){const e=new Map;return function(...n){const r=JSON.stringify(n);if(e.has(r))return e.get(r);const o=t.apply(this,n);return e.set(r,o),o}}async function Hn(t,e=!0){if(e)return Promise.all(t.map(n=>n()));{const n=[];for(const r of t)n.push(await r());return n}}function Pn(t,e=5e3,n="Operation timed out"){return Promise.race([Promise.resolve(t()),new Promise((r,o)=>{setTimeout(()=>{o(new Error(n))},e)})])}function jn(t,e=1920){let n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;if(!n)return t;let r=n/e;return Number((t*r).toFixed(3))}function Wn(t,e,n){return{type:"linear",x:0,y:0,x2:t==="v"?0:1,y2:t==="v"?1:0,colorStops:[{offset:0,color:e},{offset:1,color:n}]}}function Un(t,e,n="canvas",r){return(async()=>{try{let c;if(typeof window<"u"&&window.echarts)c=window.echarts;else{const a=await import("echarts");c=a.default||a}const u=typeof t=="string"?document.getElementById(t):t;if(!u)return console.error("ECharts DOM容器未找到"),null;const s=c.init(u,r,{renderer:n});return e&&s.setOption(e),s}catch(c){return console.error("加载 ECharts 失败:",c),null}})()}function ot(t){t&&typeof t.dispose=="function"&&t.dispose()}function Bn(t,e){t&&typeof t.setOption=="function"&&t.setOption(e)}function H(t){t&&typeof t.resize=="function"&&t.resize()}function qn(t,e=200){if(!t)return;let n;const r=()=>{clearTimeout(n),n=setTimeout(()=>{H(t)},e)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),clearTimeout(n)}}function Yn(t,e){const r=e||["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc","#67c23a"],o=[];for(let c=0;c<t;c++)o.push(r[c%r.length]);return o}function Jn(t,e){return typeof e=="function"?e(t):typeof e=="string"?e.replace("{value}",String(t)):String(t)}function Vn(t,e){return{...t,...e,series:e.series||t.series,xAxis:e.xAxis||t.xAxis,yAxis:e.yAxis||t.yAxis,legend:e.legend||t.legend,tooltip:e.tooltip||t.tooltip,title:e.title||t.title}}function Kn(t,e,n){t&&typeof t.on=="function"&&t.on(e,n)}function Qn(t,e,n){t&&typeof t.off=="function"&&t.off(e,n)}function Gn(t,e={}){if(!t||typeof t.getDataURL!="function")return null;const{type:n="png",pixel_ratio:r=2,background_color:o="#fff",exclude_components:c=[],file_name:u="echarts-image"}=e,s=t.getDataURL({type:n,pixelRatio:r,backgroundColor:o,excludeComponents:c}),a=document.createElement("a");return a.download=`${u}.${n}`,a.href=s,a.click(),s}function Xn(){return typeof window<"u"&&typeof window.echarts<"u"}function Zn(t){t.forEach(e=>{H(e)})}function xn(t){t.forEach(e=>{ot(e)})}function tr(t,e,n="asc"){return[...t].sort((r,o)=>{const c=r[e],u=o[e];return c<u?n==="asc"?-1:1:c>u?n==="asc"?1:-1:0})}function it(t,e){return t.reduce((n,r)=>{const o=r[e];return n[o]||(n[o]=[]),n[o].push(r),n},{})}function er(t,e,n,r=o=>o.reduce((c,u)=>c+u,0)){const o=it(t,e);return Object.entries(o).map(([c,u])=>{const s=u.map(a=>a[n]).filter(a=>typeof a=="number");return{[e]:c,[n]:r(s)}})}const b=new Map;let I=null;U&&(document.addEventListener("mousedown",t=>{I=t}),document.addEventListener("mouseup",t=>{for(const e of b.values())for(const{document_handler:n}of e)I&&n(t,I);I=null}));function ct(t,e){const n=[];return Array.isArray(e.arg)?n.push(...e.arg.filter(D)):D(e.arg)&&n.push(e.arg),function(r,o){const c=r.target,u=o.target;if(!c||!u||!e.instance)return;const s=t.contains(c)||t.contains(u),a=t===c,f=n.some(d=>d&&(d.contains(c)||d===u));let _=!1;try{const d=e.instance.popperRef;d&&(_=d.contains(c)||d.contains(u))}catch{}s||a||f||_||typeof e.value=="function"&&e.value(r,o)}}const ut={beforeMount(t,e){b.has(t)||b.set(t,[]),b.get(t)?.push({document_handler:ct(t,e),binding_fn:e.value})},updated(t,e){b.has(t)||b.set(t,[]);const n=b.get(t);if(!n)return;const r=n.findIndex(c=>c.binding_fn===e.oldValue),o={document_handler:ct(t,e),binding_fn:e.value};r>=0?n.splice(r,1,o):n.push(o)},unmounted(t){b.delete(t)}};function nr(t){t.directive("click-outside",ut)}i.ClickOutside=ut,i.add_chart_listener=Kn,i.add_class=je,i.add_date=$n,i.add_tree_node=Xt,i.add_tree_node_path=Jt,i.aggregate_chart_data=er,i.auto_size=jn,i.batch_execution=Hn,i.build_tree=Wt,i.calculate_percentage=de,i.ceil=le,i.clamp=ie,i.clear_expired_storage=ve,i.clear_storage=ye,i.clone_tree=ee,i.compose=Ln,i.compress_image=ln,i.create_element=Ge,i.create_file_from_blob=an,i.curry=Dn,i.darken=bn,i.debounce=An,i.decrypt_storage=Ee,i.deep_assign=G,i.deep_clone=S,i.deep_equal=z,i.delay_execution=Tn,i.destroy_chart=ot,i.destroy_charts=xn,i.diff_objects=Ce,i.download_file=T,i.download_files=rn,i.download_text_file=fn,i.encrypt_storage=$e,i.export_chart_image=Gn,i.filter_tree=qt,i.find_tree_node=B,i.find_tree_node_by_key=F,i.flatten_object=X,i.flatten_tree_to_array=Gt,i.floor=_e,i.format_chart_label=Jn,i.format_currency=oe,i.format_date=vn,i.format_timestamp_diff=zn,i.generate_chart_colors=Yn,i.generate_guid=_t,i.generate_id=st,i.generate_random_color=gt,i.generate_random_email=bt,i.generate_random_number_string=j,i.generate_random_password=mt,i.generate_random_phone=yt,i.generate_random_string=N,i.generate_random_url=wt,i.generate_string=P,i.generate_unique_file_name=dn,i.get_all_storage_keys=Q,i.get_attribute=Je,i.get_batch_storage=Oe,i.get_chart_gradient_color=Wn,i.get_contrast_color=pn,i.get_date_diff=Nn,i.get_date_time_range=Mn,i.get_decimal_part=ae,i.get_document_size=nn,i.get_element=He,i.get_element_position=et,i.get_element_rect=$,i.get_element_size=Xe,i.get_elements=Pe,i.get_file_extension=A,i.get_file_info=_n,i.get_file_name_without_extension=C,i.get_integer_part=se,i.get_object_value=Le,i.get_parent_by_class=Z,i.get_random_boolean=dt,i.get_random_element=v,i.get_random_elements=ht,i.get_random_float=lt,i.get_random_int=at,i.get_random_int_range=ft,i.get_relative_time=Sn,i.get_rgb=gn,i.get_storage=V,i.get_storage_with_expiry=we,i.get_style=qe,i.get_token=he,i.get_tree_depth=Qt,i.get_tree_node_ancestors=Kt,i.get_tree_node_descendants=Vt,i.get_window_size=en,i.group_chart_data=it,i.has_class=Be,i.has_storage=pe,i.hex_to_rgb=p,i.init_chart=Un,i.is_array=l,i.is_boolean=Et,i.is_client=U,i.is_completely_in_viewport=tn,i.is_dark=wn,i.is_date=W,i.is_echarts_loaded=Xn,i.is_element=D,i.is_email=Tt,i.is_empty=zt,i.is_empty_object=ze,i.is_even=ue,i.is_falsy=It,i.is_function=w,i.is_hex_color=Rt,i.is_html_element=Dt,i.is_in_viewport=xe,i.is_ip=Ht,i.is_light=R,i.is_mobile=Ft,i.is_null=Mt,i.is_number=m,i.is_object=h,i.is_plain_object=Nt,i.is_port=Pt,i.is_promise=St,i.is_reg_exp=kt,i.is_string=L,i.is_string_number=Lt,i.is_symbol=Ot,i.is_truthy=At,i.is_undefined=vt,i.is_url=Ct,i.is_valid_date=$t,i.is_weekday=kn,i.is_weekend=On,i.lighten=yn,i.make_chart_responsive=qn,i.memoize=Rn,i.merge_chart_options=Vn,i.merge_objects=Te,i.mix=hn,i.off=Qe,i.omit=Ie,i.on=Ke,i.once=Cn,i.pick=Ae,i.pipe=Fn,i.read_file=cn,i.remove_attribute=Ve,i.remove_batch_storage=Se,i.remove_chart_listener=Qn,i.remove_class=We,i.remove_storage=K,i.remove_token=me,i.remove_tree_node=Zt,i.resize_chart=H,i.resize_charts=Zn,i.retry=rt,i.rgb_to_hex=E,i.rgba_to_hex=mn,i.round=fe,i.scroll_footer=Re,i.scroll_to_element=Ze,i.search_tree=re,i.set_attribute=tt,i.set_batch_storage=ke,i.set_object_value=Fe,i.set_storage=J,i.set_storage_with_expiry=be,i.set_style=Ye,i.set_styles=x,i.set_token=ge,i.setupDirectives=nr,i.shuffle_array=pt,i.sort_chart_data=tr,i.sort_tree=te,i.subtract_date=En,i.thousand_separator=q,i.throttle=In,i.timeout=Pn,i.to_base64=on,i.to_fixed=Y,i.to_number=k,i.to_percentage=ce,i.toggle_class=Ue,i.transform_tree=Yt,i.traverse_tree_breadth_first=Bt,i.traverse_tree_depth_first=Ut,i.tree_flat=jt,i.unflatten_object=De,i.update_chart=Bn,i.update_tree_node=xt,i.validate_file_size=un,i.validate_file_type=sn,i.validate_tree=ne,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("dayjs")):typeof define=="function"&&define.amd?define(["exports","dayjs"],m):(i=typeof globalThis<"u"?globalThis:i||self,m(i.QyBetterLibCore={},i.dayjs))})(this,(function(i,m){"use strict";function st(){return Math.floor(Math.random()*1e4)}function at(t){return t<0?0:Math.floor(Math.random()*Math.floor(t))}function ft(t,e){return t>e&&([t,e]=[e,t]),Math.floor(Math.random()*(e-t+1))+t}function lt(t,e,n=2){t>e&&([t,e]=[e,t]);const r=Math.random()*(e-t)+t;return parseFloat(r.toFixed(n))}function _t(){const t=P;return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function P(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function N(t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){let n="";const r=e.length;for(let o=0;o<t;o++)n+=e.charAt(Math.floor(Math.random()*r));return n}function dt(){return Math.random()>.5}function v(t){if(!(!t||t.length===0))return t[Math.floor(Math.random()*t.length)]}function ht(t,e){return!t||t.length===0||e<=0?[]:e>=t.length?[...t]:[...t].sort(()=>.5-Math.random()).slice(0,e)}function mt(){const t="0123456789ABCDEF";let e="#";for(let n=0;n<6;n++)e+=t[Math.floor(Math.random()*16)];return e}function j(t){return N(t,"0123456789")}function gt(t=8){return N(t,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=")}function yt(){const e=v(["130","131","132","133","134","135","136","137","138","139","150","151","152","153","155","156","157","158","159","170","171","172","173","175","176","177","178","180","181","182","183","184","185","186","187","188","189"]),n=j(8);return`${e}${n}`}function bt(){const t=["gmail.com","yahoo.com","hotmail.com","outlook.com","163.com","126.com","qq.com","sina.com"],e=N(8),n=v(t);return`${e}@${n}`}function wt(){const t=["http","https"],e=["example.com","test.com","demo.com","sample.com"],n=["api","docs","about","contact","products"],r=v(t),o=v(e),c=v(n),u=N(4);return`${r}://www.${o}/${c}?id=${u}`}function pt(t){if(!t)return[];const e=[...t];for(let n=e.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1));[e[n],e[r]]=[e[r],e[n]]}return e}function vt(t){return t===void 0}function Mt(t){return t===null}function l(t){return Array.isArray(t)}function h(t){return typeof t=="object"&&t!==null&&Object.prototype.toString.call(t)==="[object Object]"}function Nt(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function W(t){return Object.prototype.toString.call(t)==="[object Date]"}function $t(t){return W(t)&&!isNaN(t.getTime())}function Et(t){return typeof t=="boolean"}function w(t){return typeof t=="function"}function kt(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ot(t){return typeof t=="symbol"}function St(t){return typeof t=="object"&&t!==null&&typeof t.then=="function"&&typeof t.catch=="function"}function zt(t){return!t&&t!==0||l(t)&&t.length===0||h(t)&&!Object.keys(t).length}function At(t){return!!t}function It(t){return!t}function D(t){return typeof Element>"u"?!1:t instanceof Element}function Dt(t){return typeof HTMLElement>"u"?!1:t instanceof HTMLElement}const U=typeof window<"u";function g(t){return typeof t=="number"&&!isNaN(t)}function L(t){return typeof t=="string"}function Lt(t){return L(t)?!Number.isNaN(Number(t)):!1}function Ft(t){return/^1[3-9]\d{9}$/.test(t)}function Tt(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Ct(t){try{return new URL(t),!0}catch{return!1}}function Rt(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}function Ht(t){return/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t)}function Pt(t){return/^(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)$/.test(t)}function jt(t,e="key",n="children"){const r={};if(!l(t))return r;const o=[{nodes:t}];for(;o.length>0;){const{nodes:c,parent_key:u}=o.pop();for(const s of c){const a=s[e];if(a&&!r[a]){r[a]=s,u&&r[u]&&(r[a].parent=r[u]);const f=s[n];f&&l(f)&&f.length>0&&o.push({nodes:f,parent_key:a})}}}return r}function Wt(t,e="key",n="parentId",r="children"){if(!l(t))return[];const o={},c=[];for(const u of t)o[u[e]]={...u},o[u[e]][r]||(o[u[e]][r]=[]);for(const u of t){const s=u[n];!s||!o[s]?c.push(o[u[e]]):o[s][r].push(o[u[e]])}return c}function Ut(t,e,n="children"){if(!e||!w(e))return!1;let r=!1;const o=l(t)?t:[t],c=[];for(const u of o)c.push({node:u,depth:0});for(;c.length>0;){const{node:u,depth:s}=c.pop();if(e(u,s)===!1){r=!0;break}const f=u[n];if(f&&l(f)&&f.length>0)for(let _=f.length-1;_>=0;_--)c.push({node:f[_],depth:s+1})}return r}function Bt(t,e,n="children"){if(!e||!w(e))return!1;const r=[];if(l(t))for(const o of t)r.push({node:o,depth:0});else r.push({node:t,depth:0});for(;r.length>0;){const{node:o,depth:c}=r.shift();if(e(o,c)===!1)return!0;const s=o[n];if(s&&l(s))for(const a of s)r.push({node:a,depth:c+1})}return!1}function B(t,e,n="children"){if(!e||!w(e))return null;let r=null;const o=c=>{if(e(c))return r=c,!0;const u=c[n];if(u&&l(u)){for(const s of u)if(o(s))return!0}return!1};if(l(t)){for(const c of t)if(o(c))break}else o(t);return r}function F(t,e,n="key",r="children"){return B(t,o=>o[n]===e,r)}function qt(t,e,n="children"){if(!e||!w(e))return[];const r=o=>{const c=o[n],u=[];if(c&&l(c))for(const s of c){const a=r(s);a&&u.push(a)}return e(o)||u.length>0?{...o,[n]:u}:null};if(l(t)){const o=[];for(const c of t){const u=r(c);u&&o.push(u)}return o}else{const o=r(t);return o?[o]:[]}}function Yt(t,e,n="children"){if(!e||!w(e))return[];const r=o=>{const c=e(o),u=o[n];return u&&l(u)&&(c[n]=u.map(s=>r(s))),c};return l(t)?t.map(o=>r(o)):[r(t)]}function Jt(t,e="key",n="path",r="children"){const o=(c,u="")=>{const s=c[e],a=u?`${u}.${s}`:String(s),f={...c,[n]:a},_=c[r];return _&&l(_)&&(f[r]=_.map(d=>o(d,a))),f};return l(t)?t.map(c=>o(c)):[o(t)]}function Vt(t,e="children"){const n=[],r=o=>{const c=o[e];if(c&&l(c))for(const u of c)n.push(u),r(u)};return r(t),n}function Kt(t,e="parent"){const n=[];let r=t[e];for(;r;)n.unshift(r),r=r[e];return n}function Qt(t,e="children"){const n=r=>{const o=r[e];if(!o||!l(o)||o.length===0)return 1;const c=o.map(u=>n(u));return Math.max(...c)+1};if(l(t)){if(t.length===0)return 0;const r=t.map(o=>n(o));return Math.max(...r)}else return n(t)}function Gt(t,e="children"){const n=[],r=o=>{n.push(o);const c=o[e];if(c&&l(c))for(const u of c)r(u)};if(l(t))for(const o of t)r(o);else r(t);return n}function Xt(t,e,n,r="key",o="children"){const c=l(t)?t:[t],u=F(c,e,r,o);return u?(u[o]||(u[o]=[]),u[o].push(n)):c.push(n),c}function Zt(t,e,n="key",r="children"){const o=l(t)?t:[t];let c=null,u=null;const s=(a,f=null)=>{for(let _=0;_<a.length;_++){const d=a[_];if(d[n]===e)return c=d,u=f?f[r]:a,!0;const M=d[r];if(M&&l(M)&&s(M,d))return!0}return!1};if(s(o),c&&u){const a=u.findIndex(f=>f[n]===e);a>-1&&u.splice(a,1)}return o}function xt(t,e,n,r="key",o="children"){const c=l(t)?t:[t],u=F(c,e,r,o);return u&&Object.assign(u,n),c}function te(t,e,n=!0,r="children"){const o=l(t)?t:[t],c=typeof e=="string"?(s,a)=>{const f=s[e],_=a[e];return f<_?-1:f>_?1:0}:e,u=s=>{if(s.sort(c),n)for(const a of s){const f=a[r];f&&l(f)&&f.length>0&&u(f)}};return u(o),o}function ee(t,e="children"){const n=r=>{const o={...r},c=r[e];return c&&l(c)&&(o[e]=c.map(u=>n(u))),o};return l(t)?t.map(r=>n(r)):[n(t)]}function ne(t,e="key",n="children"){const r=[],o=new Set,c=new Set,u=(s,a="")=>{if(!h(s)){r.push(`Invalid node at ${a}: node must be an object`);return}if(o.has(s)){r.push(`Circular reference detected at ${a}`);return}o.add(s),e in s&&s[e]!==void 0&&(c.has(s[e])?r.push(`Duplicate key "${s[e]}" found at ${a}`):c.add(s[e]));const f=s[n];f!==void 0&&(l(f)?f.forEach((_,d)=>{u(_,`${a}[${d}]`)}):r.push(`Invalid children at ${a}: children must be an array`)),o.delete(s)};return l(t)?t.forEach((s,a)=>{u(s,`[${a}]`)}):u(t,"root"),{valid:r.length===0,errors:r}}function re(t,e,n="children"){const r=[],o=w(e)?e:u=>{if(!e||typeof e!="object")return!1;for(const[s,a]of Object.entries(e))if(u[s]!==a)return!1;return!0},c=u=>{typeof o=="function"&&o(u)&&r.push(u);const s=u[n];if(s&&l(s))for(const a of s)c(a)};if(l(t))for(const u of t)c(u);else c(t);return r}function q(t){if(!t&&t!==0)return"0";const e=k(t);return isNaN(e)?`${t}`:`${e}`.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,"$1,")}function k(t){if(g(t))return t;if(L(t)){const e=parseFloat(t);return isNaN(e)?Number.NaN:e}return Number.NaN}function Y(t,e){const n=k(t);return isNaN(n)?Number.NaN:Number(n.toFixed(e))}function oe(t,e="¥",n=2){if(!g(t))return e+"0.00";let r;n===0?r=Math.floor(t).toString():r=t.toFixed(n);const o=q(r);return e+o}function ie(t,e,n){return g(t)?Math.max(e,Math.min(n,t)):Number.NaN}function ce(t,e=2){const n=k(t);return isNaN(n)?"0%":(n*100).toFixed(e)+"%"}function ue(t){return g(t)?t%2===0:!1}function se(t){return g(t)?Math.trunc(t):Number.NaN}function ae(t){return g(t)?t-Math.trunc(t):Number.NaN}function fe(t,e=0){if(!g(t))return Number.NaN;const n=Math.pow(10,e);return Math.round(t*n)/n}function le(t,e=0){if(!g(t))return Number.NaN;const n=Math.pow(10,e);return Math.ceil(t*n)/n}function _e(t,e=0){if(!g(t))return Number.NaN;const n=Math.pow(10,e);return Math.floor(t*n)/n}function de(t,e,n=2){if(!g(t)||!g(e)||e===0)return Number.NaN;const r=t/e*100;return Y(r,n)}function y(t="local"){return t==="local"?localStorage:sessionStorage}function O(t,e=null){try{return JSON.parse(t)}catch(n){return console.error("JSON解析错误:",n),e}}function he(){const t=localStorage.getItem("token");if(!t)return null;const e=O(t);return e!==null?e.expiry!=null&&e.expiry<Date.now()?(localStorage.removeItem("token"),null):e.value:null}function me(t,e=10080*60){const n=Date.now()+e*1e3,r={value:t,expiry:n};localStorage.setItem("token",JSON.stringify(r))}function ge(){localStorage.removeItem("token")}function J(t,e,n="local"){const r=y(n);e!==void 0&&r.setItem(t,JSON.stringify(e))}function V(t,e="local"){const r=y(e).getItem(t);return r?O(r):null}function K(t,e="local"){y(e).removeItem(t)}function ye(t="local"){y(t).clear()}function be(t,e,n,r="local"){const o=y(r),c={value:e,expiry:Date.now()+n*1e3};o.setItem(t,JSON.stringify(c))}function we(t,e="local"){const n=y(e),r=n.getItem(t);if(!r)return null;const o=O(r);return o.expiry&&o.expiry<Date.now()?(n.removeItem(t),null):o.value}function pe(t,e="local"){return y(e).getItem(t)!==null}function Q(t="local"){const e=y(t),n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o&&n.push(o)}return n}function ve(t="local"){const e=y(t),n=Q(t);let r=0;return n.forEach(o=>{const c=e.getItem(o);if(c){const u=O(c);u.expiry&&u.expiry<Date.now()&&(e.removeItem(o),r++)}}),r}function Me(t){try{return btoa(unescape(encodeURIComponent(t)))}catch(e){return console.error("加密错误:",e),t}}function Ne(t){try{return decodeURIComponent(escape(atob(t)))}catch(e){return console.error("解密错误:",e),t}}function $e(t,e,n="local"){const r=y(n),o=JSON.stringify(e),c=Me(o);r.setItem(t,c)}function Ee(t,e="local"){const r=y(e).getItem(t);if(!r)return null;try{const o=Ne(r);return JSON.parse(o)}catch(o){return console.error("解密解析错误:",o),null}}function ke(t,e="local"){t.forEach(n=>{J(n.key,n.value,e)})}function Oe(t,e="local"){const n={};return t.forEach(r=>{n[r]=V(r,e)}),n}function Se(t,e="local"){t.forEach(n=>{K(n,e)})}function S(t){const e=Object.prototype.toString;if(!t||typeof t!="object")return t;if(t.nodeType&&"cloneNode"in t)return t.cloneNode(!0);if(e.call(t)==="[object Date]")return new Date(t.getTime());if(e.call(t)==="[object RegExp]"){const r=[];return t.global&&r.push("g"),t.multiline&&r.push("m"),t.ignoreCase&&r.push("i"),new RegExp(t.source,r.join(""))}if(e.call(t)==="[object FormData]"){const r=new FormData;for(const[o,c]of t.entries())r.append(o,c);return r}if(e.call(t)==="[object Map]"){const r=new Map;for(const[o,c]of t.entries())r.set(o,S(c));return r}if(e.call(t)==="[object Set]"){const r=new Set;for(const o of t.values())r.add(S(o));return r}const n=Array.isArray(t)?[]:t.constructor?new t.constructor:{};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=S(t[r]));return n}function G(...t){let e=t.length,n=t[0];h(n)||(n={});for(let r=1;r<e;r++){let o=t[r];if(h(o))for(let c in o)c==="__proto__"||n===o[c]||(h(o[c])?(h(n[c])||(n[c]=Array.isArray(o[c])?[]:{}),n[c]=G(n[c],o[c])):n[c]=o[c])}return n}function z(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let n,r,o;if(Array.isArray(t)){if(n=t.length,n!=e.length)return!1;for(r=n;r--!==0;)if(!z(t[r],e[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const c=o[r];if(!z(t[c],e[c]))return!1}return!0}return t!==t&&e!==e}function ze(t){return h(t)&&Object.keys(t).length===0}function Ae(t,e){if(!h(t))return{};const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function Ie(t,e){if(!h(t))return{};const n={};return Object.keys(t).forEach(r=>{e.includes(r)||(n[r]=t[r])}),n}function X(t,e=""){if(!h(t))return{};const n={};return Object.keys(t).forEach(r=>{const o=e?`${e}.${r}`:r;h(t[r])&&!Array.isArray(t[r])?Object.assign(n,X(t[r],o)):n[o]=t[r]}),n}function De(t){if(!h(t))return{};const e={};return Object.keys(t).forEach(n=>{const r=n.split(".");let o=e;r.forEach((c,u)=>{u===r.length-1?o[c]=t[n]:(o[c]||(o[c]={}),o=o[c])})}),e}function Le(t,e,n=void 0){if(!h(t))return n;const r=e.split(".");let o=t;for(const c of r){if(o==null)return n;o=o[c]}return o!==void 0?o:n}function Fe(t,e,n){h(t)||(t={});const r=e.split(".");let o=t;return r.forEach((c,u)=>{u===r.length-1?o[c]=n:(h(o[c])||(o[c]={}),o=o[c])}),t}function Te(...t){return Object.assign({},...t)}function Ce(t,e){const n={};return!h(t)&&!h(e)?n:h(t)?h(e)?(new Set([...Object.keys(t),...Object.keys(e)]).forEach(o=>{z(t[o],e[o])||(n[o]={oldValue:t[o],newValue:e[o]})}),n):t:e}function Z(t,e){return!t||t.tagName==="BODY"?null:t.classList.contains(e)?t:Z(t.parentElement,e)}function Re(t,e=!0){const n=document.getElementById(t);n&&n.scrollTo({top:n.scrollHeight,behavior:e?"smooth":void 0})}function He(t,e=document){return e.querySelector(t)}function Pe(t,e=document){return Array.from(e.querySelectorAll(t))}function je(t,e){t&&!t.classList.contains(e)&&t.classList.add(e)}function We(t,e){t&&t.classList.contains(e)&&t.classList.remove(e)}function Ue(t,e){return t?t.classList.toggle(e):!1}function Be(t,e){return t?t.classList.contains(e):!1}function qe(t,e){return t?window.getComputedStyle(t).getPropertyValue(e):""}function Ye(t,e,n){t&&"style"in t&&(t.style[e]=n)}function x(t,e){t&&"style"in t&&Object.entries(e).forEach(([n,r])=>{t.style[n]=r})}function Je(t,e){return t&&t.getAttribute(e)||""}function tt(t,e,n){t&&t.setAttribute(e,n)}function Ve(t,e){t&&t.removeAttribute(e)}function Ke(t,e,n,r){t&&t.addEventListener(e,n,r)}function Qe(t,e,n,r){t&&t.removeEventListener(e,n,r)}function Ge(t,e){const n=document.createElement(t);return e&&(e.class_name&&(n.className=e.class_name),e.style&&x(n,e.style),e.attributes&&Object.entries(e.attributes).forEach(([r,o])=>{tt(n,r,o)}),e.text&&(n.textContent=e.text)),n}function $(t){return t?t.getBoundingClientRect():null}function et(t){if(!t)return null;const e=$(t);return e?{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}:null}function Xe(t){if(!t)return null;const e=$(t);return e?{width:e.width,height:e.height}:null}function Ze(t,e){if(!t)return;const{behavior:n="smooth",offsetTop:r=0,offsetLeft:o=0}=e||{},c=et(t);c&&window.scrollTo({top:c.top-r,left:c.left-o,behavior:n})}function xe(t){if(!t)return!1;const e=$(t);return e?e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth):!1}function tn(t){if(!t)return!1;const e=$(t);return e?e.top>0&&e.left>0&&e.bottom<(window.innerHeight||document.documentElement.clientHeight)&&e.right<(window.innerWidth||document.documentElement.clientWidth):!1}function en(){return{width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}}function nn(){return{width:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.documentElement.clientWidth),height:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.documentElement.clientHeight)}}function T({path:t,name:e}){const n=document.createElement("a");n.href=t,n.target="_blank",e&&n.setAttribute("download",e),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function rn(t){t.forEach(e=>{T({path:e.url,name:e.name})})}async function on(t){if(!t)return;const e=new FileReader;return e.readAsDataURL(t),new Promise((n,r)=>{e.onload=o=>n(o.target?.result),e.onerror=o=>r(void 0)})}async function cn(t,e="UTF-8"){if(!t)return;const n=new FileReader;return n.readAsText(t,e),new Promise((r,o)=>{n.onload=c=>r(c.target?.result),n.onerror=()=>o(void 0)})}function A(t){if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.substring(e+1).toLowerCase()}function C(t){if(!t)return"";const e=t.lastIndexOf(".");return e===-1?t:t.substring(0,e)}function un(t,e){return t.size<=e}function sn(t,e){const n=A(t.name);return e.includes(n)}function an(t,e,n){return new File([t],e,{type:n})}function fn(t,e,n="text/plain"){const r=new Blob([t],{type:n}),o=URL.createObjectURL(r);T({path:o,name:e}),URL.revokeObjectURL(o)}async function ln(t,e=800,n=800,r=.8){if(t.type.startsWith("image/"))return new Promise(o=>{const c=document.createElement("canvas"),u=c.getContext("2d"),s=new Image;s.onload=()=>{let{width:a,height:f}=s;if(a>e||f>n){const _=Math.min(e/a,n/f);a*=_,f*=_}c.width=a,c.height=f,u?.drawImage(s,0,0,a,f),c.toBlob(_=>{if(_){const d=new File([_],t.name,{type:t.type});o(d)}else o(void 0)},t.type,r)},s.src=URL.createObjectURL(t)})}function _n(t){const e=A(t.name),n=C(t.name);let r="";return t.size<1024?r=`${t.size} B`:t.size<1024*1024?r=`${(t.size/1024).toFixed(2)} KB`:t.size<1024*1024*1024?r=`${(t.size/(1024*1024)).toFixed(2)} MB`:r=`${(t.size/(1024*1024*1024)).toFixed(2)} GB`,{name:t.name,size:t.size,size_text:r,type:t.type,extension:e,name_without_extension:n}}function dn(t){const e=A(t),n=C(t),r=Date.now(),o=Math.random().toString(36).substring(2,8);return e?`${n}_${r}_${o}.${e}`:`${n}_${r}_${o}`}function nt(t){return/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.test(t)}function hn(t,e,n){if(!nt(t)||!nt(e))return t;n=Math.max(Math.min(Number(n),1),0);const r=p(t),o=p(e);if(!r||!o)return t;const c=Math.round(r.r*(1-n)+o.r*n),u=Math.round(r.g*(1-n)+o.g*n),s=Math.round(r.b*(1-n)+o.b*n);return E(c,u,s)}function mn(t){const e=p(t);return e?`${e.r},${e.g},${e.b}`:"0,0,0"}function p(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function E(t,e,n){return t=Math.max(0,Math.min(255,Math.round(t))),e=Math.max(0,Math.min(255,Math.round(e))),n=Math.max(0,Math.min(255,Math.round(n))),`#${((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)}`}function gn(t,e,n,r){return E(t,e,n)}function yn(t,e){const n=p(t);if(!n)return t;e=Math.max(0,Math.min(1,e));const r=Math.min(255,Math.round(n.r+(255-n.r)*e)),o=Math.min(255,Math.round(n.g+(255-n.g)*e)),c=Math.min(255,Math.round(n.b+(255-n.b)*e));return E(r,o,c)}function bn(t,e){const n=p(t);if(!n)return t;e=Math.max(0,Math.min(1,e));const r=Math.max(0,Math.round(n.r*(1-e))),o=Math.max(0,Math.round(n.g*(1-e))),c=Math.max(0,Math.round(n.b*(1-e)));return E(r,o,c)}function R(t){const e=p(t);return e?(e.r*299+e.g*587+e.b*114)/1e3>128:!1}function wn(t){return!R(t)}function pn(t){return R(t)?"#000000":"#FFFFFF"}function vn(t,e="YYYY-MM-DD HH:mm:ss"){return m(t).format(e)}function Mn(t,e=-1,n="YYYY-MM-DD HH:mm:ss",r=!1){const o=m(),c=o.format(n);let u=o;switch(t){case"d":u=r?o.add(e,"day"):o.startOf("day");break;case"w":u=r?o.add(e,"week"):o.startOf("week");break;case"M":u=r?o.add(e,"month"):o.startOf("month");break;case"Q":u=r?o.add(e*3,"month"):o.startOf("month").subtract(o.month()%3,"month");break;case"y":u=r?o.add(e,"year"):o.startOf("year");break;case"h":u=o.add(e,"hour");break;case"m":u=o.add(e,"minute");break;case"s":u=o.add(e,"second");break}return[u.format(n),c]}function Nn(t,e,n="day"){return m(t).diff(m(e),n)}function $n(t,e,n,r){const o=m(t).add(e,n);return r?o.format(r):o.toDate()}function En(t,e,n,r){const o=m(t).subtract(e,n);return r?o.format(r):o.toDate()}function kn(t){const e=m(t).day();return e>0&&e<6}function On(t){const e=m(t).day();return e===0||e===6}function Sn(t){const e=m(),n=m(t),r=e.diff(n,"minute");if(r<1)return"刚刚";if(r<60)return`${r}分钟前`;const o=e.diff(n,"hour");if(o<24)return`${o}小时前`;const c=e.diff(n,"day");if(c<30)return`${c}天前`;const u=e.diff(n,"month");return u<12?`${u}个月前`:`${e.diff(n,"year")}年前`}function zn(t,e="zh"){const n=Math.floor(t/1e3),r=Math.floor(n/86400),o=Math.floor(n%86400/3600),c=Math.floor(n%3600/60),u=n%60,s=e==="zh"?{day:"天",hour:"时",minute:"分",second:"秒"}:{day:"D",hour:"H",minute:"M",second:"S"};let a="";return r>0&&(a+=`${r}${s.day}`),(o>0||r>0&&(c>0||u>0))&&(a+=`${o}${s.hour}`),(c>0||o>0&&u>0)&&(a+=`${c}${s.minute}`),(u>0||a==="")&&(a+=`${u}${s.second}`),a}function An(t,e=200,n=!1){let r;return function(...o){const c=this;if(r&&clearTimeout(r),n){const u=!r;if(r=setTimeout(()=>{r=void 0},e),u)return t.apply(c,o)}else r=setTimeout(()=>{t.apply(c,o)},e)}}function In(t,e=200,n={}){const{leading:r=!0,trailing:o=!0}=n;let c=0,u,s,a;return function(...f){const _=this,d=Date.now();if(c===0){r&&t.apply(_,f),c=d;return}s=f,a=_;const M=d-c;if(M>=e){u&&(clearTimeout(u),u=void 0),t.apply(_,f),c=d;return}!u&&o&&(u=setTimeout(()=>{s&&(t.apply(a,s),c=Date.now()),u=void 0,s=void 0,a=void 0},e-M))}}function Dn(t){const e=t.length;function n(...r){return r.length>=e?t.apply(this,r):function(...o){return n.apply(this,[...r,...o])}}return n}function Ln(...t){return function(e){return t.reduceRight((n,r)=>r(n),e)}}function Fn(...t){return function(e){return t.reduce((n,r)=>r(n),e)}}function Tn(t,e=1e3){return new Promise(n=>{setTimeout(()=>{n(t())},e)})}async function rt(t,e=3,n=1e3){try{return await t()}catch(r){if(e<=0)throw r;return await new Promise(o=>setTimeout(o,n)),rt(t,e-1,n)}}function Cn(t){let e=!1,n;return function(...r){return e||(e=!0,n=t.apply(this,r)),n}}function Rn(t){const e=new Map;return function(...n){const r=JSON.stringify(n);if(e.has(r))return e.get(r);const o=t.apply(this,n);return e.set(r,o),o}}async function Hn(t,e=!0){if(e)return Promise.all(t.map(n=>n()));{const n=[];for(const r of t)n.push(await r());return n}}function Pn(t,e=5e3,n="Operation timed out"){return Promise.race([Promise.resolve(t()),new Promise((r,o)=>{setTimeout(()=>{o(new Error(n))},e)})])}function jn(t,e=1920){let n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;if(!n)return t;let r=n/e;return Number((t*r).toFixed(3))}function Wn(t,e,n){return{type:"linear",x:0,y:0,x2:t==="v"?0:1,y2:t==="v"?1:0,colorStops:[{offset:0,color:e},{offset:1,color:n}]}}function Un(t,e,n="canvas",r){return(async()=>{try{let c;if(typeof window<"u"&&window.echarts)c=window.echarts;else{const a=await import("echarts");c=a.default||a}const u=typeof t=="string"?document.getElementById(t):t;if(!u)return console.error("ECharts DOM容器未找到"),null;const s=c.init(u,r,{renderer:n});return e&&s.setOption(e),s}catch(c){return console.error("加载 ECharts 失败:",c),null}})()}function ot(t){t&&typeof t.dispose=="function"&&t.dispose()}function Bn(t,e){t&&typeof t.setOption=="function"&&t.setOption(e)}function H(t){t&&typeof t.resize=="function"&&t.resize()}function qn(t,e=200){if(!t)return;let n;const r=()=>{clearTimeout(n),n=setTimeout(()=>{H(t)},e)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),clearTimeout(n)}}function Yn(t,e){const r=e||["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc","#67c23a"],o=[];for(let c=0;c<t;c++)o.push(r[c%r.length]);return o}function Jn(t,e){return typeof e=="function"?e(t):typeof e=="string"?e.replace("{value}",String(t)):String(t)}function Vn(t,e){return{...t,...e,series:e.series||t.series,xAxis:e.xAxis||t.xAxis,yAxis:e.yAxis||t.yAxis,legend:e.legend||t.legend,tooltip:e.tooltip||t.tooltip,title:e.title||t.title}}function Kn(t,e,n){t&&typeof t.on=="function"&&t.on(e,n)}function Qn(t,e,n){t&&typeof t.off=="function"&&t.off(e,n)}function Gn(t,e={}){if(!t||typeof t.getDataURL!="function")return null;const{type:n="png",pixel_ratio:r=2,background_color:o="#fff",exclude_components:c=[],file_name:u="echarts-image"}=e,s=t.getDataURL({type:n,pixelRatio:r,backgroundColor:o,excludeComponents:c}),a=document.createElement("a");return a.download=`${u}.${n}`,a.href=s,a.click(),s}function Xn(){return typeof window<"u"&&typeof window.echarts<"u"}function Zn(t){t.forEach(e=>{H(e)})}function xn(t){t.forEach(e=>{ot(e)})}function tr(t,e,n="asc"){return[...t].sort((r,o)=>{const c=r[e],u=o[e];return c<u?n==="asc"?-1:1:c>u?n==="asc"?1:-1:0})}function it(t,e){return t.reduce((n,r)=>{const o=r[e];return n[o]||(n[o]=[]),n[o].push(r),n},{})}function er(t,e,n,r=o=>o.reduce((c,u)=>c+u,0)){const o=it(t,e);return Object.entries(o).map(([c,u])=>{const s=u.map(a=>a[n]).filter(a=>typeof a=="number");return{[e]:c,[n]:r(s)}})}const b=new Map;let I=null;U&&(document.addEventListener("mousedown",t=>{I=t}),document.addEventListener("mouseup",t=>{for(const e of b.values())for(const{document_handler:n}of e)I&&n(t,I);I=null}));function ct(t,e){const n=[];return Array.isArray(e.arg)?n.push(...e.arg.filter(D)):D(e.arg)&&n.push(e.arg),function(r,o){const c=r.target,u=o.target;if(!c||!u||!e.instance)return;const s=t.contains(c)||t.contains(u),a=t===c,f=n.some(d=>d&&(d.contains(c)||d===u));let _=!1;try{const d=e.instance.popperRef;d&&(_=d.contains(c)||d.contains(u))}catch{}s||a||f||_||typeof e.value=="function"&&e.value(r,o)}}const ut={beforeMount(t,e){b.has(t)||b.set(t,[]),b.get(t)?.push({document_handler:ct(t,e),binding_fn:e.value})},updated(t,e){b.has(t)||b.set(t,[]);const n=b.get(t);if(!n)return;const r=n.findIndex(c=>c.binding_fn===e.oldValue),o={document_handler:ct(t,e),binding_fn:e.value};r>=0?n.splice(r,1,o):n.push(o)},unmounted(t){b.delete(t)}};function nr(t){t.directive("click-outside",ut)}i.ClickOutside=ut,i.add_chart_listener=Kn,i.add_class=je,i.add_date=$n,i.add_tree_node=Xt,i.add_tree_node_path=Jt,i.aggregate_chart_data=er,i.auto_size=jn,i.batch_execution=Hn,i.build_tree=Wt,i.calculate_percentage=de,i.ceil=le,i.clamp=ie,i.clear_expired_storage=ve,i.clear_storage=ye,i.clone_tree=ee,i.compose=Ln,i.compress_image=ln,i.create_element=Ge,i.create_file_from_blob=an,i.curry=Dn,i.darken=bn,i.debounce=An,i.decrypt_storage=Ee,i.deep_assign=G,i.deep_clone=S,i.deep_equal=z,i.delay_execution=Tn,i.destroy_chart=ot,i.destroy_charts=xn,i.diff_objects=Ce,i.download_file=T,i.download_files=rn,i.download_text_file=fn,i.encrypt_storage=$e,i.export_chart_image=Gn,i.filter_tree=qt,i.find_tree_node=B,i.find_tree_node_by_key=F,i.flatten_object=X,i.flatten_tree_to_array=Gt,i.floor=_e,i.format_chart_label=Jn,i.format_currency=oe,i.format_date=vn,i.format_timestamp_diff=zn,i.generate_chart_colors=Yn,i.generate_unique_file_name=dn,i.get_all_storage_keys=Q,i.get_attribute=Je,i.get_batch_storage=Oe,i.get_chart_gradient_color=Wn,i.get_contrast_color=pn,i.get_date_diff=Nn,i.get_date_time_range=Mn,i.get_decimal_part=ae,i.get_document_size=nn,i.get_element=He,i.get_element_position=et,i.get_element_rect=$,i.get_element_size=Xe,i.get_elements=Pe,i.get_file_extension=A,i.get_file_info=_n,i.get_file_name_without_extension=C,i.get_integer_part=se,i.get_object_value=Le,i.get_parent_by_class=Z,i.get_relative_time=Sn,i.get_rgb=mn,i.get_storage=V,i.get_storage_with_expiry=we,i.get_style=qe,i.get_token=he,i.get_tree_depth=Qt,i.get_tree_node_ancestors=Kt,i.get_tree_node_descendants=Vt,i.get_window_size=en,i.group_chart_data=it,i.guid=_t,i.has_class=Be,i.has_storage=pe,i.hex_to_rgb=p,i.init_chart=Un,i.is_array=l,i.is_boolean=Et,i.is_client=U,i.is_completely_in_viewport=tn,i.is_dark=wn,i.is_date=W,i.is_echarts_loaded=Xn,i.is_element=D,i.is_email=Tt,i.is_empty=zt,i.is_empty_object=ze,i.is_even=ue,i.is_falsy=It,i.is_function=w,i.is_hex_color=Rt,i.is_html_element=Dt,i.is_in_viewport=xe,i.is_ip=Ht,i.is_light=R,i.is_mobile=Ft,i.is_null=Mt,i.is_number=g,i.is_object=h,i.is_plain_object=Nt,i.is_port=Pt,i.is_promise=St,i.is_reg_exp=kt,i.is_string=L,i.is_string_number=Lt,i.is_symbol=Ot,i.is_truthy=At,i.is_undefined=vt,i.is_url=Ct,i.is_valid_date=$t,i.is_weekday=kn,i.is_weekend=On,i.lighten=yn,i.make_chart_responsive=qn,i.memoize=Rn,i.merge_chart_options=Vn,i.merge_objects=Te,i.mix=hn,i.off=Qe,i.omit=Ie,i.on=Ke,i.once=Cn,i.pick=Ae,i.pipe=Fn,i.random_boolean=dt,i.random_color=mt,i.random_element=v,i.random_elements=ht,i.random_email=bt,i.random_float=lt,i.random_id=st,i.random_int=at,i.random_int_range=ft,i.random_len_string=N,i.random_number_string=j,i.random_password=gt,i.random_phone=yt,i.random_string=P,i.random_url=wt,i.read_file=cn,i.remove_attribute=Ve,i.remove_batch_storage=Se,i.remove_chart_listener=Qn,i.remove_class=We,i.remove_storage=K,i.remove_token=ge,i.remove_tree_node=Zt,i.resize_chart=H,i.resize_charts=Zn,i.retry=rt,i.rgb_to_hex=E,i.rgba_to_hex=gn,i.round=fe,i.scroll_footer=Re,i.scroll_to_element=Ze,i.search_tree=re,i.set_attribute=tt,i.set_batch_storage=ke,i.set_object_value=Fe,i.set_storage=J,i.set_storage_with_expiry=be,i.set_style=Ye,i.set_styles=x,i.set_token=me,i.setupDirectives=nr,i.shuffle_array=pt,i.sort_chart_data=tr,i.sort_tree=te,i.subtract_date=En,i.thousand_separator=q,i.throttle=In,i.timeout=Pn,i.to_base64=on,i.to_fixed=Y,i.to_number=k,i.to_percentage=ce,i.toggle_class=Ue,i.transform_tree=Yt,i.traverse_tree_breadth_first=Bt,i.traverse_tree_depth_first=Ut,i.tree_flat=jt,i.unflatten_object=De,i.update_chart=Bn,i.update_tree_node=xt,i.validate_file_size=un,i.validate_file_type=sn,i.validate_tree=ne,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { generate_guid, generate_id, generate_random_color, generate_random_email, generate_random_number_string, generate_random_password, generate_random_phone, generate_random_string, generate_random_url, generate_string, get_random_boolean, get_random_element, get_random_elements, get_random_float, get_random_int, get_random_int_range, shuffle_array } from "./utils/random.js";
1
+ import { guid, random_boolean, random_color, random_element, random_elements, random_email, random_float, random_id, random_int, random_int_range, random_len_string, random_number_string, random_password, random_phone, random_string, random_url, shuffle_array } from "./utils/random.js";
2
2
  import { is_array, is_boolean, is_client, is_date, is_element, is_email, is_empty, is_falsy, is_function, is_hex_color, is_html_element, is_ip, is_mobile, is_null, is_number, is_object, is_plain_object, is_port, is_promise, is_reg_exp, is_string, is_string_number, is_symbol, is_truthy, is_undefined, is_url, is_valid_date } from "./utils/is.js";
3
3
  import { add_tree_node, add_tree_node_path, build_tree, clone_tree, filter_tree, find_tree_node, find_tree_node_by_key, flatten_tree_to_array, get_tree_depth, get_tree_node_ancestors, get_tree_node_descendants, remove_tree_node, search_tree, sort_tree, transform_tree, traverse_tree_breadth_first, traverse_tree_depth_first, tree_flat, update_tree_node, validate_tree } from "./utils/tree.js";
4
4
  import { calculate_percentage, ceil, clamp, floor, format_currency, get_decimal_part, get_integer_part, is_even, round, thousand_separator, to_fixed, to_number, to_percentage } from "./utils/number.js";
@@ -60,16 +60,6 @@ export {
60
60
  format_date,
61
61
  format_timestamp_diff,
62
62
  generate_chart_colors,
63
- generate_guid,
64
- generate_id,
65
- generate_random_color,
66
- generate_random_email,
67
- generate_random_number_string,
68
- generate_random_password,
69
- generate_random_phone,
70
- generate_random_string,
71
- generate_random_url,
72
- generate_string,
73
63
  generate_unique_file_name,
74
64
  get_all_storage_keys,
75
65
  get_attribute,
@@ -91,12 +81,6 @@ export {
91
81
  get_integer_part,
92
82
  get_object_value,
93
83
  get_parent_by_class,
94
- get_random_boolean,
95
- get_random_element,
96
- get_random_elements,
97
- get_random_float,
98
- get_random_int,
99
- get_random_int_range,
100
84
  get_relative_time,
101
85
  get_rgb,
102
86
  get_storage,
@@ -108,6 +92,7 @@ export {
108
92
  get_tree_node_descendants,
109
93
  get_window_size,
110
94
  group_chart_data,
95
+ guid,
111
96
  has_class,
112
97
  has_storage,
113
98
  hex_to_rgb,
@@ -160,6 +145,21 @@ export {
160
145
  once,
161
146
  pick,
162
147
  pipe,
148
+ random_boolean,
149
+ random_color,
150
+ random_element,
151
+ random_elements,
152
+ random_email,
153
+ random_float,
154
+ random_id,
155
+ random_int,
156
+ random_int_range,
157
+ random_len_string,
158
+ random_number_string,
159
+ random_password,
160
+ random_phone,
161
+ random_string,
162
+ random_url,
163
163
  read_file,
164
164
  remove_attribute,
165
165
  remove_batch_storage,
@@ -7,20 +7,20 @@
7
7
  * 生成[0-10000]的随机数,针对数据小量使用
8
8
  * @returns 随机数
9
9
  */
10
- export declare function generate_id(): number;
10
+ export declare function random_id(): number;
11
11
  /**
12
12
  * 生成[0-max]的随机数
13
13
  * @param max 最大值
14
14
  * @returns 随机数
15
15
  */
16
- export declare function get_random_int(max: number): number;
16
+ export declare function random_int(max: number): number;
17
17
  /**
18
18
  * 生成指定范围的随机整数
19
19
  * @param min 最小值
20
20
  * @param max 最大值
21
21
  * @returns 随机整数
22
22
  */
23
- export declare function get_random_int_range(min: number, max: number): number;
23
+ export declare function random_int_range(min: number, max: number): number;
24
24
  /**
25
25
  * 生成随机浮点数
26
26
  * @param min 最小值
@@ -28,74 +28,74 @@ export declare function get_random_int_range(min: number, max: number): number;
28
28
  * @param decimalPlaces 小数位数
29
29
  * @returns 随机浮点数
30
30
  */
31
- export declare function get_random_float(min: number, max: number, decimalPlaces?: number): number;
31
+ export declare function random_float(min: number, max: number, decimalPlaces?: number): number;
32
32
  /**
33
33
  * 生成GUID/UUID
34
34
  * @returns GUID/UUID字符串
35
35
  */
36
- export declare function generate_guid(): string;
36
+ export declare function guid(): string;
37
37
  /**
38
38
  * 生成随机字符串
39
39
  * @returns 随机字符串
40
40
  */
41
- export declare function generate_string(): string;
41
+ export declare function random_string(): string;
42
42
  /**
43
43
  * 生成指定长度的随机字符串
44
44
  * @param length 字符串长度
45
45
  * @param chars 可选字符集
46
46
  * @returns 随机字符串
47
47
  */
48
- export declare function generate_random_string(length: number, chars?: string): string;
48
+ export declare function random_len_string(length: number, chars?: string): string;
49
49
  /**
50
50
  * 生成随机布尔值
51
51
  * @returns 随机布尔值
52
52
  */
53
- export declare function get_random_boolean(): boolean;
53
+ export declare function random_boolean(): boolean;
54
54
  /**
55
55
  * 从数组中随机选择一个元素
56
56
  * @param array 源数组
57
57
  * @returns 随机选中的元素
58
58
  */
59
- export declare function get_random_element<T>(array: T[]): T | undefined;
59
+ export declare function random_element<T>(array: T[]): T | undefined;
60
60
  /**
61
61
  * 从数组中随机选择多个元素
62
62
  * @param array 源数组
63
63
  * @param count 选择数量
64
64
  * @returns 随机选中的元素数组
65
65
  */
66
- export declare function get_random_elements<T>(array: T[], count: number): T[];
66
+ export declare function random_elements<T>(array: T[], count: number): T[];
67
67
  /**
68
68
  * 生成随机颜色
69
69
  * @returns 随机颜色的十六进制值
70
70
  */
71
- export declare function generate_random_color(): string;
71
+ export declare function random_color(): string;
72
72
  /**
73
73
  * 生成指定长度的随机数字字符串
74
74
  * @param length 字符串长度
75
75
  * @returns 随机数字字符串
76
76
  */
77
- export declare function generate_random_number_string(length: number): string;
77
+ export declare function random_number_string(length: number): string;
78
78
  /**
79
79
  * 生成随机密码
80
80
  * @param length 密码长度,默认8
81
81
  * @returns 随机密码
82
82
  */
83
- export declare function generate_random_password(length?: number): string;
83
+ export declare function random_password(length?: number): string;
84
84
  /**
85
85
  * 生成随机手机号
86
86
  * @returns 随机手机号
87
87
  */
88
- export declare function generate_random_phone(): string;
88
+ export declare function random_phone(): string;
89
89
  /**
90
90
  * 生成随机邮箱
91
91
  * @returns 随机邮箱
92
92
  */
93
- export declare function generate_random_email(): string;
93
+ export declare function random_email(): string;
94
94
  /**
95
95
  * 生成随机URL
96
96
  * @returns 随机URL
97
97
  */
98
- export declare function generate_random_url(): string;
98
+ export declare function random_url(): string;
99
99
  /**
100
100
  * 打乱数组顺序
101
101
  * @param array 源数组
@@ -1,27 +1,27 @@
1
- function generate_id() {
1
+ function random_id() {
2
2
  return Math.floor(Math.random() * 1e4);
3
3
  }
4
- function get_random_int(max) {
4
+ function random_int(max) {
5
5
  if (max < 0) return 0;
6
6
  return Math.floor(Math.random() * Math.floor(max));
7
7
  }
8
- function get_random_int_range(min, max) {
8
+ function random_int_range(min, max) {
9
9
  if (min > max) [min, max] = [max, min];
10
10
  return Math.floor(Math.random() * (max - min + 1)) + min;
11
11
  }
12
- function get_random_float(min, max, decimalPlaces = 2) {
12
+ function random_float(min, max, decimalPlaces = 2) {
13
13
  if (min > max) [min, max] = [max, min];
14
14
  const random = Math.random() * (max - min) + min;
15
15
  return parseFloat(random.toFixed(decimalPlaces));
16
16
  }
17
- function generate_guid() {
18
- const gs = generate_string;
17
+ function guid() {
18
+ const gs = random_string;
19
19
  return `${gs()}${gs()}-${gs()}-${gs()}-${gs()}-${gs()}${gs()}${gs()}`;
20
20
  }
21
- function generate_string() {
21
+ function random_string() {
22
22
  return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
23
23
  }
24
- function generate_random_string(length, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
24
+ function random_len_string(length, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
25
25
  let result = "";
26
26
  const charsLength = chars.length;
27
27
  for (let i = 0; i < length; i++) {
@@ -29,20 +29,20 @@ function generate_random_string(length, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde
29
29
  }
30
30
  return result;
31
31
  }
32
- function get_random_boolean() {
32
+ function random_boolean() {
33
33
  return Math.random() > 0.5;
34
34
  }
35
- function get_random_element(array) {
35
+ function random_element(array) {
36
36
  if (!array || array.length === 0) return void 0;
37
37
  return array[Math.floor(Math.random() * array.length)];
38
38
  }
39
- function get_random_elements(array, count) {
39
+ function random_elements(array, count) {
40
40
  if (!array || array.length === 0 || count <= 0) return [];
41
41
  if (count >= array.length) return [...array];
42
42
  const shuffled = [...array].sort(() => 0.5 - Math.random());
43
43
  return shuffled.slice(0, count);
44
44
  }
45
- function generate_random_color() {
45
+ function random_color() {
46
46
  const letters = "0123456789ABCDEF";
47
47
  let color = "#";
48
48
  for (let i = 0; i < 6; i++) {
@@ -50,33 +50,33 @@ function generate_random_color() {
50
50
  }
51
51
  return color;
52
52
  }
53
- function generate_random_number_string(length) {
54
- return generate_random_string(length, "0123456789");
53
+ function random_number_string(length) {
54
+ return random_len_string(length, "0123456789");
55
55
  }
56
- function generate_random_password(length = 8) {
56
+ function random_password(length = 8) {
57
57
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=";
58
- return generate_random_string(length, chars);
58
+ return random_len_string(length, chars);
59
59
  }
60
- function generate_random_phone() {
60
+ function random_phone() {
61
61
  const prefixes = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "150", "151", "152", "153", "155", "156", "157", "158", "159", "170", "171", "172", "173", "175", "176", "177", "178", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189"];
62
- const prefix = get_random_element(prefixes);
63
- const suffix = generate_random_number_string(8);
62
+ const prefix = random_element(prefixes);
63
+ const suffix = random_number_string(8);
64
64
  return `${prefix}${suffix}`;
65
65
  }
66
- function generate_random_email() {
66
+ function random_email() {
67
67
  const domains = ["gmail.com", "yahoo.com", "hotmail.com", "outlook.com", "163.com", "126.com", "qq.com", "sina.com"];
68
- const username = generate_random_string(8);
69
- const domain = get_random_element(domains);
68
+ const username = random_len_string(8);
69
+ const domain = random_element(domains);
70
70
  return `${username}@${domain}`;
71
71
  }
72
- function generate_random_url() {
72
+ function random_url() {
73
73
  const protocols = ["http", "https"];
74
74
  const domains = ["example.com", "test.com", "demo.com", "sample.com"];
75
75
  const paths = ["api", "docs", "about", "contact", "products"];
76
- const protocol = get_random_element(protocols);
77
- const domain = get_random_element(domains);
78
- const path = get_random_element(paths);
79
- const query = generate_random_string(4);
76
+ const protocol = random_element(protocols);
77
+ const domain = random_element(domains);
78
+ const path = random_element(paths);
79
+ const query = random_len_string(4);
80
80
  return `${protocol}://www.${domain}/${path}?id=${query}`;
81
81
  }
82
82
  function shuffle_array(array) {
@@ -89,21 +89,21 @@ function shuffle_array(array) {
89
89
  return shuffled;
90
90
  }
91
91
  export {
92
- generate_guid,
93
- generate_id,
94
- generate_random_color,
95
- generate_random_email,
96
- generate_random_number_string,
97
- generate_random_password,
98
- generate_random_phone,
99
- generate_random_string,
100
- generate_random_url,
101
- generate_string,
102
- get_random_boolean,
103
- get_random_element,
104
- get_random_elements,
105
- get_random_float,
106
- get_random_int,
107
- get_random_int_range,
92
+ guid,
93
+ random_boolean,
94
+ random_color,
95
+ random_element,
96
+ random_elements,
97
+ random_email,
98
+ random_float,
99
+ random_id,
100
+ random_int,
101
+ random_int_range,
102
+ random_len_string,
103
+ random_number_string,
104
+ random_password,
105
+ random_phone,
106
+ random_string,
107
+ random_url,
108
108
  shuffle_array
109
109
  };
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@qy_better_lib/core",
3
3
  "type": "module",
4
4
  "private": false,
5
- "version": "0.2.1",
5
+ "version": "0.2.3",
6
6
  "description": "qy better lib core",
7
7
  "author": "luhuiming",
8
- "license": "ISC",
8
+ "license": "MIT",
9
9
  "scripts": {
10
10
  "build:lib": "vite build --config vite.lib.config.ts",
11
11
  "build:dist-min": "vite build --config vite.dist.min.config.ts",
@@ -45,15 +45,15 @@
45
45
  "./utils/*": "./lib/utils/*.js"
46
46
  },
47
47
  "peerDependencies": {
48
- "vue": "^3.5.22",
49
- "dayjs": "^1.11.10"
48
+ "dayjs": "^1.11.19"
50
49
  },
51
50
  "devDependencies": {
52
51
  "@types/node": "^24.5.2",
53
52
  "@vitejs/plugin-vue": "^6.0.1",
53
+ "dayjs": "^1.11.19",
54
+ "happy-dom": "^15.4.0",
54
55
  "vite": "^7.1.7",
55
56
  "vite-plugin-dts": "^4.5.4",
56
- "vitest": "^4.0.18",
57
- "happy-dom": "^15.4.0"
57
+ "vitest": "^4.0.18"
58
58
  }
59
- }
59
+ }