@witlink/components 1.0.22 → 1.0.24
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/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +63 -26
- package/dist/index.js +814 -749
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +56 -56
- package/package.json +18 -11
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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 h(e){return i(e,"Function")}const O=e=>typeof e<"u",b=e=>!O(e),N=e=>e!==null&&i(e,"Object");function v(e){return i(e,"Date")}function k(e){return i(e,"Number")}function F(e){return i(e,"AsyncFunction")}function K(e){return i(e,"Promise")&&h(e.then)&&h(e.catch)}function J(e){return i(e,"String")}function B(e){return i(e,"Boolean")}function R(e){return e&&Array.isArray(e)}const D=()=>typeof window<"u",W=e=>typeof window<"u"&&i(e,"Window"),_=e=>N(e)&&!!e.tagName,Y=typeof window>"u";function x(e){return e&&["IMAGE","IMG"].includes(e.tagName)}function w(e){return e===null}function $(e){return b(e)||w(e)}function G(e,n){if(e&&typeof e=="object"){const o=window.URL.createObjectURL(new Blob([e])),t=document.createElement("a");t.style.display="none",t.href=o,t.setAttribute("download",n),document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(o)}}function E(e,n){e.forEach(o=>{n(o),Array.isArray(o.children)&&E(o.children,n)})}function q(e,n){n=Object.assign({id:"id",parentId:"parentId",children:"children",root:""},n);const{id:o,parentId:t,children:s,root:c}=n,m=JSON.parse(JSON.stringify(e));return m.filter(d=>{const U=m.filter(L=>d[o]===L[t]);return d[s]=U.length>0?U:null,d[t]===c})||e}const C="Witlink-Usercenter-QureyParams";function u(){const e=localStorage.getItem(C)||"{}",{token:n,lang:o,usercenterUrl:t}=JSON.parse(e);return{token:n,lang:o,usercenterUrl:t}}function z(e){const n=u();localStorage.setItem(C,JSON.stringify({...n,...e}))}function Q(){const e=window.location.href,n={},o=e.split("?")[1];return o&&o.split("&").forEach(t=>{const[s,c]=t.split("=");s&&c&&(n[s]=decodeURIComponent(c))}),n}const P="Witlink-Usercenter";function X(){const{usercenterUrl:e}=u();window.location.href=e}function H(){window.open(u().usercenterUrl,P),window.close()}const V="",l="ACCESS_TOKEN",f="locale",I="userInfo",S="menuInfo";function Z(e){const n=new URL(e);return n.hash&&n.hash.startsWith("#/")?`/${n.hash.substring(2).split("?")[0]}`.replace(/\/+/g,"/"):n.pathname}function A(e,n={}){const o=Array.isArray(e)?e:[e];for(const t of o){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&&A(t.children,n)}return n}function r(e){return V+e}function ee(e){localStorage.setItem(r(l),e)}function ne(){return localStorage.getItem(r(l))}function te(){localStorage.removeItem(r(l))}function oe(e){localStorage.setItem(r(f),e)}function re(){return localStorage.getItem(r(f))}function se(){localStorage.removeItem(r(f))}function ie(e={}){e={...p()||{},...e},localStorage.setItem(r(I),JSON.stringify(e))}function p(e){const n=localStorage.getItem(r(I));if(e){if(typeof e=="string")return(n?JSON.parse(n):{})[e]||null;if(Array.isArray(e)){const o=n?JSON.parse(n):{},t={};return e.forEach(s=>{t[s]=o[s]||null}),t}}return n?JSON.parse(n):null}function ce(e){localStorage.setItem(r(S),JSON.stringify(e))}function j(){const e=localStorage.getItem(r(S));return e?JSON.parse(e):null}const g={},a={};function ae(){if(Object.keys(g).length===0){const e=j()||[];A(e,g)}return g}function T(){return Object.keys(a).length===0&&((p()||{}).role.permissions||[]).forEach(o=>{var t;if(o.actionEntitySet!=null&&((t=o.actionEntitySet)==null?void 0:t.length)>0){const s=o.actionEntitySet.map(c=>c.action);a[o.permissionId]=s}}),a}function ue(e){const n=T(),o=Z(window.location.href),t=ae(),s=Object.keys(t||{}).find(y=>o.endsWith(y)),c=t[s]||"";return(n[c]||[]).includes(e)}function le(){localStorage.removeItem(r(I)),localStorage.removeItem(r(S)),localStorage.removeItem(r(l)),localStorage.removeItem(r(f))}exports.UserCenterKey=P;exports.buildTree=q;exports.exportFile=G;exports.forEachTree=E;exports.getButtonPermissions=T;exports.getLocale=re;exports.getMenuInfo=j;exports.getToken=ne;exports.getUserCenterParams=u;exports.getUserCenterParamsByUrl=Q;exports.getUserInfo=p;exports.hasPermission=ue;exports.is=i;exports.isArray=R;exports.isAsyncFunction=F;exports.isBoolean=B;exports.isClient=D;exports.isDate=v;exports.isDef=O;exports.isElement=_;exports.isFunction=h;exports.isImageDom=x;exports.isNull=w;exports.isNullOrUndef=$;exports.isNumber=k;exports.isObject=N;exports.isPromise=K;exports.isServer=Y;exports.isString=J;exports.isUndef=b;exports.isWindow=W;exports.logoutToUserCenter=H;exports.removeAll=le;exports.removeLocale=se;exports.removeToken=te;exports.setLocale=oe;exports.setMenuInfo=ce;exports.setToken=ee;exports.setUserCenterParams=z;exports.setUserInfo=ie;exports.toUserCenterConsole=X;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const N = Object.prototype.toString;
|
|
2
2
|
function i(n, t) {
|
|
3
|
-
return
|
|
3
|
+
return N.call(n) === `[object ${t}]`;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function y(n) {
|
|
6
6
|
return i(n, "Function");
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
function
|
|
8
|
+
const E = (n) => typeof n < "u", A = (n) => !E(n), P = (n) => n !== null && i(n, "Object");
|
|
9
|
+
function R(n) {
|
|
10
10
|
return i(n, "Date");
|
|
11
11
|
}
|
|
12
12
|
function v(n) {
|
|
@@ -16,7 +16,7 @@ function F(n) {
|
|
|
16
16
|
return i(n, "AsyncFunction");
|
|
17
17
|
}
|
|
18
18
|
function W(n) {
|
|
19
|
-
return i(n, "Promise") &&
|
|
19
|
+
return i(n, "Promise") && y(n.then) && y(n.catch);
|
|
20
20
|
}
|
|
21
21
|
function _(n) {
|
|
22
22
|
return i(n, "String");
|
|
@@ -27,15 +27,15 @@ function B(n) {
|
|
|
27
27
|
function D(n) {
|
|
28
28
|
return n && Array.isArray(n);
|
|
29
29
|
}
|
|
30
|
-
const Y = () => typeof window < "u", x = (n) => typeof window < "u" && i(n, "Window"), $ = (n) =>
|
|
30
|
+
const Y = () => typeof window < "u", x = (n) => typeof window < "u" && i(n, "Window"), $ = (n) => P(n) && !!n.tagName, G = typeof window > "u";
|
|
31
31
|
function q(n) {
|
|
32
32
|
return n && ["IMAGE", "IMG"].includes(n.tagName);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function C(n) {
|
|
35
35
|
return n === null;
|
|
36
36
|
}
|
|
37
37
|
function z(n) {
|
|
38
|
-
return
|
|
38
|
+
return A(n) || C(n);
|
|
39
39
|
}
|
|
40
40
|
function Q(n, t) {
|
|
41
41
|
if (n && typeof n == "object") {
|
|
@@ -43,9 +43,9 @@ function Q(n, t) {
|
|
|
43
43
|
e.style.display = "none", e.href = o, e.setAttribute("download", t), document.body.appendChild(e), e.click(), document.body.removeChild(e), window.URL.revokeObjectURL(o);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function j(n, t) {
|
|
47
47
|
n.forEach((o) => {
|
|
48
|
-
t(o), Array.isArray(o.children) &&
|
|
48
|
+
t(o), Array.isArray(o.children) && j(o.children, t);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function X(n, t) {
|
|
@@ -53,21 +53,21 @@ 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,
|
|
57
|
-
return
|
|
58
|
-
const
|
|
59
|
-
return m[s] =
|
|
56
|
+
const { id: o, parentId: e, children: s, root: c } = t, f = JSON.parse(JSON.stringify(n));
|
|
57
|
+
return f.filter((m) => {
|
|
58
|
+
const S = f.filter((w) => m[o] === w[e]);
|
|
59
|
+
return m[s] = S.length > 0 ? S : null, m[e] === c;
|
|
60
60
|
}) || n;
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const O = "Witlink-Usercenter-QureyParams";
|
|
63
63
|
function g() {
|
|
64
|
-
const n = localStorage.getItem(
|
|
64
|
+
const n = localStorage.getItem(O) || "{}", { 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
68
|
const t = g();
|
|
69
69
|
localStorage.setItem(
|
|
70
|
-
|
|
70
|
+
O,
|
|
71
71
|
JSON.stringify({ ...t, ...n })
|
|
72
72
|
);
|
|
73
73
|
}
|
|
@@ -78,55 +78,55 @@ function V() {
|
|
|
78
78
|
s && c && (t[s] = decodeURIComponent(c));
|
|
79
79
|
}), t;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const L = "Witlink-Usercenter";
|
|
82
82
|
function Z() {
|
|
83
83
|
const { usercenterUrl: n } = g();
|
|
84
84
|
window.location.href = n;
|
|
85
85
|
}
|
|
86
86
|
function nn() {
|
|
87
|
-
window.open(g().usercenterUrl,
|
|
87
|
+
window.open(g().usercenterUrl, L), window.close();
|
|
88
88
|
}
|
|
89
|
-
const
|
|
90
|
-
function
|
|
89
|
+
const M = "", a = "ACCESS_TOKEN", l = "locale", h = "userInfo", I = "menuInfo";
|
|
90
|
+
function J(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
|
}
|
|
94
|
-
function
|
|
94
|
+
function U(n, t = {}) {
|
|
95
95
|
const o = Array.isArray(n) ? n : [n];
|
|
96
96
|
for (const e of o) {
|
|
97
97
|
if (e.path && e.name !== void 0) {
|
|
98
98
|
const s = e.path.startsWith("/") ? e.path : `/${e.path}`;
|
|
99
99
|
t[s] = e.name.toString();
|
|
100
100
|
}
|
|
101
|
-
e.children && e.children.length > 0 &&
|
|
101
|
+
e.children && e.children.length > 0 && U(e.children, t);
|
|
102
102
|
}
|
|
103
103
|
return t;
|
|
104
104
|
}
|
|
105
105
|
function r(n) {
|
|
106
|
-
return
|
|
106
|
+
return M + n;
|
|
107
107
|
}
|
|
108
108
|
function tn(n) {
|
|
109
|
-
localStorage.setItem(r(
|
|
109
|
+
localStorage.setItem(r(a), n);
|
|
110
110
|
}
|
|
111
111
|
function en() {
|
|
112
|
-
return localStorage.getItem(r(
|
|
112
|
+
return localStorage.getItem(r(a));
|
|
113
113
|
}
|
|
114
114
|
function on() {
|
|
115
|
-
localStorage.removeItem(r(
|
|
115
|
+
localStorage.removeItem(r(a));
|
|
116
116
|
}
|
|
117
117
|
function rn(n) {
|
|
118
|
-
localStorage.setItem(r(
|
|
118
|
+
localStorage.setItem(r(l), n);
|
|
119
119
|
}
|
|
120
120
|
function sn() {
|
|
121
|
-
return localStorage.getItem(r(
|
|
121
|
+
return localStorage.getItem(r(l));
|
|
122
122
|
}
|
|
123
123
|
function cn() {
|
|
124
|
-
localStorage.removeItem(r(
|
|
124
|
+
localStorage.removeItem(r(l));
|
|
125
125
|
}
|
|
126
126
|
function un(n = {}) {
|
|
127
|
-
n = { ...
|
|
127
|
+
n = { ...b() || {}, ...n }, localStorage.setItem(r(h), JSON.stringify(n));
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function b(n) {
|
|
130
130
|
const t = localStorage.getItem(r(h));
|
|
131
131
|
if (n) {
|
|
132
132
|
if (typeof n == "string")
|
|
@@ -143,65 +143,65 @@ function U(n) {
|
|
|
143
143
|
function an(n) {
|
|
144
144
|
localStorage.setItem(r(I), JSON.stringify(n));
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function K() {
|
|
147
147
|
const n = localStorage.getItem(r(I));
|
|
148
148
|
return n ? JSON.parse(n) : null;
|
|
149
149
|
}
|
|
150
|
-
const d = {},
|
|
151
|
-
function
|
|
150
|
+
const d = {}, u = {};
|
|
151
|
+
function T() {
|
|
152
152
|
if (Object.keys(d).length === 0) {
|
|
153
|
-
const n =
|
|
154
|
-
|
|
153
|
+
const n = K() || [];
|
|
154
|
+
U(n, d);
|
|
155
155
|
}
|
|
156
156
|
return d;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return Object.keys(
|
|
158
|
+
function k() {
|
|
159
|
+
return Object.keys(u).length === 0 && ((b() || {}).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
|
-
|
|
163
|
+
u[o.permissionId] = s;
|
|
164
164
|
}
|
|
165
|
-
}),
|
|
165
|
+
}), u;
|
|
166
166
|
}
|
|
167
167
|
function ln(n) {
|
|
168
|
-
const t =
|
|
169
|
-
return (t[
|
|
168
|
+
const t = k(), o = J(window.location.href), e = T(), s = Object.keys(e || {}).find((p) => o.endsWith(p)), c = e[s] || "";
|
|
169
|
+
return (t[c] || []).includes(n);
|
|
170
170
|
}
|
|
171
171
|
function fn() {
|
|
172
|
-
localStorage.removeItem(r(h)), localStorage.removeItem(r(I)), localStorage.removeItem(r(
|
|
172
|
+
localStorage.removeItem(r(h)), localStorage.removeItem(r(I)), localStorage.removeItem(r(a)), localStorage.removeItem(r(l));
|
|
173
173
|
}
|
|
174
174
|
export {
|
|
175
|
-
|
|
175
|
+
L as UserCenterKey,
|
|
176
176
|
X as buildTree,
|
|
177
177
|
Q as exportFile,
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
j as forEachTree,
|
|
179
|
+
k as getButtonPermissions,
|
|
180
180
|
sn as getLocale,
|
|
181
|
-
|
|
181
|
+
K as getMenuInfo,
|
|
182
182
|
en as getToken,
|
|
183
183
|
g as getUserCenterParams,
|
|
184
184
|
V as getUserCenterParamsByUrl,
|
|
185
|
-
|
|
185
|
+
b as getUserInfo,
|
|
186
186
|
ln as hasPermission,
|
|
187
187
|
i as is,
|
|
188
188
|
D as isArray,
|
|
189
189
|
F as isAsyncFunction,
|
|
190
190
|
B as isBoolean,
|
|
191
191
|
Y as isClient,
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
R as isDate,
|
|
193
|
+
E as isDef,
|
|
194
194
|
$ as isElement,
|
|
195
|
-
|
|
195
|
+
y as isFunction,
|
|
196
196
|
q as isImageDom,
|
|
197
|
-
|
|
197
|
+
C as isNull,
|
|
198
198
|
z as isNullOrUndef,
|
|
199
199
|
v as isNumber,
|
|
200
|
-
|
|
200
|
+
P as isObject,
|
|
201
201
|
W as isPromise,
|
|
202
202
|
G as isServer,
|
|
203
203
|
_ as isString,
|
|
204
|
-
|
|
204
|
+
A as isUndef,
|
|
205
205
|
x as isWindow,
|
|
206
206
|
nn as logoutToUserCenter,
|
|
207
207
|
fn as removeAll,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witlink/components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.24",
|
|
5
5
|
"description": "witlink公共组件库",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"preview": "vite preview",
|
|
29
29
|
"docs:dev": "vitepress dev docs",
|
|
30
30
|
"docs:build": "vitepress build docs",
|
|
31
|
-
"docs:preview": "vitepress preview docs"
|
|
31
|
+
"docs:preview": "vitepress preview docs",
|
|
32
|
+
"lint": "eslint . --fix",
|
|
33
|
+
"format": "prettier --write --experimental-cli src/"
|
|
32
34
|
},
|
|
33
35
|
"peerDependencies": {
|
|
34
36
|
"ant-design-vue": ">=4",
|
|
@@ -37,21 +39,26 @@
|
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@iconify-json/ant-design": "^1.2.5",
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@vitejs/plugin-vue": "^
|
|
42
|
-
"@vue/
|
|
42
|
+
"@types/node": "^24.10.1",
|
|
43
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
44
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
45
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
46
|
+
"@vue/tsconfig": "^0.8.1",
|
|
43
47
|
"@vueuse/core": "^13.0.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
+
"eslint": "^9.39.2",
|
|
49
|
+
"eslint-plugin-vue": "~10.6.2",
|
|
50
|
+
"jiti": "^2.6.1",
|
|
51
|
+
"less": "^4.5.1",
|
|
52
|
+
"prettier": "^3.7.4",
|
|
53
|
+
"rollup-plugin-visualizer": "^6.0.5",
|
|
54
|
+
"typescript": "~5.8.2",
|
|
48
55
|
"unplugin-auto-import": "^19.1.1",
|
|
49
56
|
"unplugin-icons": "^22.1.0",
|
|
50
57
|
"unplugin-vue-components": "^28.4.1",
|
|
51
58
|
"vite": "^6.2.0",
|
|
52
|
-
"vite-plugin-dts": "^4.5.
|
|
59
|
+
"vite-plugin-dts": "^4.5.4",
|
|
53
60
|
"vitepress": "^2.0.0-alpha.5",
|
|
54
61
|
"vue-router": "^4.5.0",
|
|
55
|
-
"vue-tsc": "^
|
|
62
|
+
"vue-tsc": "^3.1.4"
|
|
56
63
|
}
|
|
57
64
|
}
|