@witlink/components 0.0.2 → 0.0.4
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/README.md +30 -3
- package/dist/index.css +1 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.js +136 -0
- package/dist/utils.d.ts +130 -0
- package/dist/utils.js +199 -0
- package/package.json +28 -24
- package/dist/components.js +0 -43578
- package/dist/components.umd.cjs +0 -401
- package/dist/style.css +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
## @witlink/components 库介绍
|
|
2
|
+
> Witlink公共组件库,仅包含与业务无关的组件、指令、勾子、工具方法等。持续完善中。。。
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
### 如何使用@witlink/components
|
|
5
|
+
##### 1. 安装@witlink/components
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install @witlink/components
|
|
9
|
+
```
|
|
10
|
+
##### 2. 使用@witlink/components
|
|
11
|
+
|
|
12
|
+
+ 全局引入
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import WitlinkComponents from '@witlink/components'
|
|
16
|
+
|
|
17
|
+
const app = createApp(App)
|
|
18
|
+
app.use(WitlinkComponents)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
+ 按需引入
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { WlSplitter, permission, useComponentRef, useRequire, isNullOrUndef, exportFile } from '@witlink/components'
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
+ 工具类方法也可以从utils目录引入
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { isNullOrUndef, exportFile } from '@witlink/components/utils'
|
|
31
|
+
|
|
32
|
+
```
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.m-xs{margin:4px}.p-xs{padding:4px}.mt-xs{margin-top:4px}.mr-xs{margin-right:4px}.mb-xs{margin-bottom:4px}.ml-xs{margin-left:4px}.mx-xs{margin-left:4px;margin-right:4px}.my-xs{margin-top:4px;margin-bottom:4px}.pt-xs{padding-top:4px}.pr-xs{padding-right:4px}.pb-xs{padding-bottom:4px}.pl-xs{padding-left:4px}.px-xs{padding-left:4px;padding-right:4px}.py-xs{padding-top:4px;padding-bottom:4px}.br-xs{border-radius:4px}.brtl-xs{border-top-left-radius:4px}.brtr-xs{border-top-right-radius:4px}.brbl-xs{border-bottom-left-radius:4px}.brbr-xs{border-bottom-right-radius:4px}.m-sm{margin:8px}.p-sm{padding:8px}.mt-sm{margin-top:8px}.mr-sm{margin-right:8px}.mb-sm{margin-bottom:8px}.ml-sm{margin-left:8px}.mx-sm{margin-left:8px;margin-right:8px}.my-sm{margin-top:8px;margin-bottom:8px}.pt-sm{padding-top:8px}.pr-sm{padding-right:8px}.pb-sm{padding-bottom:8px}.pl-sm{padding-left:8px}.px-sm{padding-left:8px;padding-right:8px}.py-sm{padding-top:8px;padding-bottom:8px}.br-sm{border-radius:8px}.brtl-sm{border-top-left-radius:8px}.brtr-sm{border-top-right-radius:8px}.brbl-sm{border-bottom-left-radius:8px}.brbr-sm{border-bottom-right-radius:8px}.m-nm{margin:16px}.p-nm{padding:16px}.mt-nm{margin-top:16px}.mr-nm{margin-right:16px}.mb-nm{margin-bottom:16px}.ml-nm{margin-left:16px}.mx-nm{margin-left:16px;margin-right:16px}.my-nm{margin-top:16px;margin-bottom:16px}.pt-nm{padding-top:16px}.pr-nm{padding-right:16px}.pb-nm{padding-bottom:16px}.pl-nm{padding-left:16px}.px-nm{padding-left:16px;padding-right:16px}.py-nm{padding-top:16px;padding-bottom:16px}.br-nm{border-radius:16px}.brtl-nm{border-top-left-radius:16px}.brtr-nm{border-top-right-radius:16px}.brbl-nm{border-bottom-left-radius:16px}.brbr-nm{border-bottom-right-radius:16px}.m-lg{margin:24px}.p-lg{padding:24px}.mt-lg{margin-top:24px}.mr-lg{margin-right:24px}.mb-lg{margin-bottom:24px}.ml-lg{margin-left:24px}.mx-lg{margin-left:24px;margin-right:24px}.my-lg{margin-top:24px;margin-bottom:24px}.pt-lg{padding-top:24px}.pr-lg{padding-right:24px}.pb-lg{padding-bottom:24px}.pl-lg{padding-left:24px}.px-lg{padding-left:24px;padding-right:24px}.py-lg{padding-top:24px;padding-bottom:24px}.br-lg{border-radius:24px}.brtl-lg{border-top-left-radius:24px}.brtr-lg{border-top-right-radius:24px}.brbl-lg{border-bottom-left-radius:24px}.brbr-lg{border-bottom-right-radius:24px}.m-auto{margin:auto}.p-auto{padding:auto}.mt-auto{margin-top:auto}.mr-auto{margin-right:auto}.mb-auto{margin-bottom:auto}.ml-auto{margin-left:auto}.mx-auto{margin-left:auto;margin-right:auto}.my-auto{margin-top:auto;margin-bottom:auto}.pt-auto{padding-top:auto}.pr-auto{padding-right:auto}.pb-auto{padding-bottom:auto}.pl-auto{padding-left:auto}.px-auto{padding-left:auto;padding-right:auto}.py-auto{padding-top:auto;padding-bottom:auto}.br-auto{border-radius:auto}.brtl-auto{border-top-left-radius:auto}.brtr-auto{border-top-right-radius:auto}.brbl-auto{border-bottom-left-radius:auto}.brbr-auto{border-bottom-right-radius:auto}.b-none{border:none}.bl-none{border-left:none}.br-none{border-right:none}.bt-none{border-top:none}.bb-none{border-bottom:none}.b-none-important{border:none!important}.bl-none-important{border-left:none!important}.br-none-important{border-right:none!important}.bt-none-important{border-top:none!important}.bb-none-important{border-bottom:none!important}.position-r{position:relative}.position-a{position:absolute}.position-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.float-left{float:left}.float-right{float:right}.clearfix{zoom:1}.clearfix:after{display:table;clear:both;content:""}.ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.ellipsis-2{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}.width-100{width:100%}.max-width-100{max-width:100%}.pointer{cursor:pointer}.pointer-none{pointer-events:none}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.text-underline{text-decoration:underline}.nowrap{white-space:nowrap}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.flex{display:flex}.flex-1{flex:1}.flex-auto{flex:auto}.flex-none{flex:none}.flex-sc{display:flex;justify-content:flex-start;align-items:center}.flex-ac{display:flex;justify-content:space-around;align-items:center}.flex-bc{display:flex;justify-content:space-between;align-items:center}.flex-cc{display:flex;justify-content:center;align-items:center}.flex-evenly{display:flex;justify-content:space-evenly;align-items:center}.flex-ce{display:flex;justify-content:center;align-items:flex-end}.flex-cs{display:flex;justify-content:center;align-items:flex-start}.flex-ec{display:flex;justify-content:flex-end;align-items:center}.flex-wrap{flex-flow:wrap}.flex-column{flex-direction:column}.font-bold{font-weight:700}::-webkit-scrollbar{width:5px;height:8px}::-webkit-scrollbar-thumb{background-color:#aaaaaa69;border-radius:6px}::-webkit-scrollbar-track{background-color:transparent;transition:background-color .2s linear,width .2s ease-in-out}::-webkit-scrollbar-corner{background-color:#0000}.icon{display:inline-block;width:16px;height:16px;vertical-align:-3px}.icon.icon-sm{width:14px;height:14px}.icon:focus{outline:none}.icon.icon-lg{width:20px;height:20px}.icon.icon-xl{width:24px;height:24px}.icon.icon-xxl{width:32px;height:32px}.icon.icon-xxxl{width:48px;height:48px}.splitter[data-v-385ad393]{width:100%;height:100%;display:flex;flex-direction:row}.my-left[data-v-385ad393],.my-right[data-v-385ad393]{height:100%;z-index:1}.my-spliter[data-v-385ad393]{cursor:col-resize;position:relative;z-index:2;-webkit-user-select:none;user-select:none}.my-spliter[data-v-385ad393]:before{content:"";position:absolute;top:50%;left:50%;width:2px;height:100%;transform:translate(-50%,-50%);background-color:#0000000a}.my-spliter[data-v-385ad393]:after{content:"";position:absolute;top:50%;left:50%;width:2px;height:30px;transform:translate(-50%,-50%);background-color:#00000026}.my-spliter[data-v-385ad393]:hover:before{background-color:#00000026}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { DefineComponent } from 'vue';
|
|
5
|
+
import { ObjectDirective } from 'vue';
|
|
6
|
+
import { PublicProps } from 'vue';
|
|
7
|
+
|
|
8
|
+
declare const __VLS_component: DefineComponent<globalThis.ExtractPropTypes<{
|
|
9
|
+
leftMin: {
|
|
10
|
+
type: NumberConstructor;
|
|
11
|
+
default: number;
|
|
12
|
+
};
|
|
13
|
+
leftMax: {
|
|
14
|
+
type: NumberConstructor;
|
|
15
|
+
default: number;
|
|
16
|
+
};
|
|
17
|
+
}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
18
|
+
leftMin: {
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
leftMax: {
|
|
23
|
+
type: NumberConstructor;
|
|
24
|
+
default: number;
|
|
25
|
+
};
|
|
26
|
+
}>> & Readonly<{}>, {
|
|
27
|
+
leftMin: number;
|
|
28
|
+
leftMax: number;
|
|
29
|
+
}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
30
|
+
container: HTMLDivElement;
|
|
31
|
+
spliter: HTMLDivElement;
|
|
32
|
+
}, HTMLDivElement>;
|
|
33
|
+
|
|
34
|
+
declare function __VLS_template(): {
|
|
35
|
+
attrs: Partial<{}>;
|
|
36
|
+
slots: {
|
|
37
|
+
left?(_: {}): any;
|
|
38
|
+
right?(_: {}): any;
|
|
39
|
+
};
|
|
40
|
+
refs: {
|
|
41
|
+
container: HTMLDivElement;
|
|
42
|
+
spliter: HTMLDivElement;
|
|
43
|
+
};
|
|
44
|
+
rootEl: HTMLDivElement;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
48
|
+
|
|
49
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
50
|
+
new (): {
|
|
51
|
+
$slots: S;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare const _default: {
|
|
56
|
+
install: typeof install;
|
|
57
|
+
};
|
|
58
|
+
export default _default;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 下载文件
|
|
62
|
+
*/
|
|
63
|
+
export declare function exportFile(options: {
|
|
64
|
+
fileData: any;
|
|
65
|
+
name: string;
|
|
66
|
+
}): void;
|
|
67
|
+
|
|
68
|
+
export declare function getButtonPermissions(): any;
|
|
69
|
+
|
|
70
|
+
export declare function getLocale(): string | null;
|
|
71
|
+
|
|
72
|
+
export declare function getMenuInfo(): any;
|
|
73
|
+
|
|
74
|
+
export declare function getToken(): string | null;
|
|
75
|
+
|
|
76
|
+
export declare function getUserCenterParams(): UserCenterParams;
|
|
77
|
+
|
|
78
|
+
export declare function getUserCenterParamsByUrl(): Record<string, string>;
|
|
79
|
+
|
|
80
|
+
export declare function getUserInfo(key?: string | Array<string> | null): any;
|
|
81
|
+
|
|
82
|
+
export declare function hasPermission(id: string): boolean;
|
|
83
|
+
|
|
84
|
+
declare function install(app: App): void;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @description: 判断值是否未某个类型
|
|
88
|
+
*/
|
|
89
|
+
export declare function is(val: unknown, type: string): boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @description: 是否为数组
|
|
93
|
+
*/
|
|
94
|
+
export declare function isArray(val: any): val is Array<any>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @description: 是否为AsyncFunction
|
|
98
|
+
*/
|
|
99
|
+
export declare function isAsyncFunction<T = any>(val: unknown): val is Promise<T>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @description: 是否为boolean类型
|
|
103
|
+
*/
|
|
104
|
+
export declare function isBoolean(val: unknown): val is boolean;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @description: 是否客户端
|
|
108
|
+
*/
|
|
109
|
+
export declare const isClient: () => boolean;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @description: 是否为时间
|
|
113
|
+
*/
|
|
114
|
+
export declare function isDate(val: unknown): val is Date;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @description: 是否已定义
|
|
118
|
+
*/
|
|
119
|
+
export declare const isDef: <T = unknown>(val?: T) => val is T;
|
|
120
|
+
|
|
121
|
+
export declare const isElement: (val: unknown) => val is Element;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @description: 是否为函数
|
|
125
|
+
*/
|
|
126
|
+
export declare function isFunction<T = Function>(val: unknown): val is T;
|
|
127
|
+
|
|
128
|
+
export declare function isImageDom(o: Element): boolean;
|
|
129
|
+
|
|
130
|
+
export declare function isNull(val: unknown): val is null;
|
|
131
|
+
|
|
132
|
+
export declare function isNullOrUndef(val: unknown): val is null | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @description: 是否为数值
|
|
136
|
+
*/
|
|
137
|
+
export declare function isNumber(val: unknown): val is number;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @description: 是否为对象
|
|
141
|
+
*/
|
|
142
|
+
export declare const isObject: (val: any) => val is Record<any, any>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @description: 是否为promise
|
|
146
|
+
*/
|
|
147
|
+
export declare function isPromise<T = any>(val: any): val is Promise<T>;
|
|
148
|
+
|
|
149
|
+
export declare const isServer: boolean;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @description: 是否为字符串
|
|
153
|
+
*/
|
|
154
|
+
export declare function isString(val: unknown): val is string;
|
|
155
|
+
|
|
156
|
+
export declare const isUndef: <T = unknown>(val?: T) => val is T;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @description: 是否为浏览器
|
|
160
|
+
*/
|
|
161
|
+
export declare const isWindow: (val: any) => val is Window;
|
|
162
|
+
|
|
163
|
+
export declare function logoutToUserCenter(): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 按钮级权限控制指令
|
|
167
|
+
*/
|
|
168
|
+
export declare const permission: ObjectDirective;
|
|
169
|
+
|
|
170
|
+
export declare function removeAll(): void;
|
|
171
|
+
|
|
172
|
+
export declare function removeLocale(): void;
|
|
173
|
+
|
|
174
|
+
export declare function removeToken(): void;
|
|
175
|
+
|
|
176
|
+
export declare function setLocale(locale: string): void;
|
|
177
|
+
|
|
178
|
+
export declare function setMenuInfo(menuInfo: any): void;
|
|
179
|
+
|
|
180
|
+
export declare function setToken(token: string): void;
|
|
181
|
+
|
|
182
|
+
export declare function setUserCenterParams(params: UserCenterParams): void;
|
|
183
|
+
|
|
184
|
+
export declare function setUserInfo(userInfo?: any): void;
|
|
185
|
+
|
|
186
|
+
export declare function toUserCenterConsole(): void;
|
|
187
|
+
|
|
188
|
+
export declare const UserCenterKey = "Witlink-Usercenter";
|
|
189
|
+
|
|
190
|
+
export declare type UserCenterParams = {
|
|
191
|
+
token?: string;
|
|
192
|
+
lang?: string;
|
|
193
|
+
usercenterUrl?: string;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export declare const WlSplitter: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
197
|
+
|
|
198
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { defineComponent as x, ref as c, onMounted as C, onUnmounted as E, createElementBlock as L, openBlock as O, createElementVNode as m, normalizeStyle as _, unref as h, renderSlot as S } from "vue";
|
|
2
|
+
import { hasPermission as P } from "./utils.js";
|
|
3
|
+
import { UserCenterKey as z, exportFile as X, getButtonPermissions as A, getLocale as R, getMenuInfo as Y, getToken as K, getUserCenterParams as V, getUserCenterParamsByUrl as q, getUserInfo as G, is as H, isArray as J, isAsyncFunction as Q, isBoolean as Z, isClient as ee, isDate as te, isDef as ne, isElement as oe, isFunction as se, isImageDom as ie, isNull as re, isNullOrUndef as le, isNumber as ce, isObject as ae, isPromise as ue, isServer as me, isString as fe, isUndef as de, isWindow as ve, logoutToUserCenter as pe, removeAll as ge, removeLocale as ye, removeToken as _e, setLocale as he, setMenuInfo as Se, setToken as be, setUserCenterParams as Me, setUserInfo as Ue, toUserCenterConsole as xe } from "./utils.js";
|
|
4
|
+
const k = /* @__PURE__ */ x({
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: {
|
|
7
|
+
leftMin: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 0.1
|
|
10
|
+
},
|
|
11
|
+
leftMax: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 0.3
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setup(t) {
|
|
17
|
+
const e = t, o = c(), s = c(), i = c({}), f = c({}), d = c(0.2);
|
|
18
|
+
function v(n) {
|
|
19
|
+
i.value = { width: `calc(${n * 100}% - 5px)` }, f.value = { width: `calc(${(1 - n) * 100}% - 5px)` };
|
|
20
|
+
}
|
|
21
|
+
function p() {
|
|
22
|
+
const n = o.value;
|
|
23
|
+
if (!n)
|
|
24
|
+
return;
|
|
25
|
+
const g = n.clientWidth, l = n.getBoundingClientRect(), U = l.left;
|
|
26
|
+
function y(r) {
|
|
27
|
+
r.preventDefault(), (r.clientX < l.left || r.clientX > l.right || r.clientY < l.top || r.clientY > l.bottom) && u();
|
|
28
|
+
const a = (r.clientX - U) / g;
|
|
29
|
+
a > e.leftMin && a < e.leftMax && (d.value = a, v(a));
|
|
30
|
+
}
|
|
31
|
+
function u() {
|
|
32
|
+
document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", u);
|
|
33
|
+
}
|
|
34
|
+
document.addEventListener("mousemove", y), document.addEventListener("mouseup", u);
|
|
35
|
+
}
|
|
36
|
+
return C(() => {
|
|
37
|
+
v(d.value), s.value && s.value.addEventListener("mousedown", p, !1);
|
|
38
|
+
}), E(() => {
|
|
39
|
+
s.value && s.value.removeEventListener("mousedown", p);
|
|
40
|
+
}), (n, g) => (O(), L("div", {
|
|
41
|
+
ref_key: "container",
|
|
42
|
+
ref: o,
|
|
43
|
+
class: "splitter"
|
|
44
|
+
}, [
|
|
45
|
+
m("div", {
|
|
46
|
+
class: "my-left",
|
|
47
|
+
style: _(h(i))
|
|
48
|
+
}, [
|
|
49
|
+
S(n.$slots, "left", {}, void 0, !0)
|
|
50
|
+
], 4),
|
|
51
|
+
m("div", {
|
|
52
|
+
ref_key: "spliter",
|
|
53
|
+
ref: s,
|
|
54
|
+
style: { height: "100%", width: "10px" },
|
|
55
|
+
class: "my-spliter"
|
|
56
|
+
}, null, 512),
|
|
57
|
+
m("div", {
|
|
58
|
+
class: "my-right",
|
|
59
|
+
style: _(h(f))
|
|
60
|
+
}, [
|
|
61
|
+
S(n.$slots, "right", {}, void 0, !0)
|
|
62
|
+
], 4)
|
|
63
|
+
], 512));
|
|
64
|
+
}
|
|
65
|
+
}), j = (t, e) => {
|
|
66
|
+
const o = t.__vccOpts || t;
|
|
67
|
+
for (const [s, i] of e)
|
|
68
|
+
o[s] = i;
|
|
69
|
+
return o;
|
|
70
|
+
}, N = /* @__PURE__ */ j(k, [["__scopeId", "data-v-385ad393"]]), b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
71
|
+
__proto__: null,
|
|
72
|
+
WlSplitter: N
|
|
73
|
+
}, Symbol.toStringTag, { value: "Module" })), T = {
|
|
74
|
+
beforeMount(t, e) {
|
|
75
|
+
const { value: o } = e;
|
|
76
|
+
o && (P(o) || setTimeout(() => {
|
|
77
|
+
var i;
|
|
78
|
+
(i = t.parentNode) == null || i.removeChild(t);
|
|
79
|
+
}, 50));
|
|
80
|
+
}
|
|
81
|
+
}, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
82
|
+
__proto__: null,
|
|
83
|
+
permission: T
|
|
84
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
85
|
+
function w(t) {
|
|
86
|
+
Object.keys(b).forEach((e) => {
|
|
87
|
+
t.component(e, b[e]);
|
|
88
|
+
}), Object.keys(M).forEach((e) => {
|
|
89
|
+
t.directive(e, M[e]);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const F = { install: w };
|
|
93
|
+
export {
|
|
94
|
+
z as UserCenterKey,
|
|
95
|
+
N as WlSplitter,
|
|
96
|
+
F as default,
|
|
97
|
+
X as exportFile,
|
|
98
|
+
A as getButtonPermissions,
|
|
99
|
+
R as getLocale,
|
|
100
|
+
Y as getMenuInfo,
|
|
101
|
+
K as getToken,
|
|
102
|
+
V as getUserCenterParams,
|
|
103
|
+
q as getUserCenterParamsByUrl,
|
|
104
|
+
G as getUserInfo,
|
|
105
|
+
P as hasPermission,
|
|
106
|
+
H as is,
|
|
107
|
+
J as isArray,
|
|
108
|
+
Q as isAsyncFunction,
|
|
109
|
+
Z as isBoolean,
|
|
110
|
+
ee as isClient,
|
|
111
|
+
te as isDate,
|
|
112
|
+
ne as isDef,
|
|
113
|
+
oe as isElement,
|
|
114
|
+
se as isFunction,
|
|
115
|
+
ie as isImageDom,
|
|
116
|
+
re as isNull,
|
|
117
|
+
le as isNullOrUndef,
|
|
118
|
+
ce as isNumber,
|
|
119
|
+
ae as isObject,
|
|
120
|
+
ue as isPromise,
|
|
121
|
+
me as isServer,
|
|
122
|
+
fe as isString,
|
|
123
|
+
de as isUndef,
|
|
124
|
+
ve as isWindow,
|
|
125
|
+
pe as logoutToUserCenter,
|
|
126
|
+
T as permission,
|
|
127
|
+
ge as removeAll,
|
|
128
|
+
ye as removeLocale,
|
|
129
|
+
_e as removeToken,
|
|
130
|
+
he as setLocale,
|
|
131
|
+
Se as setMenuInfo,
|
|
132
|
+
be as setToken,
|
|
133
|
+
Me as setUserCenterParams,
|
|
134
|
+
Ue as setUserInfo,
|
|
135
|
+
xe as toUserCenterConsole
|
|
136
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 下载文件
|
|
3
|
+
*/
|
|
4
|
+
export declare function exportFile(options: {
|
|
5
|
+
fileData: any;
|
|
6
|
+
name: string;
|
|
7
|
+
}): void;
|
|
8
|
+
|
|
9
|
+
export declare function getButtonPermissions(): any;
|
|
10
|
+
|
|
11
|
+
export declare function getLocale(): string | null;
|
|
12
|
+
|
|
13
|
+
export declare function getMenuInfo(): any;
|
|
14
|
+
|
|
15
|
+
export declare function getToken(): string | null;
|
|
16
|
+
|
|
17
|
+
export declare function getUserCenterParams(): UserCenterParams;
|
|
18
|
+
|
|
19
|
+
export declare function getUserCenterParamsByUrl(): Record<string, string>;
|
|
20
|
+
|
|
21
|
+
export declare function getUserInfo(key?: string | Array<string> | null): any;
|
|
22
|
+
|
|
23
|
+
export declare function hasPermission(id: string): boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @description: 判断值是否未某个类型
|
|
27
|
+
*/
|
|
28
|
+
export declare function is(val: unknown, type: string): boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @description: 是否为数组
|
|
32
|
+
*/
|
|
33
|
+
export declare function isArray(val: any): val is Array<any>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @description: 是否为AsyncFunction
|
|
37
|
+
*/
|
|
38
|
+
export declare function isAsyncFunction<T = any>(val: unknown): val is Promise<T>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description: 是否为boolean类型
|
|
42
|
+
*/
|
|
43
|
+
export declare function isBoolean(val: unknown): val is boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @description: 是否客户端
|
|
47
|
+
*/
|
|
48
|
+
export declare const isClient: () => boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @description: 是否为时间
|
|
52
|
+
*/
|
|
53
|
+
export declare function isDate(val: unknown): val is Date;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @description: 是否已定义
|
|
57
|
+
*/
|
|
58
|
+
export declare const isDef: <T = unknown>(val?: T) => val is T;
|
|
59
|
+
|
|
60
|
+
export declare const isElement: (val: unknown) => val is Element;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @description: 是否为函数
|
|
64
|
+
*/
|
|
65
|
+
export declare function isFunction<T = Function>(val: unknown): val is T;
|
|
66
|
+
|
|
67
|
+
export declare function isImageDom(o: Element): boolean;
|
|
68
|
+
|
|
69
|
+
export declare function isNull(val: unknown): val is null;
|
|
70
|
+
|
|
71
|
+
export declare function isNullOrUndef(val: unknown): val is null | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @description: 是否为数值
|
|
75
|
+
*/
|
|
76
|
+
export declare function isNumber(val: unknown): val is number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @description: 是否为对象
|
|
80
|
+
*/
|
|
81
|
+
export declare const isObject: (val: any) => val is Record<any, any>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @description: 是否为promise
|
|
85
|
+
*/
|
|
86
|
+
export declare function isPromise<T = any>(val: any): val is Promise<T>;
|
|
87
|
+
|
|
88
|
+
export declare const isServer: boolean;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @description: 是否为字符串
|
|
92
|
+
*/
|
|
93
|
+
export declare function isString(val: unknown): val is string;
|
|
94
|
+
|
|
95
|
+
export declare const isUndef: <T = unknown>(val?: T) => val is T;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @description: 是否为浏览器
|
|
99
|
+
*/
|
|
100
|
+
export declare const isWindow: (val: any) => val is Window;
|
|
101
|
+
|
|
102
|
+
export declare function logoutToUserCenter(): void;
|
|
103
|
+
|
|
104
|
+
export declare function removeAll(): void;
|
|
105
|
+
|
|
106
|
+
export declare function removeLocale(): void;
|
|
107
|
+
|
|
108
|
+
export declare function removeToken(): void;
|
|
109
|
+
|
|
110
|
+
export declare function setLocale(locale: string): void;
|
|
111
|
+
|
|
112
|
+
export declare function setMenuInfo(menuInfo: any): void;
|
|
113
|
+
|
|
114
|
+
export declare function setToken(token: string): void;
|
|
115
|
+
|
|
116
|
+
export declare function setUserCenterParams(params: UserCenterParams): void;
|
|
117
|
+
|
|
118
|
+
export declare function setUserInfo(userInfo?: any): void;
|
|
119
|
+
|
|
120
|
+
export declare function toUserCenterConsole(): void;
|
|
121
|
+
|
|
122
|
+
export declare const UserCenterKey = "Witlink-Usercenter";
|
|
123
|
+
|
|
124
|
+
export declare type UserCenterParams = {
|
|
125
|
+
token?: string;
|
|
126
|
+
lang?: string;
|
|
127
|
+
usercenterUrl?: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export { }
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
const y = Object.prototype.toString;
|
|
2
|
+
function i(n, t) {
|
|
3
|
+
return y.call(n) === `[object ${t}]`;
|
|
4
|
+
}
|
|
5
|
+
function h(n) {
|
|
6
|
+
return i(n, "Function");
|
|
7
|
+
}
|
|
8
|
+
const U = (n) => typeof n < "u", w = (n) => !U(n), O = (n) => n !== null && i(n, "Object");
|
|
9
|
+
function M(n) {
|
|
10
|
+
return i(n, "Date");
|
|
11
|
+
}
|
|
12
|
+
function L(n) {
|
|
13
|
+
return i(n, "Number");
|
|
14
|
+
}
|
|
15
|
+
function K(n) {
|
|
16
|
+
return i(n, "AsyncFunction");
|
|
17
|
+
}
|
|
18
|
+
function R(n) {
|
|
19
|
+
return i(n, "Promise") && h(n.then) && h(n.catch);
|
|
20
|
+
}
|
|
21
|
+
function v(n) {
|
|
22
|
+
return i(n, "String");
|
|
23
|
+
}
|
|
24
|
+
function F(n) {
|
|
25
|
+
return i(n, "Boolean");
|
|
26
|
+
}
|
|
27
|
+
function J(n) {
|
|
28
|
+
return n && Array.isArray(n);
|
|
29
|
+
}
|
|
30
|
+
const T = () => typeof window < "u", k = (n) => typeof window < "u" && i(n, "Window"), _ = (n) => O(n) && !!n.tagName, B = typeof window > "u";
|
|
31
|
+
function W(n) {
|
|
32
|
+
return n && ["IMAGE", "IMG"].includes(n.tagName);
|
|
33
|
+
}
|
|
34
|
+
function N(n) {
|
|
35
|
+
return n === null;
|
|
36
|
+
}
|
|
37
|
+
function D(n) {
|
|
38
|
+
return w(n) || N(n);
|
|
39
|
+
}
|
|
40
|
+
function Y(n) {
|
|
41
|
+
const { fileData: t = null, name: o = "" } = n || {};
|
|
42
|
+
if (t && typeof t == "object") {
|
|
43
|
+
const e = window.URL.createObjectURL(new Blob([t])), r = document.createElement("a");
|
|
44
|
+
r.style.display = "none", r.href = e, r.setAttribute("download", o), document.body.appendChild(r), r.click(), document.body.removeChild(r), window.URL.revokeObjectURL(e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const p = "Witlink-Usercenter-QureyParams";
|
|
48
|
+
function m() {
|
|
49
|
+
const n = localStorage.getItem(p) || "{}", { token: t, lang: o, usercenterUrl: e } = JSON.parse(n);
|
|
50
|
+
return { token: t, lang: o, usercenterUrl: e };
|
|
51
|
+
}
|
|
52
|
+
function x(n) {
|
|
53
|
+
const t = m();
|
|
54
|
+
localStorage.setItem(
|
|
55
|
+
p,
|
|
56
|
+
JSON.stringify({ ...t, ...n })
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function $() {
|
|
60
|
+
const n = window.location.href, t = {}, o = n.split("?")[1];
|
|
61
|
+
return o && o.split("&").forEach((e) => {
|
|
62
|
+
const [r, c] = e.split("=");
|
|
63
|
+
r && c && (t[r] = decodeURIComponent(c));
|
|
64
|
+
}), t;
|
|
65
|
+
}
|
|
66
|
+
const E = "Witlink-Usercenter";
|
|
67
|
+
function G() {
|
|
68
|
+
const { usercenterUrl: n } = m();
|
|
69
|
+
window.location.href = n;
|
|
70
|
+
}
|
|
71
|
+
function q() {
|
|
72
|
+
window.open(m().usercenterUrl, E), window.close();
|
|
73
|
+
}
|
|
74
|
+
const b = "", a = "ACCESS_TOKEN", l = "locale", g = "userInfo", d = "menuInfo";
|
|
75
|
+
function P(n) {
|
|
76
|
+
const t = new URL(n);
|
|
77
|
+
return t.hash && t.hash.startsWith("#/") ? `/${t.hash.substring(2).split("?")[0]}`.replace(/\/+/g, "/") : t.pathname;
|
|
78
|
+
}
|
|
79
|
+
function I(n, t = {}) {
|
|
80
|
+
const o = Array.isArray(n) ? n : [n];
|
|
81
|
+
for (const e of o) {
|
|
82
|
+
if (e.path && e.name !== void 0) {
|
|
83
|
+
const r = e.path.startsWith("/") ? e.path : `/${e.path}`;
|
|
84
|
+
t[r] = e.name.toString();
|
|
85
|
+
}
|
|
86
|
+
e.children && e.children.length > 0 && I(e.children, t);
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
function s(n) {
|
|
91
|
+
return b + n;
|
|
92
|
+
}
|
|
93
|
+
function z(n) {
|
|
94
|
+
localStorage.setItem(s(a), n);
|
|
95
|
+
}
|
|
96
|
+
function Q() {
|
|
97
|
+
return localStorage.getItem(s(a));
|
|
98
|
+
}
|
|
99
|
+
function X() {
|
|
100
|
+
localStorage.removeItem(s(a));
|
|
101
|
+
}
|
|
102
|
+
function H(n) {
|
|
103
|
+
localStorage.setItem(s(l), n);
|
|
104
|
+
}
|
|
105
|
+
function V() {
|
|
106
|
+
return localStorage.getItem(s(l));
|
|
107
|
+
}
|
|
108
|
+
function Z() {
|
|
109
|
+
localStorage.removeItem(s(l));
|
|
110
|
+
}
|
|
111
|
+
function nn(n = {}) {
|
|
112
|
+
n = { ...S() || {}, ...n }, localStorage.setItem(s(g), JSON.stringify(n));
|
|
113
|
+
}
|
|
114
|
+
function S(n) {
|
|
115
|
+
const t = localStorage.getItem(s(g));
|
|
116
|
+
if (n) {
|
|
117
|
+
if (typeof n == "string")
|
|
118
|
+
return (t ? JSON.parse(t) : {})[n] || null;
|
|
119
|
+
if (Array.isArray(n)) {
|
|
120
|
+
const o = t ? JSON.parse(t) : {}, e = {};
|
|
121
|
+
return n.forEach((r) => {
|
|
122
|
+
e[r] = o[r] || null;
|
|
123
|
+
}), e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return t ? JSON.parse(t) : null;
|
|
127
|
+
}
|
|
128
|
+
function tn(n) {
|
|
129
|
+
localStorage.setItem(s(d), JSON.stringify(n));
|
|
130
|
+
}
|
|
131
|
+
function C() {
|
|
132
|
+
const n = localStorage.getItem(s(d));
|
|
133
|
+
return n ? JSON.parse(n) : null;
|
|
134
|
+
}
|
|
135
|
+
const f = {}, u = {};
|
|
136
|
+
function A() {
|
|
137
|
+
if (Object.keys(f).length === 0) {
|
|
138
|
+
const n = C() || [];
|
|
139
|
+
I(n, f);
|
|
140
|
+
}
|
|
141
|
+
return f;
|
|
142
|
+
}
|
|
143
|
+
function j() {
|
|
144
|
+
return Object.keys(u).length === 0 && ((S() || {}).role.permissions || []).forEach((o) => {
|
|
145
|
+
var e;
|
|
146
|
+
if (o.actionEntitySet != null && ((e = o.actionEntitySet) == null ? void 0 : e.length) > 0) {
|
|
147
|
+
const r = o.actionEntitySet.map((c) => c.action);
|
|
148
|
+
u[o.permissionId] = r;
|
|
149
|
+
}
|
|
150
|
+
}), u;
|
|
151
|
+
}
|
|
152
|
+
function en(n) {
|
|
153
|
+
const t = j(), o = P(window.location.href), r = A()[o] || "";
|
|
154
|
+
return (t[r] || []).includes(n);
|
|
155
|
+
}
|
|
156
|
+
function on() {
|
|
157
|
+
localStorage.removeItem(s(g)), localStorage.removeItem(s(d)), localStorage.removeItem(s(a)), localStorage.removeItem(s(l));
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
E as UserCenterKey,
|
|
161
|
+
Y as exportFile,
|
|
162
|
+
j as getButtonPermissions,
|
|
163
|
+
V as getLocale,
|
|
164
|
+
C as getMenuInfo,
|
|
165
|
+
Q as getToken,
|
|
166
|
+
m as getUserCenterParams,
|
|
167
|
+
$ as getUserCenterParamsByUrl,
|
|
168
|
+
S as getUserInfo,
|
|
169
|
+
en as hasPermission,
|
|
170
|
+
i as is,
|
|
171
|
+
J as isArray,
|
|
172
|
+
K as isAsyncFunction,
|
|
173
|
+
F as isBoolean,
|
|
174
|
+
T as isClient,
|
|
175
|
+
M as isDate,
|
|
176
|
+
U as isDef,
|
|
177
|
+
_ as isElement,
|
|
178
|
+
h as isFunction,
|
|
179
|
+
W as isImageDom,
|
|
180
|
+
N as isNull,
|
|
181
|
+
D as isNullOrUndef,
|
|
182
|
+
L as isNumber,
|
|
183
|
+
O as isObject,
|
|
184
|
+
R as isPromise,
|
|
185
|
+
B as isServer,
|
|
186
|
+
v as isString,
|
|
187
|
+
w as isUndef,
|
|
188
|
+
k as isWindow,
|
|
189
|
+
q as logoutToUserCenter,
|
|
190
|
+
on as removeAll,
|
|
191
|
+
Z as removeLocale,
|
|
192
|
+
X as removeToken,
|
|
193
|
+
H as setLocale,
|
|
194
|
+
tn as setMenuInfo,
|
|
195
|
+
z as setToken,
|
|
196
|
+
x as setUserCenterParams,
|
|
197
|
+
nn as setUserInfo,
|
|
198
|
+
G as toUserCenterConsole
|
|
199
|
+
};
|