@witlink/components 1.0.15 → 1.0.16

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/dist/utils.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=Object.prototype.toString;function i(e,n){return M.call(e)===`[object ${n}]`}function d(e){return i(e,"Function")}const U=e=>typeof e<"u",O=e=>!U(e),b=e=>e!==null&&i(e,"Object");function L(e){return i(e,"Date")}function v(e){return i(e,"Number")}function F(e){return i(e,"AsyncFunction")}function K(e){return i(e,"Promise")&&d(e.then)&&d(e.catch)}function k(e){return i(e,"String")}function J(e){return i(e,"Boolean")}function B(e){return e&&Array.isArray(e)}const R=()=>typeof window<"u",D=e=>typeof window<"u"&&i(e,"Window"),W=e=>b(e)&&!!e.tagName,_=typeof window>"u";function Y(e){return e&&["IMAGE","IMG"].includes(e.tagName)}function N(e){return e===null}function x(e){return O(e)||N(e)}function $(e,n){if(e&&typeof e=="object"){const r=window.URL.createObjectURL(new Blob([e])),t=document.createElement("a");t.style.display="none",t.href=r,t.setAttribute("download",n),document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(r)}}function w(e,n){e.forEach(r=>{n(r),Array.isArray(r.children)&&w(r.children,n)})}function G(e,n){n=Object.assign({id:"id",parentId:"parentId",children:"children",root:""},n);const{id:r,parentId:t,children:s,root:c}=n,p=JSON.parse(JSON.stringify(e));return p.filter(m=>{const y=p.filter(j=>m[r]===j[t]);return m[s]=y.length>0?y:null,m[t]===c})||e}const E="Witlink-Usercenter-QureyParams";function u(){const e=localStorage.getItem(E)||"{}",{token:n,lang:r,usercenterUrl:t}=JSON.parse(e);return{token:n,lang:r,usercenterUrl:t}}function q(e){const n=u();localStorage.setItem(E,JSON.stringify({...n,...e}))}function z(){const e=window.location.href,n={},r=e.split("?")[1];return r&&r.split("&").forEach(t=>{const[s,c]=t.split("=");s&&c&&(n[s]=decodeURIComponent(c))}),n}const C="Witlink-Usercenter";function Q(){const{usercenterUrl:e}=u();window.location.href=e}function X(){window.open(u().usercenterUrl,C),window.close()}const H="",l="ACCESS_TOKEN",f="locale",h="userInfo",I="menuInfo";function V(e){const n=new URL(e);return n.hash&&n.hash.startsWith("#/")?`/${n.hash.substring(2).split("?")[0]}`.replace(/\/+/g,"/"):n.pathname}function P(e,n={}){const r=Array.isArray(e)?e:[e];for(const t of r){if(t.path&&t.name!==void 0){const s=t.path.startsWith("/")?t.path:`/${t.path}`;n[s]=t.name.toString()}t.children&&t.children.length>0&&P(t.children,n)}return n}function o(e){return H+e}function Z(e){localStorage.setItem(o(l),e)}function ee(){return localStorage.getItem(o(l))}function ne(){localStorage.removeItem(o(l))}function te(e){localStorage.setItem(o(f),e)}function re(){return localStorage.getItem(o(f))}function oe(){localStorage.removeItem(o(f))}function se(e={}){e={...S()||{},...e},localStorage.setItem(o(h),JSON.stringify(e))}function S(e){const n=localStorage.getItem(o(h));if(e){if(typeof e=="string")return(n?JSON.parse(n):{})[e]||null;if(Array.isArray(e)){const r=n?JSON.parse(n):{},t={};return e.forEach(s=>{t[s]=r[s]||null}),t}}return n?JSON.parse(n):null}function ie(e){localStorage.setItem(o(I),JSON.stringify(e))}function A(){const e=localStorage.getItem(o(I));return e?JSON.parse(e):null}const g={},a={};function ce(){if(Object.keys(g).length===0){const e=A()||[];P(e,g)}return g}function T(){return Object.keys(a).length===0&&((S()||{}).role.permissions||[]).forEach(r=>{var t;if(r.actionEntitySet!=null&&((t=r.actionEntitySet)==null?void 0:t.length)>0){const s=r.actionEntitySet.map(c=>c.action);a[r.permissionId]=s}}),a}function ae(e){const n=T(),r=V(window.location.href),s=ce()[r]||"";return(n[s]||[]).includes(e)}function ue(){localStorage.removeItem(o(h)),localStorage.removeItem(o(I)),localStorage.removeItem(o(l)),localStorage.removeItem(o(f))}exports.UserCenterKey=C;exports.buildTree=G;exports.exportFile=$;exports.forEachTree=w;exports.getButtonPermissions=T;exports.getLocale=re;exports.getMenuInfo=A;exports.getToken=ee;exports.getUserCenterParams=u;exports.getUserCenterParamsByUrl=z;exports.getUserInfo=S;exports.hasPermission=ae;exports.is=i;exports.isArray=B;exports.isAsyncFunction=F;exports.isBoolean=J;exports.isClient=R;exports.isDate=L;exports.isDef=U;exports.isElement=W;exports.isFunction=d;exports.isImageDom=Y;exports.isNull=N;exports.isNullOrUndef=x;exports.isNumber=v;exports.isObject=b;exports.isPromise=K;exports.isServer=_;exports.isString=k;exports.isUndef=O;exports.isWindow=D;exports.logoutToUserCenter=X;exports.removeAll=ue;exports.removeLocale=oe;exports.removeToken=ne;exports.setLocale=te;exports.setMenuInfo=ie;exports.setToken=Z;exports.setUserCenterParams=q;exports.setUserInfo=se;exports.toUserCenterConsole=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=Object.prototype.toString;function i(e,n){return L.call(e)===`[object ${n}]`}function h(e){return i(e,"Function")}const U=e=>typeof e<"u",O=e=>!U(e),b=e=>e!==null&&i(e,"Object");function M(e){return i(e,"Date")}function v(e){return i(e,"Number")}function k(e){return i(e,"AsyncFunction")}function F(e){return i(e,"Promise")&&h(e.then)&&h(e.catch)}function K(e){return i(e,"String")}function J(e){return i(e,"Boolean")}function B(e){return e&&Array.isArray(e)}const R=()=>typeof window<"u",D=e=>typeof window<"u"&&i(e,"Window"),W=e=>b(e)&&!!e.tagName,_=typeof window>"u";function Y(e){return e&&["IMAGE","IMG"].includes(e.tagName)}function N(e){return e===null}function x(e){return O(e)||N(e)}function $(e,n){if(e&&typeof e=="object"){const r=window.URL.createObjectURL(new Blob([e])),t=document.createElement("a");t.style.display="none",t.href=r,t.setAttribute("download",n),document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(r)}}function w(e,n){e.forEach(r=>{n(r),Array.isArray(r.children)&&w(r.children,n)})}function G(e,n){n=Object.assign({id:"id",parentId:"parentId",children:"children",root:""},n);const{id:r,parentId:t,children:s,root:c}=n,a=JSON.parse(JSON.stringify(e));return a.filter(d=>{const y=a.filter(T=>d[r]===T[t]);return d[s]=y.length>0?y:null,d[t]===c})||e}const E="Witlink-Usercenter-QureyParams";function l(){const e=localStorage.getItem(E)||"{}",{token:n,lang:r,usercenterUrl:t}=JSON.parse(e);return{token:n,lang:r,usercenterUrl:t}}function q(e){const n=l();localStorage.setItem(E,JSON.stringify({...n,...e}))}function z(){const e=window.location.href,n={},r=e.split("?")[1];return r&&r.split("&").forEach(t=>{const[s,c]=t.split("=");s&&c&&(n[s]=decodeURIComponent(c))}),n}const C="Witlink-Usercenter";function Q(){const{usercenterUrl:e}=l();window.location.href=e}function X(){window.open(l().usercenterUrl,C),window.close()}const H="",f="ACCESS_TOKEN",m="locale",I="userInfo",S="menuInfo";function V(e){const n=new URL(e);return n.hash&&n.hash.startsWith("#/")?`/${n.hash.substring(2).split("?")[0]}`.replace(/\/+/g,"/"):n.pathname}function P(e,n={}){const r=Array.isArray(e)?e:[e];for(const t of r){if(t.path&&t.name!==void 0){const s=t.path.startsWith("/")?t.path:`/${t.path}`;n[s]=t.name.toString()}t.children&&t.children.length>0&&P(t.children,n)}return n}function o(e){return H+e}function Z(e){localStorage.setItem(o(f),e)}function ee(){return localStorage.getItem(o(f))}function ne(){localStorage.removeItem(o(f))}function te(e){localStorage.setItem(o(m),e)}function re(){return localStorage.getItem(o(m))}function oe(){localStorage.removeItem(o(m))}function se(e={}){e={...p()||{},...e},localStorage.setItem(o(I),JSON.stringify(e))}function p(e){const n=localStorage.getItem(o(I));if(e){if(typeof e=="string")return(n?JSON.parse(n):{})[e]||null;if(Array.isArray(e)){const r=n?JSON.parse(n):{},t={};return e.forEach(s=>{t[s]=r[s]||null}),t}}return n?JSON.parse(n):null}function ie(e){localStorage.setItem(o(S),JSON.stringify(e))}function A(){const e=localStorage.getItem(o(S));return e?JSON.parse(e):null}const g={},u={};function ce(){if(Object.keys(g).length===0){const e=A()||[];P(e,g)}return g}function j(){return Object.keys(u).length===0&&((p()||{}).role.permissions||[]).forEach(r=>{var t;if(r.actionEntitySet!=null&&((t=r.actionEntitySet)==null?void 0:t.length)>0){const s=r.actionEntitySet.map(c=>c.action);u[r.permissionId]=s}}),u}function ae(e){const n=j(),r=V(window.location.href),t=ce(),s=t[Object.keys(t||{}).find(a=>r.endsWith(a))]||"";return(n[s]||[]).includes(e)}function ue(){localStorage.removeItem(o(I)),localStorage.removeItem(o(S)),localStorage.removeItem(o(f)),localStorage.removeItem(o(m))}exports.UserCenterKey=C;exports.buildTree=G;exports.exportFile=$;exports.forEachTree=w;exports.getButtonPermissions=j;exports.getLocale=re;exports.getMenuInfo=A;exports.getToken=ee;exports.getUserCenterParams=l;exports.getUserCenterParamsByUrl=z;exports.getUserInfo=p;exports.hasPermission=ae;exports.is=i;exports.isArray=B;exports.isAsyncFunction=k;exports.isBoolean=J;exports.isClient=R;exports.isDate=M;exports.isDef=U;exports.isElement=W;exports.isFunction=h;exports.isImageDom=Y;exports.isNull=N;exports.isNullOrUndef=x;exports.isNumber=v;exports.isObject=b;exports.isPromise=F;exports.isServer=_;exports.isString=K;exports.isUndef=O;exports.isWindow=D;exports.logoutToUserCenter=X;exports.removeAll=ue;exports.removeLocale=oe;exports.removeToken=ne;exports.setLocale=te;exports.setMenuInfo=ie;exports.setToken=Z;exports.setUserCenterParams=q;exports.setUserInfo=se;exports.toUserCenterConsole=Q;
package/dist/utils.js CHANGED
@@ -1,27 +1,27 @@
1
- const N = Object.prototype.toString;
1
+ const w = Object.prototype.toString;
2
2
  function i(n, t) {
3
- return N.call(n) === `[object ${t}]`;
3
+ return w.call(n) === `[object ${t}]`;
4
4
  }
