@witlink/components 0.0.3 → 1.0.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.
package/dist/utils.cjs ADDED
@@ -0,0 +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;
@@ -0,0 +1,141 @@
1
+ /**
2
+ * 构造树型结构数据
3
+ * @param arr 数据源
4
+ * @param options { id: "id", parentId: "parentId", children: "children", root: "" }
5
+ */
6
+ export declare function buildTree(arr: any, options?: any): any;
7
+
8
+ /**
9
+ * 下载文件
10
+ */
11
+ export declare function exportFile(fileData: any, fileName: string): void;
12
+
13
+ /**
14
+ * 遍历树结构数据
15
+ * @param treeData 树型数据
16
+ * @param fn 回调方法
17
+ */
18
+ export declare function forEachTree<T>(treeData: Array<T>, fn: (item: T) => void): void;
19
+
20
+ export declare function getButtonPermissions(): any;
21
+
22
+ export declare function getLocale(): string | null;
23
+
24
+ export declare function getMenuInfo(): any;
25
+
26
+ export declare function getToken(): string | null;
27
+
28
+ export declare function getUserCenterParams(): UserCenterParams;
29
+
30
+ export declare function getUserCenterParamsByUrl(): Record<string, string>;
31
+
32
+ export declare function getUserInfo(key?: string | Array<string> | null): any;
33
+
34
+ export declare function hasPermission(id: string): boolean;
35
+
36
+ /**
37
+ * @description: 判断值是否未某个类型
38
+ */
39
+ export declare function is(val: unknown, type: string): boolean;
40
+
41
+ /**
42
+ * @description: 是否为数组
43
+ */
44
+ export declare function isArray(val: any): val is Array<any>;
45
+
46
+ /**
47
+ * @description: 是否为AsyncFunction
48
+ */
49
+ export declare function isAsyncFunction<T = any>(val: unknown): val is Promise<T>;
50
+
51
+ /**
52
+ * @description: 是否为boolean类型
53
+ */
54
+ export declare function isBoolean(val: unknown): val is boolean;
55
+
56
+ /**
57
+ * @description: 是否客户端
58
+ */
59
+ export declare const isClient: () => boolean;
60
+
61
+ /**
62
+ * @description: 是否为时间
63
+ */
64
+ export declare function isDate(val: unknown): val is Date;
65
+
66
+ /**
67
+ * @description: 是否已定义
68
+ */
69
+ export declare const isDef: <T = unknown>(val?: T) => val is T;
70
+
71
+ export declare const isElement: (val: unknown) => val is Element;
72
+
73
+ /**
74
+ * @description: 是否为函数
75
+ */
76
+ export declare function isFunction<T = Function>(val: unknown): val is T;
77
+
78
+ export declare function isImageDom(o: Element): boolean;
79
+
80
+ export declare function isNull(val: unknown): val is null;
81
+
82
+ export declare function isNullOrUndef(val: unknown): val is null | undefined;
83
+
84
+ /**
85
+ * @description: 是否为数值
86
+ */
87
+ export declare function isNumber(val: unknown): val is number;
88
+
89
+ /**
90
+ * @description: 是否为对象
91
+ */
92
+ export declare const isObject: (val: any) => val is Record<any, any>;
93
+
94
+ /**
95
+ * @description: 是否为promise
96
+ */
97
+ export declare function isPromise<T = any>(val: any): val is Promise<T>;
98
+
99
+ export declare const isServer: boolean;
100
+
101
+ /**
102
+ * @description: 是否为字符串
103
+ */
104
+ export declare function isString(val: unknown): val is string;
105
+
106
+ export declare const isUndef: <T = unknown>(val?: T) => val is T;
107
+
108
+ /**
109
+ * @description: 是否为浏览器
110
+ */
111
+ export declare const isWindow: (val: any) => val is Window;
112
+
113
+ export declare function logoutToUserCenter(): void;
114
+
115
+ export declare function removeAll(): void;
116
+
117
+ export declare function removeLocale(): void;
118
+
119
+ export declare function removeToken(): void;
120
+
121
+ export declare function setLocale(locale: string): void;
122
+
123
+ export declare function setMenuInfo(menuInfo: any): void;
124
+
125
+ export declare function setToken(token: string): void;
126
+
127
+ export declare function setUserCenterParams(params: UserCenterParams): void;
128
+
129
+ export declare function setUserInfo(userInfo?: any): void;
130
+
131
+ export declare function toUserCenterConsole(): void;
132
+
133
+ export declare const UserCenterKey = "Witlink-Usercenter";
134
+
135
+ export declare type UserCenterParams = {
136
+ token?: string;
137
+ lang?: string;
138
+ usercenterUrl?: string;
139
+ };
140
+
141
+ export { }
package/dist/utils.js ADDED
@@ -0,0 +1,216 @@
1
+ const N = Object.prototype.toString;
2
+ function i(n, t) {
3
+ return N.call(n) === `[object ${t}]`;
4
+ }
5
+ function S(n) {
6
+ return i(n, "Function");
7
+ }
8
+ const b = (n) => typeof n < "u", E = (n) => !b(n), A = (n) => n !== null && i(n, "Object");
9
+ function v(n) {
10
+ return i(n, "Date");
11
+ }
12
+ function F(n) {
13
+ return i(n, "Number");
14
+ }
15
+ function k(n) {
16
+ return i(n, "AsyncFunction");
17
+ }
18
+ function _(n) {
19
+ return i(n, "Promise") && S(n.then) && S(n.catch);
20
+ }
21
+ function B(n) {
22
+ return i(n, "String");
23
+ }
24
+ function W(n) {
25
+ return i(n, "Boolean");
26
+ }
27
+ function D(n) {
28
+ return n && Array.isArray(n);
29
+ }
30
+ const Y = () => typeof window < "u", x = (n) => typeof window < "u" && i(n, "Window"), $ = (n) => A(n) && !!n.tagName, G = typeof window > "u";
31
+ function q(n) {
32
+ return n && ["IMAGE", "IMG"].includes(n.tagName);
33
+ }
34
+ function P(n) {
35
+ return n === null;
36
+ }
37
+ function z(n) {
38
+ return E(n) || P(n);
39
+ }
40
+ function Q(n, t) {
41
+ if (n && typeof n == "object") {
42
+ const o = window.URL.createObjectURL(new Blob([n])), e = document.createElement("a");
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
+ }
45
+ }
46
+ function C(n, t) {
47
+ n.forEach((o) => {
48
+ t(o), Array.isArray(o.children) && C(o.children, t);
49
+ });
50
+ }
51
+ function X(n, t) {
52
+ t = Object.assign(
53
+ { id: "id", parentId: "parentId", children: "children", root: "" },
54
+ t
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;
60
+ }) || n;
61
+ }
62
+ const y = "Witlink-Usercenter-QureyParams";
63
+ function d() {
64
+ const n = localStorage.getItem(y) || "{}", { token: t, lang: o, usercenterUrl: e } = JSON.parse(n);
65
+ return { token: t, lang: o, usercenterUrl: e };
66
+ }
67
+ function H(n) {
68
+ const t = d();
69
+ localStorage.setItem(
70
+ y,
71
+ JSON.stringify({ ...t, ...n })
72
+ );
73
+ }
74
+ function V() {
75
+ const n = window.location.href, t = {}, o = n.split("?")[1];
76
+ return o && o.split("&").forEach((e) => {
77
+ const [s, c] = e.split("=");
78
+ s && c && (t[s] = decodeURIComponent(c));
79
+ }), t;
80
+ }
81
+ const j = "Witlink-Usercenter";
82
+ function Z() {
83
+ const { usercenterUrl: n } = d();
84
+ window.location.href = n;
85
+ }
86
+ function nn() {
87
+ window.open(d().usercenterUrl, j), window.close();
88
+ }
89
+ const M = "", a = "ACCESS_TOKEN", l = "locale", g = "userInfo", h = "menuInfo";
90
+ function L(n) {
91
+ const t = new URL(n);
92
+ return t.hash && t.hash.startsWith("#/") ? `/${t.hash.substring(2).split("?")[0]}`.replace(/\/+/g, "/") : t.pathname;
93
+ }
94
+ function O(n, t = {}) {
95
+ const o = Array.isArray(n) ? n : [n];
96
+ for (const e of o) {
97
+ if (e.path && e.name !== void 0) {
98
+ const s = e.path.startsWith("/") ? e.path : `/${e.path}`;
99
+ t[s] = e.name.toString();
100
+ }
101
+ e.children && e.children.length > 0 && O(e.children, t);
102
+ }
103
+ return t;
104
+ }
105
+ function r(n) {
106
+ return M + n;
107
+ }
108
+ function tn(n) {
109
+ localStorage.setItem(r(a), n);
110
+ }
111
+ function en() {
112
+ return localStorage.getItem(r(a));
113
+ }
114
+ function on() {
115
+ localStorage.removeItem(r(a));
116
+ }
117
+ function rn(n) {
118
+ localStorage.setItem(r(l), n);
119
+ }
120
+ function sn() {
121
+ return localStorage.getItem(r(l));
122
+ }
123
+ function cn() {
124
+ localStorage.removeItem(r(l));
125
+ }
126
+ function un(n = {}) {
127
+ n = { ...U() || {}, ...n }, localStorage.setItem(r(g), JSON.stringify(n));
128
+ }
129
+ function U(n) {
130
+ const t = localStorage.getItem(r(g));
131
+ if (n) {
132
+ if (typeof n == "string")
133
+ return (t ? JSON.parse(t) : {})[n] || null;
134
+ if (Array.isArray(n)) {
135
+ const o = t ? JSON.parse(t) : {}, e = {};
136
+ return n.forEach((s) => {
137
+ e[s] = o[s] || null;
138
+ }), e;
139
+ }
140
+ }
141
+ return t ? JSON.parse(t) : null;
142
+ }
143
+ function an(n) {
144
+ localStorage.setItem(r(h), JSON.stringify(n));
145
+ }
146
+ function J() {
147
+ const n = localStorage.getItem(r(h));
148
+ return n ? JSON.parse(n) : null;
149
+ }
150
+ const m = {}, u = {};
151
+ function K() {
152
+ if (Object.keys(m).length === 0) {
153
+ const n = J() || [];
154
+ O(n, m);
155
+ }
156
+ return m;
157
+ }
158
+ function T() {
159
+ return Object.keys(u).length === 0 && ((U() || {}).role.permissions || []).forEach((o) => {
160
+ var e;
161
+ if (o.actionEntitySet != null && ((e = o.actionEntitySet) == null ? void 0 : e.length) > 0) {
162
+ const s = o.actionEntitySet.map((c) => c.action);
163
+ u[o.permissionId] = s;
164
+ }
165
+ }), u;
166
+ }
167
+ function ln(n) {
168
+ const t = T(), o = L(window.location.href), s = K()[o] || "";
169
+ return (t[s] || []).includes(n);
170
+ }
171
+ function fn() {
172
+ localStorage.removeItem(r(g)), localStorage.removeItem(r(h)), localStorage.removeItem(r(a)), localStorage.removeItem(r(l));
173
+ }
174
+ export {
175
+ j as UserCenterKey,
176
+ X as buildTree,
177
+ Q as exportFile,
178
+ C as forEachTree,
179
+ T as getButtonPermissions,
180
+ sn as getLocale,
181
+ J as getMenuInfo,
182
+ en as getToken,
183
+ d as getUserCenterParams,
184
+ V as getUserCenterParamsByUrl,
185
+ U as getUserInfo,
186
+ ln as hasPermission,
187
+ i as is,
188
+ D as isArray,
189
+ k as isAsyncFunction,
190
+ W as isBoolean,
191
+ Y as isClient,
192
+ v as isDate,
193
+ b as isDef,
194
+ $ as isElement,
195
+ S as isFunction,
196
+ q as isImageDom,
197
+ P as isNull,
198
+ z as isNullOrUndef,
199
+ F as isNumber,
200
+ A as isObject,
201
+ _ as isPromise,
202
+ G as isServer,
203
+ B as isString,
204
+ E as isUndef,
205
+ x as isWindow,
206
+ nn as logoutToUserCenter,
207
+ fn as removeAll,
208
+ cn as removeLocale,
209
+ on as removeToken,
210
+ rn as setLocale,
211
+ an as setMenuInfo,
212
+ tn as setToken,
213
+ H as setUserCenterParams,
214
+ un as setUserInfo,
215
+ Z as toUserCenterConsole
216
+ };
package/package.json CHANGED
@@ -1,48 +1,57 @@
1
1
  {
2
2
  "name": "@witlink/components",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "1.0.0",
5
5
  "description": "witlink公共组件库",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "main": "./dist/components.umd.cjs",
12
- "module": "./dist/components.js",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts",
14
14
  "exports": {
15
15
  ".": {
16
- "import": "./dist/components.js",
17
- "require": "./dist/components.umd.cjs"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
18
  },
19
- "./style.css": "./dist/style.css"
19
+ "./utils": {
20
+ "import": "./dist/utils.js",
21
+ "require": "./dist/utils.cjs"
22
+ },
23
+ "./style.css": "./dist/index.css"
20
24
  },
21
25
  "scripts": {
22
26
  "dev": "vite",
23
- "build": "vue-tsc -noEmit && vite build",
24
- "preview": "vite preview"
27
+ "build": "vue-tsc -b && vite build",
28
+ "preview": "vite preview",
29
+ "docs:dev": "vitepress dev docs",
30
+ "docs:build": "vitepress build docs",
31
+ "docs:preview": "vitepress preview docs"
25
32
  },
26
- "dependencies": {
27
- "bpmn-js": "^17.11.1"
33
+ "peerDependencies": {
34
+ "ant-design-vue": "^4.2.6",
35
+ "element-plus": "^2.8.7",
36
+ "vue": "^3.5.13"
28
37
  },
29
38
  "devDependencies": {
30
- "@iconify-json/ant-design": "^1.2.2",
31
- "@types/node": "^22.8.7",
32
- "@vitejs/plugin-vue": "^5.1.4",
33
- "@vueuse/core": "^11.2.0",
34
- "ant-design-vue": "^4.2.5",
35
- "axios": "^1.7.7",
36
- "less": "^4.2.0",
39
+ "@iconify-json/ant-design": "^1.2.5",
40
+ "@types/node": "^22.13.11",
41
+ "@vitejs/plugin-vue": "^5.2.1",
42
+ "@vue/tsconfig": "^0.7.0",
43
+ "@vueuse/core": "^13.0.0",
44
+ "less": "^4.2.2",
37
45
  "less-loader": "^12.2.0",
38
- "rollup-plugin-visualizer": "^5.12.0",
39
- "typescript": "~5.6.2",
40
- "unplugin-auto-import": "^0.18.3",
41
- "unplugin-icons": "^0.20.0",
42
- "unplugin-vue-components": "^0.27.4",
43
- "vite": "^5.4.10",
44
- "vite-plugin-dts": "^4.3.0",
45
- "vue": "^3.5.12",
46
- "vue-tsc": "^2.1.8"
46
+ "rollup-plugin-visualizer": "^5.14.0",
47
+ "typescript": "~5.7.2",
48
+ "unplugin-auto-import": "^19.1.1",
49
+ "unplugin-icons": "^22.1.0",
50
+ "unplugin-vue-components": "^28.4.1",
51
+ "vite": "^6.2.0",
52
+ "vite-plugin-dts": "^4.5.3",
53
+ "vitepress": "^2.0.0-alpha.5",
54
+ "vue-router": "^4.5.0",
55
+ "vue-tsc": "^2.2.4"
47
56
  }
48
57
  }