@qy_better_lib/core 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(o,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(o=typeof globalThis<"u"?globalThis:o||self,f(o["@qy_better_lib/core"]={}))})(this,function(o){"use strict";function f(){return Math.floor(Math.random()*1e4)}function w(e){return Math.floor(Math.random()*Math.floor(e))}function C(){const e=h;return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function h(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function $(e){return e===void 0}function N(e){return Object.prototype.toString.call(e)==="[object Array]"}function g(e){return typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function A(e){return Object.prototype.toString.call(e)==="[object Date]"}function M(e){return!e&&e!==0||N(e)&&e.length===0||g(e)&&!Object.keys(e).length}function O(e){return typeof Element>"u"?!1:e instanceof Element}const k=typeof window<"u",y=e=>typeof e=="number",v=e=>typeof e=="string",j=e=>v(e)?!Number.isNaN(Number(e)):!1;function L(e){return/^1[3-9]\d{9}$/.test(e)}function R(e){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(e)}function B(e){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(e)}function P(e,t="key",n="children"){const r={},i=(c,a)=>{for(let s=0;s<c.length;s++){const l=c[s],d=l[t];if(!r[d]){r[d]=l,a&&(r[d].parent=r[a]);const m=l[n];m&&m.length>0&&i(m,l[t])}}};return i(e),r}function _(e){return e?Object.prototype.toString.call(1)!=="[object Number]"?`${e}`:`${e}`.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,"$1,"):"0"}function H(e,t){return y(e)?Number(t?Number(e).toFixed(t):e):Number.NaN}function J(e,t){return y(e)?Number(e.toFixed(t)):Number.NaN}function U(){const e=localStorage.getItem("token");if(!e)return;const t=JSON.parse(e);if(t!==null)if(t.expirse!=null&&t.expirse<new Date().getTime())localStorage.removeItem("token");else return t.value;return null}function q(e,t){!t&&(t=7*24*60*60*1e3)||(t=t*1e3);const n={value:e,expirse:new Date().getTime()+t};localStorage.setItem("token",JSON.stringify(n))}function V(){localStorage.removeItem("token")}function Y(e,t,n="local"){const r=n=="local"?localStorage:sessionStorage;t!=null&&r.setItem(e,JSON.stringify(t))}function z(e,t="local"){let r=(t=="local"?localStorage:sessionStorage).getItem(e);return r&&JSON.parse(r||"")}function G(e,t="local"){(t=="local"?localStorage:sessionStorage).removeItem(e)}function K(e="local"){(e=="local"?localStorage:sessionStorage).clear()}function E(e){const t=Object.prototype.toString;if(!e||typeof e!="object")return e;if(e.nodeType&&"cloneNode"in e)return e.cloneNode(!0);if(t.call(e)==="[object Date]")return new Date(e.getTime());if(t.call(e)==="[object RegExp]"){const r=[];return e.global&&r.push("g"),e.multiline&&r.push("m"),e.ignoreCase&&r.push("i"),new RegExp(e.source,r.join(""))}if(t.call(e)==="[object FormData]"){const r=new FormData;for(const[i,c]of e.entries())r.append(i,c);return r}const n=Array.isArray(e)?[]:e.constructor?new e.constructor:{};for(const r in e)n[r]=E(e[r]);return n}function I(...e){let t=e.length,n=e[0];g(n)||(n={});for(let r=1;r<t;r++){let i=e[r];if(g(i))for(let c in i)c==="__proto__"||n===i[c]||(g(i[c])?n[c]=I(n[c],i[c]):n[c]=i[c])}return n}function S(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;let n,r,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!S(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const c=i[r];if(!S(e[c],t[c]))return!1}return!0}return e!==e&&t!==t}function T(e,t){return!e||e.tagName==="BODY"?null:e.classList.contains(t)?e:T(e.parentNode,t)}function D({path:e,name:t}){const n=document.createElement("a");n.href=e,n.target="_blank",t&&n.setAttribute("download",t),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Q(e){e.forEach(t=>{D({path:t.url,name:t.name})})}async function W(e){if(!e)return;const t=new FileReader;return t.readAsDataURL(e),new Promise((n,r)=>{t.onload=i=>{var c;return n((c=i.target)==null?void 0:c.result)},t.onerror=i=>r(void 0)})}const u=new Map;let F;k&&(document.addEventListener("mousedown",e=>F=e),document.addEventListener("mouseup",e=>{for(const t of u.values())for(const{documentHandler:n}of t)n(e,F)}));function b(e,t){let n=[];return Array.isArray(t.arg)?n=t.arg:O(t.arg)&&n.push(t.arg),function(r,i){const c=t.instance.popperRef,a=r.target,s=i==null?void 0:i.target,l=!t||!t.instance,d=!a||!s,m=e.contains(a)||e.contains(s),Z=e===a,x=n.length&&n.some(p=>p==null?void 0:p.contains(a))||n.length&&n.includes(s),ee=c&&(c.contains(a)||c.contains(s));l||d||m||Z||x||ee||t.value(r,i)}}const X={beforeMount(e,t){var n;u.has(e)||u.set(e,[]),(n=u.get(e))==null||n.push({documentHandler:b(e,t),bindingFn:t.value})},updated(e,t){u.has(e)||u.set(e,[]);const n=u.get(e),r=n==null?void 0:n.findIndex(c=>c.bindingFn===t.oldValue),i={documentHandler:b(e,t),bindingFn:t.value};r&&r>=0?n==null||n.splice(r,1,i):n==null||n.push(i)},unmounted(e){u.delete(e)}};o.ClickOutside=X,o.clearStorage=K,o.deepAssign=I,o.deepClone=E,o.deepEqual=S,o.downLoadFile=D,o.downLoadFiles=Q,o.generateId=f,o.generateString=h,o.getParentByClass=T,o.getRandomInt=w,o.getStorage=z,o.getToken=U,o.guiID=C,o.isArray=N,o.isClient=k,o.isDate=A,o.isElement=O,o.isEmpty=M,o.isIp=R,o.isMobile=L,o.isNumber=y,o.isObject=g,o.isPort=B,o.isString=v,o.isStringNumber=j,o.isUndefined=$,o.removeStorage=G,o.removeToken=V,o.setStorage=Y,o.setToken=q,o.thousandSeparator=_,o.toBase64=W,o.toFixed=J,o.toNumber=H,o.treeFlat=P,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(o=typeof globalThis<"u"?globalThis:o||self,d(o["@qy_better_lib/core"]={}))})(this,(function(o){"use strict";function d(){return Math.floor(Math.random()*1e4)}function D(e){return Math.floor(Math.random()*Math.floor(e))}function F(){const e=p;return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function p(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function C(e){return e===void 0}function O(e){return Object.prototype.toString.call(e)==="[object Array]"}function m(e){return typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function j(e){return Object.prototype.toString.call(e)==="[object Date]"}function A(e){return!e&&e!==0||O(e)&&e.length===0||m(e)&&!Object.keys(e).length}function b(e){return typeof Element>"u"?!1:e instanceof Element}const k=typeof window<"u",y=e=>typeof e=="number",N=e=>typeof e=="string",w=e=>N(e)?!Number.isNaN(Number(e)):!1;function _(e){return/^1[3-9]\d{9}$/.test(e)}function L(e){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(e)}function R(e){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(e)}function B(e,t="key",n="children"){const r={},i=(s,u)=>{for(let c=0;c<s.length;c++){const a=s[c],f=a[t];if(!r[f]){r[f]=a,u&&(r[f].parent=r[u]);const g=a[n];g&&g.length>0&&i(g,a[t])}}};return i(e),r}function P(e){return e?Object.prototype.toString.call(1)!=="[object Number]"?`${e}`:`${e}`.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,"$1,"):"0"}function H(e,t){return y(e)?Number(t?Number(e).toFixed(t):e):Number.NaN}function J(e,t){return y(e)?Number(e.toFixed(t)):Number.NaN}function U(){const e=localStorage.getItem("token");if(!e)return;const t=JSON.parse(e);if(t!==null)if(t.expirse!=null&&t.expirse<new Date().getTime())localStorage.removeItem("token");else return t.value;return null}function q(e,t){!t&&(t=10080*60*1e3)||(t=t*1e3);const n={value:e,expirse:new Date().getTime()+t};localStorage.setItem("token",JSON.stringify(n))}function V(){localStorage.removeItem("token")}function Y(e,t,n="local"){const r=n=="local"?localStorage:sessionStorage;t!=null&&r.setItem(e,JSON.stringify(t))}function z(e,t="local"){let r=(t=="local"?localStorage:sessionStorage).getItem(e);return r&&JSON.parse(r||"")}function G(e,t="local"){(t=="local"?localStorage:sessionStorage).removeItem(e)}function K(e="local"){(e=="local"?localStorage:sessionStorage).clear()}function I(e){const t=Object.prototype.toString;if(!e||typeof e!="object")return e;if(e.nodeType&&"cloneNode"in e)return e.cloneNode(!0);if(t.call(e)==="[object Date]")return new Date(e.getTime());if(t.call(e)==="[object RegExp]"){const r=[];return e.global&&r.push("g"),e.multiline&&r.push("m"),e.ignoreCase&&r.push("i"),new RegExp(e.source,r.join(""))}if(t.call(e)==="[object FormData]"){const r=new FormData;for(const[i,s]of e.entries())r.append(i,s);return r}const n=Array.isArray(e)?[]:e.constructor?new e.constructor:{};for(const r in e)n[r]=I(e[r]);return n}function v(...e){let t=e.length,n=e[0];m(n)||(n={});for(let r=1;r<t;r++){let i=e[r];if(m(i))for(let s in i)s==="__proto__"||n===i[s]||(m(i[s])?n[s]=v(n[s],i[s]):n[s]=i[s])}return n}function S(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return console.log("对象比较-a.constructor",e.constructor,"对象比较-b.constructor",t.constructor),!1;let n,r,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return console.log("对象比较-a.length",e.length,"对象比较-b.length",t.length),!1;for(r=n;r--!==0;)if(!S(e[r],t[r]))return console.log("对象比较-a[i]",e[r],"对象比较-b[i]",t[r]),!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()!==t.valueOf()&&console.log("对象比较-a.valueOf()",e.valueOf(),"对象比较-b.valueOf()",e.valueOf()),e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString()&&console.log("对象比较-a.toString()",e.toString(),"对象比较-b.toString()",t.toString()),e.toString()===t.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return console.log("对象比较-Object.keys(a).length",Object.keys(e).length,"对象比较-Object.keys(b).length",Object.keys(t).length),!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return console.log("对象比较-keys[i]",i[r],"对象比较-b",t),!1;for(r=n;r--!==0;){const s=i[r];if(!S(e[s],t[s]))return console.log("对象比较-a[key]",e[s],"对象比较-b[key]",t[s]),!1}return!0}return e!==e&&t!==t||console.log("对象比较-a",e,"对象比较-b",t),e!==e&&t!==t}function $(e,t){return!e||e.tagName==="BODY"?null:e.classList.contains(t)?e:$(e.parentNode,t)}function M({path:e,name:t}){const n=document.createElement("a");n.href=e,n.target="_blank",t&&n.setAttribute("download",t),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Q(e){e.forEach(t=>{M({path:t.url,name:t.name})})}async function W(e){if(!e)return;const t=new FileReader;return t.readAsDataURL(e),new Promise((n,r)=>{t.onload=i=>n(i.target?.result),t.onerror=i=>r(void 0)})}function X(e,t,n){n=Math.max(Math.min(Number(n),1),0);let r=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),s=parseInt(e.substring(5,7),16),u=parseInt(t.substring(1,3),16),c=parseInt(t.substring(3,5),16),a=parseInt(t.substring(5,7),16),f=Math.round(r*(1-n)+u*n),g=Math.round(i*(1-n)+c*n),h=Math.round(s*(1-n)+a*n);return`#${("0"+(f||0).toString(16)).slice(-2)}${("0"+(g||0).toString(16)).slice(-2)}${("0"+(h||0).toString(16)).slice(-2)}`}function Z(e){return`${Math.round(parseInt(e.substring(1,3),16))},${Math.round(parseInt(e.substring(3,5),16))},${Math.round(parseInt(e.substring(5,7),16))}`}const l=new Map;let E;k&&(document.addEventListener("mousedown",e=>E=e),document.addEventListener("mouseup",e=>{for(const t of l.values())for(const{documentHandler:n}of t)n(e,E)}));function T(e,t){let n=[];return Array.isArray(t.arg)?n=t.arg:b(t.arg)&&n.push(t.arg),function(r,i){const s=t.instance.popperRef,u=r.target,c=i?.target,a=!t||!t.instance,f=!u||!c,g=e.contains(u)||e.contains(c),h=e===u,ee=n.length&&n.some(ne=>ne?.contains(u))||n.length&&n.includes(c),te=s&&(s.contains(u)||s.contains(c));a||f||g||h||ee||te||t.value(r,i)}}const x={beforeMount(e,t){l.has(e)||l.set(e,[]),l.get(e)?.push({documentHandler:T(e,t),bindingFn:t.value})},updated(e,t){l.has(e)||l.set(e,[]);const n=l.get(e),r=n?.findIndex(s=>s.bindingFn===t.oldValue),i={documentHandler:T(e,t),bindingFn:t.value};r&&r>=0?n?.splice(r,1,i):n?.push(i)},unmounted(e){l.delete(e)}};o.ClickOutside=x,o.clearStorage=K,o.deepAssign=v,o.deepClone=I,o.deepEqual=S,o.downLoadFile=M,o.downLoadFiles=Q,o.generateId=d,o.generateString=p,o.getParentByClass=$,o.getRandomInt=D,o.getStorage=z,o.getToken=U,o.get_rgb=Z,o.guiID=F,o.isArray=O,o.isClient=k,o.isDate=j,o.isElement=b,o.isEmpty=A,o.isIp=L,o.isMobile=_,o.isNumber=y,o.isObject=m,o.isPort=R,o.isString=N,o.isStringNumber=w,o.isUndefined=C,o.mix=X,o.removeStorage=G,o.removeToken=V,o.setStorage=Y,o.setToken=q,o.thousandSeparator=P,o.toBase64=W,o.toFixed=J,o.toNumber=H,o.treeFlat=B,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
@@ -1,4 +1,3 @@
1
1
  import { ObjectDirective } from 'vue';
2
-
3
2
  declare const ClickOutside: ObjectDirective;
4
3
  export default ClickOutside;
@@ -1,40 +1,39 @@
1
- import { isClient as H, isElement as m } from "../utils/is.js";
1
+ import { isClient as x, isElement as E } from "../utils/is.js";
2
2
  const s = /* @__PURE__ */ new Map();
3
- let f;
4
- H && (document.addEventListener("mousedown", (e) => f = e), document.addEventListener("mouseup", (e) => {
5
- for (const n of s.values())
6
- for (const { documentHandler: t } of n)
7
- t(e, f);
3
+ let d;
4
+ x && (document.addEventListener("mousedown", (e) => d = e), document.addEventListener("mouseup", (e) => {
5
+ for (const t of s.values())
6
+ for (const { documentHandler: n } of t)
7
+ n(e, d);
8
8
  }));
9
- function d(e, n) {
10
- let t = [];
11
- return Array.isArray(n.arg) ? t = n.arg : m(n.arg) && t.push(n.arg), function(a, o) {
12
- const c = n.instance.popperRef, r = a.target, u = o == null ? void 0 : o.target, l = !n || !n.instance, p = !r || !u, g = e.contains(r) || e.contains(u), v = e === r, x = t.length && t.some((i) => i == null ? void 0 : i.contains(r)) || t.length && t.includes(u), E = c && (c.contains(r) || c.contains(u));
13
- l || p || g || v || x || E || n.value(a, o);
9
+ function i(e, t) {
10
+ let n = [];
11
+ return Array.isArray(t.arg) ? n = t.arg : E(t.arg) && n.push(t.arg), function(o, a) {
12
+ const r = t.instance.popperRef, c = o.target, u = a?.target, l = !t || !t.instance, f = !c || !u, p = e.contains(c) || e.contains(u), m = e === c, h = n.length && n.some((v) => v?.contains(c)) || n.length && n.includes(u), g = r && (r.contains(c) || r.contains(u));
13
+ l || f || p || m || h || g || t.value(o, a);
14
14
  };
15
15
  }
16
- const y = {
17
- beforeMount(e, n) {
18
- var t;
19
- s.has(e) || s.set(e, []), (t = s.get(e)) == null || t.push({
20
- documentHandler: d(e, n),
21
- bindingFn: n.value
16
+ const C = {
17
+ beforeMount(e, t) {
18
+ s.has(e) || s.set(e, []), s.get(e)?.push({
19
+ documentHandler: i(e, t),
20
+ bindingFn: t.value
22
21
  });
23
22
  },
24
- updated(e, n) {
23
+ updated(e, t) {
25
24
  s.has(e) || s.set(e, []);
26
- const t = s.get(e), a = t == null ? void 0 : t.findIndex(
27
- (c) => c.bindingFn === n.oldValue
28
- ), o = {
29
- documentHandler: d(e, n),
30
- bindingFn: n.value
25
+ const n = s.get(e), o = n?.findIndex(
26
+ (r) => r.bindingFn === t.oldValue
27
+ ), a = {
28
+ documentHandler: i(e, t),
29
+ bindingFn: t.value
31
30
  };
32
- a && a >= 0 ? t == null || t.splice(a, 1, o) : t == null || t.push(o);
31
+ o && o >= 0 ? n?.splice(o, 1, a) : n?.push(a);
33
32
  },
34
33
  unmounted(e) {
35
34
  s.delete(e);
36
35
  }
37
36
  };
38
37
  export {
39
- y as default
38
+ C as default
40
39
  };
@@ -1,3 +1,2 @@
1
1
  import { default as ClickOutside } from './click-outside';
2
-
3
2
  export { ClickOutside };
package/lib/index.js CHANGED
@@ -1,46 +1,49 @@
1
- import { generateId as o, generateString as r, getRandomInt as i, guiID as s } from "./utils/random.js";
2
- import { isArray as n, isClient as m, isDate as d, isElement as g, isEmpty as p, isIp as l, isMobile as f, isNumber as x, isObject as u, isPort as S, isString as b, isStringNumber as k, isUndefined as C } from "./utils/is.js";
1
+ import { generateId as t, generateString as o, getRandomInt as i, guiID as s } from "./utils/random.js";
2
+ import { isArray as n, isClient as m, isDate as g, isElement as p, isEmpty as d, isIp as f, isMobile as l, isNumber as x, isObject as u, isPort as S, isString as b, isStringNumber as k, isUndefined as C } from "./utils/is.js";
3
3
  import { treeFlat as I } from "./utils/tree.js";
4
4
  import { thousandSeparator as y, toFixed as E, toNumber as N } from "./utils/number.js";
5
5
  import { clearStorage as v, getStorage as w, getToken as A, removeStorage as B, removeToken as D, setStorage as L, setToken as O } from "./utils/storage.js";
6
6
  import { deepAssign as h, deepClone as j, deepEqual as q } from "./utils/object.js";
7
7
  import { getParentByClass as R } from "./utils/dom.js";
8
- import { downLoadFile as z, downLoadFiles as G, toBase64 as H } from "./utils/file.js";
9
- import { default as K } from "./directives/click-outside.js";
8
+ import { downLoadFile as _, downLoadFiles as z, toBase64 as G } from "./utils/file.js";
9
+ import { get_rgb as J, mix as K } from "./utils/color.js";
10
+ import { default as V } from "./directives/click-outside.js";
10
11
  export {
11
- K as ClickOutside,
12
+ V as ClickOutside,
12
13
  v as clearStorage,
13
14
  h as deepAssign,
14
15
  j as deepClone,
15
16
  q as deepEqual,
16
- z as downLoadFile,
17
- G as downLoadFiles,
18
- o as generateId,
19
- r as generateString,
17
+ _ as downLoadFile,
18
+ z as downLoadFiles,
19
+ t as generateId,
20
+ o as generateString,
20
21
  R as getParentByClass,
21
22
  i as getRandomInt,
22
23
  w as getStorage,
23
24
  A as getToken,
25
+ J as get_rgb,
24
26
  s as guiID,
25
27
  n as isArray,
26
28
  m as isClient,
27
- d as isDate,
28
- g as isElement,
29
- p as isEmpty,
30
- l as isIp,
31
- f as isMobile,
29
+ g as isDate,
30
+ p as isElement,
31
+ d as isEmpty,
32
+ f as isIp,
33
+ l as isMobile,
32
34
  x as isNumber,
33
35
  u as isObject,
34
36
  S as isPort,
35
37
  b as isString,
36
38
  k as isStringNumber,
37
39
  C as isUndefined,
40
+ K as mix,
38
41
  B as removeStorage,
39
42
  D as removeToken,
40
43
  L as setStorage,
41
44
  O as setToken,
42
45
  y as thousandSeparator,
43
- H as toBase64,
46
+ G as toBase64,
44
47
  E as toFixed,
45
48
  N as toNumber,
46
49
  I as treeFlat
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 过渡颜色生成
3
+ * @param color1
4
+ * @param color2
5
+ * @param weight
6
+ * @returns
7
+ */
8
+ export declare function mix(color1: string, color2: string, weight: number): string;
9
+ /**HEX转成RGB */
10
+ export declare function get_rgb(color: string): string;
@@ -0,0 +1,14 @@
1
+ function M(n, r, t) {
2
+ t = Math.max(Math.min(Number(t), 1), 0);
3
+ let s = parseInt(n.substring(1, 3), 16), u = parseInt(n.substring(3, 5), 16), e = parseInt(n.substring(5, 7), 16), a = parseInt(r.substring(1, 3), 16), b = parseInt(r.substring(3, 5), 16), i = parseInt(r.substring(5, 7), 16), g = Math.round(s * (1 - t) + a * t), p = Math.round(u * (1 - t) + b * t), I = Math.round(e * (1 - t) + i * t);
4
+ return `#${("0" + (g || 0).toString(16)).slice(-2)}${("0" + (p || 0).toString(16)).slice(-2)}${("0" + (I || 0).toString(16)).slice(-2)}`;
5
+ }
6
+ function d(n) {
7
+ return `${Math.round(parseInt(n.substring(1, 3), 16))},${Math.round(
8
+ parseInt(n.substring(3, 5), 16)
9
+ )},${Math.round(parseInt(n.substring(5, 7), 16))}`;
10
+ }
11
+ export {
12
+ d as get_rgb,
13
+ M as mix
14
+ };
@@ -0,0 +1,11 @@
1
+ export {};
2
+ /**
3
+ * 根据当前时间获取指定类型的时间范围
4
+ *
5
+ * 基于dayjs实现,格式必须满足dayjs格式
6
+ * @param type 范围类型 'd' | 'w' | 'M' | 'Q' | 'y' | 'h' | 'm' | 's'
7
+ * @param increment 增量,默认-1
8
+ * @param format 日期时间显示格式
9
+ * @param span 是否跨越范围类型,如当日时间是否过0点,false的话起始时间为0点
10
+ * @return [start-开始日期时间,end-截止日期时间]
11
+ */
package/lib/utils/file.js CHANGED
@@ -1,24 +1,21 @@
1
- function d({ path: n, name: e }) {
1
+ function a({ path: n, name: e }) {
2
2
  const r = document.createElement("a");
3
3
  r.href = n, r.target = "_blank", e && r.setAttribute("download", e), document.body.appendChild(r), r.click(), document.body.removeChild(r);
4
4
  }
5
- function c(n) {
5
+ function d(n) {
6
6
  n.forEach((e) => {
7
- d({ path: e.url, name: e.name });
7
+ a({ path: e.url, name: e.name });
8
8
  });
9
9
  }
10
- async function i(n) {
10
+ async function c(n) {
11
11
  if (!n) return;
12
12
  const e = new FileReader();
13
- return e.readAsDataURL(n), new Promise((r, a) => {
14
- e.onload = (o) => {
15
- var t;
16
- return r((t = o.target) == null ? void 0 : t.result);
17
- }, e.onerror = (o) => a(void 0);
13
+ return e.readAsDataURL(n), new Promise((r, t) => {
14
+ e.onload = (o) => r(o.target?.result), e.onerror = (o) => t(void 0);
18
15
  });
19
16
  }
20
17
  export {
21
- d as downLoadFile,
22
- c as downLoadFiles,
23
- i as toBase64
18
+ a as downLoadFile,
19
+ d as downLoadFiles,
20
+ c as toBase64
24
21
  };
@@ -6,3 +6,4 @@ export * from './storage';
6
6
  export * from './object';
7
7
  export * from './dom';
8
8
  export * from './file';
9
+ export * from './color';
package/lib/utils/is.d.ts CHANGED
@@ -39,9 +39,9 @@ export declare function isElement(e: unknown): e is Element;
39
39
  */
40
40
  export declare const isClient: boolean;
41
41
  /**是否未数值 */
42
- export declare const isNumber: (val: any) => boolean;
42
+ export declare const isNumber: (val: any) => val is number;
43
43
  /**是否为字符串 */
44
- export declare const isString: (val: any) => boolean;
44
+ export declare const isString: (val: any) => val is string;
45
45
  /**是否为字符串数值 */
46
46
  export declare const isStringNumber: (val: string) => boolean;
47
47
  /**是否为手机号(国内手机号) */
@@ -1,65 +1,73 @@
1
- import { isObject as i } from "./is.js";
2
- function c(e) {
3
- const r = Object.prototype.toString;
1
+ import { isObject as c } from "./is.js";
2
+ function f(e) {
3
+ const t = Object.prototype.toString;
4
4
  if (!e || typeof e != "object")
5
5
  return e;
6
6
  if (e.nodeType && "cloneNode" in e)
7
7
  return e.cloneNode(!0);
8
- if (r.call(e) === "[object Date]")
8
+ if (t.call(e) === "[object Date]")
9
9
  return new Date(e.getTime());
10
- if (r.call(e) === "[object RegExp]") {
11
- const t = [];
12
- return e.global && t.push("g"), e.multiline && t.push("m"), e.ignoreCase && t.push("i"), new RegExp(e.source, t.join(""));
10
+ if (t.call(e) === "[object RegExp]") {
11
+ const r = [];
12
+ return e.global && r.push("g"), e.multiline && r.push("m"), e.ignoreCase && r.push("i"), new RegExp(e.source, r.join(""));
13
13
  }
14
- if (r.call(e) === "[object FormData]") {
15
- const t = new FormData();
16
- for (const [o, f] of e.entries())
17
- t.append(o, f);
18
- return t;
14
+ if (t.call(e) === "[object FormData]") {
15
+ const r = new FormData();
16
+ for (const [l, o] of e.entries())
17
+ r.append(l, o);
18
+ return r;
19
19
  }
20
20
  const n = Array.isArray(e) ? [] : e.constructor ? new e.constructor() : {};
21
- for (const t in e)
22
- n[t] = c(e[t]);
21
+ for (const r in e)
22
+ n[r] = f(e[r]);
23
23
  return n;
24
24
  }
25
- function l(...e) {
26
- let r = e.length, n = e[0];
27
- i(n) || (n = {});
28
- for (let t = 1; t < r; t++) {
29
- let o = e[t];
30
- if (i(o))
31
- for (let f in o)
32
- f === "__proto__" || n === o[f] || (i(o[f]) ? n[f] = l(n[f], o[f]) : n[f] = o[f]);
25
+ function s(...e) {
26
+ let t = e.length, n = e[0];
27
+ c(n) || (n = {});
28
+ for (let r = 1; r < t; r++) {
29
+ let l = e[r];
30
+ if (c(l))
31
+ for (let o in l)
32
+ o === "__proto__" || n === l[o] || (c(l[o]) ? n[o] = s(n[o], l[o]) : n[o] = l[o]);
33
33
  }
34
34
  return n;
35
35
  }
36
- function u(e, r) {
37
- if (e === r) return !0;
38
- if (e && r && typeof e == "object" && typeof r == "object") {
39
- if (e.constructor !== r.constructor) return !1;
40
- let n, t, o;
36
+ function i(e, t) {
37
+ if (e === t) return !0;
38
+ if (e && t && typeof e == "object" && typeof t == "object") {
39
+ if (e.constructor !== t.constructor)
40
+ return console.log("对象比较-a.constructor", e.constructor, "对象比较-b.constructor", t.constructor), !1;
41
+ let n, r, l;
41
42
  if (Array.isArray(e)) {
42
- if (n = e.length, n != r.length) return !1;
43
- for (t = n; t-- !== 0; )
44
- if (!u(e[t], r[t])) return !1;
43
+ if (n = e.length, n != t.length)
44
+ return console.log("对象比较-a.length", e.length, "对象比较-b.length", t.length), !1;
45
+ for (r = n; r-- !== 0; )
46
+ if (!i(e[r], t[r]))
47
+ return console.log("对象比较-a[i]", e[r], "对象比较-b[i]", t[r]), !1;
45
48
  return !0;
46
49
  }
47
- if (e.constructor === RegExp) return e.source === r.source && e.flags === r.flags;
48
- if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === r.valueOf();
49
- if (e.toString !== Object.prototype.toString) return e.toString() === r.toString();
50
- if (o = Object.keys(e), n = o.length, n !== Object.keys(r).length) return !1;
51
- for (t = n; t-- !== 0; )
52
- if (!Object.prototype.hasOwnProperty.call(r, o[t])) return !1;
53
- for (t = n; t-- !== 0; ) {
54
- const f = o[t];
55
- if (!u(e[f], r[f])) return !1;
50
+ if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
51
+ if (e.valueOf !== Object.prototype.valueOf)
52
+ return e.valueOf() !== t.valueOf() && console.log("对象比较-a.valueOf()", e.valueOf(), "对象比较-b.valueOf()", e.valueOf()), e.valueOf() === t.valueOf();
53
+ if (e.toString !== Object.prototype.toString)
54
+ return e.toString() === t.toString() && console.log("对象比较-a.toString()", e.toString(), "对象比较-b.toString()", t.toString()), e.toString() === t.toString();
55
+ if (l = Object.keys(e), n = l.length, n !== Object.keys(t).length)
56
+ return console.log("对象比较-Object.keys(a).length", Object.keys(e).length, "对象比较-Object.keys(b).length", Object.keys(t).length), !1;
57
+ for (r = n; r-- !== 0; )
58
+ if (!Object.prototype.hasOwnProperty.call(t, l[r]))
59
+ return console.log("对象比较-keys[i]", l[r], "对象比较-b", t), !1;
60
+ for (r = n; r-- !== 0; ) {
61
+ const o = l[r];
62
+ if (!i(e[o], t[o]))
63
+ return console.log("对象比较-a[key]", e[o], "对象比较-b[key]", t[o]), !1;
56
64
  }
57
65
  return !0;
58
66
  }
59
- return e !== e && r !== r;
67
+ return e !== e && t !== t || console.log("对象比较-a", e, "对象比较-b", t), e !== e && t !== t;
60
68
  }
61
69
  export {
62
- l as deepAssign,
63
- c as deepClone,
64
- u as deepEqual
70
+ s as deepAssign,
71
+ f as deepClone,
72
+ i as deepEqual
65
73
  };
@@ -11,7 +11,7 @@ function n() {
11
11
  return null;
12
12
  }
13
13
  function r(o, e) {
14
- !e && (e = 7 * 24 * 60 * 60 * 1e3) || (e = e * 1e3);
14
+ !e && (e = 10080 * 60 * 1e3) || (e = e * 1e3);
15
15
  const t = { value: o, expirse: (/* @__PURE__ */ new Date()).getTime() + e };
16
16
  localStorage.setItem("token", JSON.stringify(t));
17
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qy_better_lib/core",
3
3
  "private": false,
4
- "version": "0.0.6",
4
+ "version": "0.1.0",
5
5
  "description": "qy better lib core",
6
6
  "author": "luhuiming",
7
7
  "license": "ISC",
@@ -40,11 +40,10 @@
40
40
  "./utils/*": "./lib/utils/*.js"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "^20.14.9",
44
- "@vitejs/plugin-vue": "^5.0.5",
45
- "element-plus": "^2.7.6",
46
- "vite": "^5.3.2",
47
- "vite-plugin-dts": "^3.9.1",
48
- "vue": "^3.4.31"
43
+ "@types/node": "^24.5.2",
44
+ "@vitejs/plugin-vue": "^6.0.1",
45
+ "vite": "^7.1.7",
46
+ "vite-plugin-dts": "^4.5.4",
47
+ "vue": "^3.5.22"
49
48
  }
50
- }
49
+ }