5
5
  function S(n) {
6
6
  return i(n, "Function");
7
7
  }
8
- const b = (n) => typeof n < "u", E = (n) => !b(n), A = (n) => n !== null && i(n, "Object");
9
- function v(n) {
8
+ const N = (n) => typeof n < "u", E = (n) => !N(n), A = (n) => n !== null && i(n, "Object");
9
+ function k(n) {
10
10
  return i(n, "Date");
11
11
  }
12
- function F(n) {
12
+ function v(n) {
13
13
  return i(n, "Number");
14
14
  }
15
- function k(n) {
15
+ function F(n) {
16
16
  return i(n, "AsyncFunction");
17
17
  }
18
- function _(n) {
18
+ function W(n) {
19
19
  return i(n, "Promise") && S(n.then) && S(n.catch);
20
20
  }
21
- function B(n) {
21
+ function _(n) {
22
22
  return i(n, "String");
23
23
  }
24
- function W(n) {
24
+ function B(n) {
25
25
  return i(n, "Boolean");
26
26
  }
27
27
  function D(n) {
@@ -53,19 +53,19 @@ function X(n, t) {
53
53
  { id: "id", parentId: "parentId", children: "children", root: "" },
54
54
  t
55
55
  );
56
- const { id: o, parentId: e, children: s, root: c } = t, p = JSON.parse(JSON.stringify(n));
57
- return p.filter((f) => {
58
- const I = p.filter((w) => f[o] === w[e]);
59
- return f[s] = I.length > 0 ? I : null, f[e] === c;
56
+ const { id: o, parentId: e, children: s, root: c } = t, u = JSON.parse(JSON.stringify(n));
57
+ return u.filter((m) => {
58
+ const p = u.filter((b) => m[o] === b[e]);
59
+ return m[s] = p.length > 0 ? p : null, m[e] === c;
60
60
  }) || n;
61
61
  }
62
62
  const y = "Witlink-Usercenter-QureyParams";
63
- function d() {
63
+ function g() {
64
64
  const n = localStorage.getItem(y) || "{}", { token: t, lang: o, usercenterUrl: e } = JSON.parse(n);
65
65
  return { token: t, lang: o, usercenterUrl: e };
66
66
  }
67
67
  function H(n) {
68
- const t = d();
68
+ const t = g();
69
69
  localStorage.setItem(
70
70
  y,
71
71
  JSON.stringify({ ...t, ...n })
@@ -80,14 +80,14 @@ function V() {
80
80
  }
81
81
  const j = "Witlink-Usercenter";
82
82
  function Z() {
83
- const { usercenterUrl: n } = d();
83
+ const { usercenterUrl: n } = g();
84
84
  window.location.href = n;
85
85
  }
86
86
  function nn() {
87
- window.open(d().usercenterUrl, j), window.close();
87
+ window.open(g().usercenterUrl, j), window.close();
88
88
  }
89
- const M = "", a = "ACCESS_TOKEN", l = "locale", g = "userInfo", h = "menuInfo";
90
- function L(n) {
89
+ const L = "", l = "ACCESS_TOKEN", f = "locale", h = "userInfo", I = "menuInfo";
90
+ function M(n) {
91
91
  const t = new URL(n);
92
92
  return t.hash && t.hash.startsWith("#/") ? `/${t.hash.substring(2).split("?")[0]}`.replace(/\/+/g, "/") : t.pathname;
93
93
  }
@@ -103,31 +103,31 @@ function O(n, t = {}) {
103
103
  return t;
104
104
  }
105
105
  function r(n) {
106
- return M + n;
106
+ return L + n;
107
107
  }
108
108
  function tn(n) {
109
- localStorage.setItem(r(a), n);
109
+ localStorage.setItem(r(l), n);
110
110
  }
111
111
  function en() {
112
- return localStorage.getItem(r(a));
112
+ return localStorage.getItem(r(l));
113
113
  }
114
114
  function on() {
115
- localStorage.removeItem(r(a));
115
+ localStorage.removeItem(r(l));
116
116
  }
117
117
  function rn(n) {
118
- localStorage.setItem(r(l), n);
118
+ localStorage.setItem(r(f), n);
119
119
  }
120
120
  function sn() {
121
- return localStorage.getItem(r(l));
121
+ return localStorage.getItem(r(f));
122
122
  }
123
123
  function cn() {
124
- localStorage.removeItem(r(l));
124
+ localStorage.removeItem(r(f));
125
125
  }
126
126
  function un(n = {}) {
127
- n = { ...U() || {}, ...n }, localStorage.setItem(r(g), JSON.stringify(n));
127
+ n = { ...U() || {}, ...n }, localStorage.setItem(r(h), JSON.stringify(n));
128
128
  }
129
129
  function U(n) {
130
- const t = localStorage.getItem(r(g));
130
+ const t = localStorage.getItem(r(h));
131
131
  if (n) {
132
132
  if (typeof n == "string")
133
133
  return (t ? JSON.parse(t) : {})[n] || null;
@@ -141,35 +141,35 @@ function U(n) {
141
141
  return t ? JSON.parse(t) : null;
142
142
  }
143
143
  function an(n) {
144
- localStorage.setItem(r(h), JSON.stringify(n));
144
+ localStorage.setItem(r(I), JSON.stringify(n));
145
145
  }
146
146
  function J() {
147
- const n = localStorage.getItem(r(h));
147
+ const n = localStorage.getItem(r(I));
148
148
  return n ? JSON.parse(n) : null;
149
149
  }
150
- const m = {}, u = {};
150
+ const d = {}, a = {};
151
151
  function K() {
152
- if (Object.keys(m).length === 0) {
152
+ if (Object.keys(d).length === 0) {
153
153
  const n = J() || [];
154
- O(n, m);
154
+ O(n, d);
155
155
  }
156
- return m;
156
+ return d;
157
157
  }
158
158
  function T() {
159
- return Object.keys(u).length === 0 && ((U() || {}).role.permissions || []).forEach((o) => {
159
+ return Object.keys(a).length === 0 && ((U() || {}).role.permissions || []).forEach((o) => {
160
160
  var e;
161
161
  if (o.actionEntitySet != null && ((e = o.actionEntitySet) == null ? void 0 : e.length) > 0) {
162
162
  const s = o.actionEntitySet.map((c) => c.action);
163
- u[o.permissionId] = s;
163
+ a[o.permissionId] = s;
164
164
  }
165
- }), u;
165
+ }), a;
166
166
  }
167
167
  function ln(n) {
168
- const t = T(), o = L(window.location.href), s = K()[o] || "";
168
+ const t = T(), o = M(window.location.href), e = K(), s = e[Object.keys(e || {}).find((u) => o.endsWith(u))] || "";
169
169
  return (t[s] || []).includes(n);
170
170
  }
171
171
  function fn() {
172
- localStorage.removeItem(r(g)), localStorage.removeItem(r(h)), localStorage.removeItem(r(a)), localStorage.removeItem(r(l));
172
+ localStorage.removeItem(r(h)), localStorage.removeItem(r(I)), localStorage.removeItem(r(l)), localStorage.removeItem(r(f));
173
173
  }
174
174
  export {
175
175
  j as UserCenterKey,
@@ -180,27 +180,27 @@ export {
180
180
  sn as getLocale,
181
181
  J as getMenuInfo,
182
182
  en as getToken,
183
- d as getUserCenterParams,
183
+ g as getUserCenterParams,
184
184
  V as getUserCenterParamsByUrl,
185
185
  U as getUserInfo,
186
186
  ln as hasPermission,
187
187
  i as is,
188
188
  D as isArray,
189
- k as isAsyncFunction,
190
- W as isBoolean,
189
+ F as isAsyncFunction,
190
+ B as isBoolean,
191
191
  Y as isClient,
192
- v as isDate,
193
- b as isDef,
192
+ k as isDate,
193
+ N as isDef,
194
194
  $ as isElement,
195
195
  S as isFunction,
196
196
  q as isImageDom,
197
197
  P as isNull,
198
198
  z as isNullOrUndef,
199
- F as isNumber,
199
+ v as isNumber,
200
200
  A as isObject,
201
- _ as isPromise,
201
+ W as isPromise,
202
202
  G as isServer,
203
- B as isString,
203
+ _ as isString,
204
204
  E as isUndef,
205
205
  x as isWindow,
206
206
  nn as logoutToUserCenter,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witlink/components",
3
3
  "private": false,
4
- "version": "1.0.15",
4
+ "version": "1.0.16",
5
5
  "description": "witlink公共组件库",
6
6
  "license": "MIT",
7
7
  "type": "module",