zf-dbs 2.0.1 → 2.1.2
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.d.ts +91 -13
- package/dist/index.mjs +140 -109
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -145,6 +145,9 @@ declare type ServiceHandleHasParams<Params, Result> = (params: Params, config?:
|
|
|
145
145
|
declare type ServiceHandleNoParams<Result> = (params?: any, config?: Record<string, any>) => Promise<Result>;
|
|
146
146
|
|
|
147
147
|
export declare class Ue extends EventListener_2 {
|
|
148
|
+
__handleDispatchEvent(name: string, ...args: unknown[]): any;
|
|
149
|
+
__handleAddEventListener(name: string): void;
|
|
150
|
+
__handleRemoveEventListener(name: string): void;
|
|
148
151
|
/**
|
|
149
152
|
* 发送事件
|
|
150
153
|
* @param {string} name 事件名称
|
|
@@ -183,9 +186,32 @@ readonly appElement: HTMLElement | null;
|
|
|
183
186
|
readonly appViewElement: HTMLElement | null;
|
|
184
187
|
}>;
|
|
185
188
|
|
|
186
|
-
|
|
189
|
+
/**
|
|
190
|
+
* 轮询 Hook
|
|
191
|
+
*
|
|
192
|
+
* 类型推导效果:
|
|
193
|
+
* - listener 返回 Promise<User>,state => User | D
|
|
194
|
+
* - defaultValue 不传,state => User | undefined
|
|
195
|
+
* - defaultValue 传 0,state => User | 0
|
|
196
|
+
*
|
|
197
|
+
* setConfig 只允许修改运行时安全项:
|
|
198
|
+
* - delay
|
|
199
|
+
* - leading
|
|
200
|
+
* - resetOnExecute
|
|
201
|
+
* - throwError
|
|
202
|
+
* - onError
|
|
203
|
+
* - onSuccess
|
|
204
|
+
*
|
|
205
|
+
* 不允许修改:
|
|
206
|
+
* - shallow
|
|
207
|
+
* - immediate
|
|
208
|
+
*/
|
|
209
|
+
export declare function usePolling<TListener extends UsePollingListener<any>, D = undefined, TConfig extends UsePollingConfig<UsePollingResolvedValue<TListener>> = UsePollingConfig<UsePollingResolvedValue<TListener>>>(listener: TListener, defaultValue?: UsePollingDefaultValue<D>, config?: TConfig): UsePollingResponse<UsePollingResolvedValue<TListener>, TConfig, D>;
|
|
187
210
|
|
|
188
|
-
|
|
211
|
+
/**
|
|
212
|
+
* 原始配置
|
|
213
|
+
*/
|
|
214
|
+
declare type UsePollingConfig<TResult> = {
|
|
189
215
|
delay?: number;
|
|
190
216
|
immediate?: boolean;
|
|
191
217
|
leading?: boolean;
|
|
@@ -193,43 +219,95 @@ declare type UsePollingConfig<T> = {
|
|
|
193
219
|
resetOnExecute?: boolean;
|
|
194
220
|
throwError?: boolean;
|
|
195
221
|
onError?: (error: unknown) => void;
|
|
196
|
-
onSuccess?: (result:
|
|
222
|
+
onSuccess?: (result: TResult) => void;
|
|
197
223
|
};
|
|
198
224
|
|
|
225
|
+
/**
|
|
226
|
+
* 默认值
|
|
227
|
+
* 允许不传,也允许显式传 undefined
|
|
228
|
+
*/
|
|
199
229
|
declare type UsePollingDefaultValue<T = undefined> = T | undefined;
|
|
200
230
|
|
|
201
|
-
|
|
231
|
+
/**
|
|
232
|
+
* 轮询监听器
|
|
233
|
+
* 支持同步值,也支持 Promise
|
|
234
|
+
*/
|
|
235
|
+
declare type UsePollingListener<TResult> = () => TResult | Promise<TResult>;
|
|
202
236
|
|
|
203
|
-
|
|
237
|
+
/**
|
|
238
|
+
* 允许运行时修改的配置
|
|
239
|
+
* shallow / immediate 不允许改
|
|
240
|
+
*/
|
|
241
|
+
declare type UsePollingMutableConfig<TResult> = Omit<UsePollingConfig<TResult>, 'shallow' | 'immediate'>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 仅返回 state 的版本
|
|
245
|
+
* 参数、类型推导、默认值行为都和 usePolling 完全一致
|
|
246
|
+
*/
|
|
247
|
+
export declare function usePollingRef<TListener extends UsePollingListener<any>, D = undefined, TConfig extends UsePollingConfig<Awaited<ReturnType<TListener>>> = UsePollingConfig<Awaited<ReturnType<TListener>>>>(listener: TListener, defaultValue?: UsePollingDefaultValue<D>, config?: TConfig): UsePollingResponse<Awaited<ReturnType<TListener>>, TConfig, D>['state'];
|
|
204
248
|
|
|
205
|
-
|
|
206
|
-
|
|
249
|
+
/**
|
|
250
|
+
* listener 的最终返回值
|
|
251
|
+
* Promise<T> 会自动解包成 T
|
|
252
|
+
*/
|
|
253
|
+
declare type UsePollingResolvedValue<TListener extends UsePollingListener<any>> = Awaited<ReturnType<TListener>>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 对外返回值
|
|
257
|
+
*/
|
|
258
|
+
declare type UsePollingResponse<TResult, TConfig extends UsePollingConfig<TResult>, D = undefined> = {
|
|
259
|
+
state: UsePollingStateTypeRef<TResult, TConfig, D>;
|
|
207
260
|
isLoading: Ref_2<boolean>;
|
|
208
261
|
error: Ref_2<unknown>;
|
|
209
|
-
execute: UsePollingResponseExecute<
|
|
262
|
+
execute: UsePollingResponseExecute<TResult>;
|
|
210
263
|
pause: () => void;
|
|
211
264
|
resume: UsePollingResponseResume;
|
|
212
265
|
reset: () => void;
|
|
266
|
+
setConfig: (config: UsePollingSetConfig<TResult>) => void;
|
|
213
267
|
};
|
|
214
268
|
|
|
215
|
-
|
|
269
|
+
/**
|
|
270
|
+
* 主动执行
|
|
271
|
+
*/
|
|
272
|
+
declare type UsePollingResponseExecute<TResult> = (config?: UsePollingResponseExecuteConfig<TResult>) => Promise<void>;
|
|
216
273
|
|
|
217
|
-
|
|
274
|
+
/**
|
|
275
|
+
* 执行时可覆盖的配置
|
|
276
|
+
*/
|
|
277
|
+
declare type UsePollingResponseExecuteConfig<TResult> = {
|
|
218
278
|
resetOnExecute?: boolean;
|
|
219
279
|
throwError?: boolean;
|
|
220
280
|
onError?: (error: unknown) => void;
|
|
221
|
-
onSuccess?: (result:
|
|
281
|
+
onSuccess?: (result: TResult) => void;
|
|
222
282
|
};
|
|
223
283
|
|
|
284
|
+
/**
|
|
285
|
+
* 继续轮询
|
|
286
|
+
*/
|
|
224
287
|
declare type UsePollingResponseResume = (config?: UsePollingResponseResumeConfig) => void;
|
|
225
288
|
|
|
289
|
+
/**
|
|
290
|
+
* 继续轮询时的配置
|
|
291
|
+
*/
|
|
226
292
|
declare type UsePollingResponseResumeConfig = {
|
|
227
293
|
leading?: boolean;
|
|
228
294
|
};
|
|
229
295
|
|
|
230
|
-
|
|
296
|
+
/**
|
|
297
|
+
* setConfig 的入参
|
|
298
|
+
*/
|
|
299
|
+
declare type UsePollingSetConfig<TResult> = Partial<UsePollingMutableConfig<TResult>>;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* state 的值类型
|
|
303
|
+
* 结果类型 + 默认值类型
|
|
304
|
+
*/
|
|
305
|
+
declare type UsePollingStateType<TResult, D = undefined> = TResult | D;
|
|
231
306
|
|
|
232
|
-
|
|
307
|
+
/**
|
|
308
|
+
* shallow 模式下返回 ShallowRef,否则返回 Ref
|
|
309
|
+
*/
|
|
310
|
+
declare type UsePollingStateTypeRef<TResult, TConfig extends UsePollingConfig<TResult>, D = undefined> = TConfig['shallow'] extends true ? ShallowRef<UsePollingStateType<TResult, D>> : Ref_2<UsePollingStateType<TResult, D>>;
|
|
233
311
|
|
|
234
312
|
export declare const ZfApp: __VLS_WithTemplateSlots<DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<globalThis.ExtractPropTypes<{}>>, {}, {}>, {
|
|
235
313
|
default?(_: {}): any;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { z as
|
|
3
|
-
import { _ as
|
|
4
|
-
import { _ as
|
|
5
|
-
import { z as
|
|
6
|
-
import { ref as
|
|
7
|
-
import { ElNotification as
|
|
8
|
-
import { Z as
|
|
9
|
-
const
|
|
10
|
-
return
|
|
1
|
+
import { a as E, g as O, m as A, t as S, _ as q } from "./chunks/qN7meZTV.mjs";
|
|
2
|
+
import { z as X, d as Y, u as ee, b as te } from "./chunks/qN7meZTV.mjs";
|
|
3
|
+
import { _ as j } from "./chunks/Ck0Cdfr_.mjs";
|
|
4
|
+
import { _ as N } from "./chunks/BHHE86vT.mjs";
|
|
5
|
+
import { z as oe } from "./chunks/BHHE86vT.mjs";
|
|
6
|
+
import { ref as i, shallowRef as z, onMounted as L, onBeforeUnmount as P } from "vue";
|
|
7
|
+
import { ElNotification as R } from "element-plus";
|
|
8
|
+
import { Z as se } from "./chunks/DbOTUn3A.mjs";
|
|
9
|
+
const B = function(t) {
|
|
10
|
+
return t;
|
|
11
11
|
};
|
|
12
|
-
function
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function j(e, t, o) {
|
|
18
|
-
o = Object.assign({
|
|
19
|
-
delay: 3e3,
|
|
12
|
+
function T() {
|
|
13
|
+
return {
|
|
14
|
+
delay: E.value?.pollingInterval || 3e3,
|
|
20
15
|
immediate: !0,
|
|
21
16
|
leading: !0,
|
|
22
17
|
resetOnExecute: !1,
|
|
@@ -26,146 +21,182 @@ function j(e, t, o) {
|
|
|
26
21
|
},
|
|
27
22
|
onSuccess: () => {
|
|
28
23
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function U() {
|
|
27
|
+
return new Promise((t) => {
|
|
28
|
+
requestAnimationFrame(() => t());
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function Z(t, e, n) {
|
|
32
|
+
const o = Object.assign(T(), n ?? {}), r = i(0), f = e, p = o.shallow ? z(f) : i(f), d = i(!1), v = i(null), l = i(null), u = i(!0), m = () => {
|
|
33
|
+
l.value !== null && (clearTimeout(l.value), l.value = null);
|
|
34
|
+
}, C = (c) => {
|
|
35
|
+
Object.assign(o, c);
|
|
36
|
+
}, h = async (c) => {
|
|
37
|
+
const g = Object.assign(
|
|
38
|
+
{
|
|
39
|
+
resetOnExecute: o.resetOnExecute,
|
|
40
|
+
throwError: o.throwError,
|
|
41
|
+
onError: o.onError,
|
|
42
|
+
onSuccess: o.onSuccess
|
|
43
|
+
},
|
|
44
|
+
c ?? {}
|
|
45
|
+
);
|
|
46
|
+
r.value += 1;
|
|
47
|
+
const _ = r.value;
|
|
48
|
+
d.value = !0, g.resetOnExecute && (p.value = e);
|
|
35
49
|
try {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
} catch (
|
|
39
|
-
if (
|
|
40
|
-
throw
|
|
50
|
+
const s = await Promise.resolve(t());
|
|
51
|
+
_ === r.value && (v.value = null, p.value = s, g.onSuccess?.(s));
|
|
52
|
+
} catch (s) {
|
|
53
|
+
if (_ === r.value && (v.value = s, g.onError?.(s), g.throwError))
|
|
54
|
+
throw s;
|
|
41
55
|
} finally {
|
|
42
|
-
|
|
56
|
+
_ === r.value && (d.value = !1);
|
|
43
57
|
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, o
|
|
54
|
-
},
|
|
55
|
-
|
|
58
|
+
}, b = () => {
|
|
59
|
+
m(), !u.value && (l.value = setTimeout(async () => {
|
|
60
|
+
if (l.value = null, !u.value)
|
|
61
|
+
try {
|
|
62
|
+
await h();
|
|
63
|
+
} catch {
|
|
64
|
+
} finally {
|
|
65
|
+
await U(), u.value || b();
|
|
66
|
+
}
|
|
67
|
+
}, o.delay));
|
|
68
|
+
}, w = () => {
|
|
69
|
+
u.value = !0, m();
|
|
70
|
+
}, x = (c = { leading: o.leading }) => {
|
|
71
|
+
u.value = !1, m(), c.leading && h().catch(() => {
|
|
72
|
+
}), b();
|
|
73
|
+
}, y = () => {
|
|
74
|
+
w(), r.value = 0, p.value = e, d.value = !1, v.value = null, o.immediate && x();
|
|
56
75
|
};
|
|
57
|
-
return
|
|
58
|
-
|
|
76
|
+
return L(() => {
|
|
77
|
+
y();
|
|
78
|
+
}), P(() => {
|
|
79
|
+
w();
|
|
59
80
|
}), {
|
|
60
|
-
state:
|
|
61
|
-
isLoading:
|
|
62
|
-
error:
|
|
63
|
-
execute:
|
|
64
|
-
pause:
|
|
65
|
-
resume:
|
|
66
|
-
reset:
|
|
81
|
+
state: p,
|
|
82
|
+
isLoading: d,
|
|
83
|
+
error: v,
|
|
84
|
+
execute: h,
|
|
85
|
+
pause: w,
|
|
86
|
+
resume: x,
|
|
87
|
+
reset: y,
|
|
88
|
+
setConfig: C
|
|
67
89
|
};
|
|
68
90
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
91
|
+
function k(t, e, n) {
|
|
92
|
+
return Z(t, e, n).state;
|
|
71
93
|
}
|
|
72
|
-
function
|
|
73
|
-
if (!
|
|
94
|
+
function D() {
|
|
95
|
+
if (!E.value)
|
|
74
96
|
throw new Error("请先调用 defineAppConfig 进行配置");
|
|
75
|
-
return
|
|
97
|
+
return E.value;
|
|
76
98
|
}
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
...
|
|
80
|
-
appendTo:
|
|
99
|
+
const a = Object.assign(function(t) {
|
|
100
|
+
return R({
|
|
101
|
+
...t,
|
|
102
|
+
appendTo: O().appViewElement || document.body || void 0
|
|
81
103
|
});
|
|
82
104
|
}, {
|
|
83
|
-
success(
|
|
84
|
-
return
|
|
85
|
-
...
|
|
105
|
+
success(t) {
|
|
106
|
+
return a({
|
|
107
|
+
...t,
|
|
86
108
|
type: "success"
|
|
87
109
|
});
|
|
88
110
|
},
|
|
89
|
-
info(
|
|
90
|
-
return
|
|
91
|
-
...
|
|
111
|
+
info(t) {
|
|
112
|
+
return a({
|
|
113
|
+
...t,
|
|
92
114
|
type: "info"
|
|
93
115
|
});
|
|
94
116
|
},
|
|
95
|
-
warning(
|
|
96
|
-
return
|
|
97
|
-
...
|
|
117
|
+
warning(t) {
|
|
118
|
+
return a({
|
|
119
|
+
...t,
|
|
98
120
|
type: "warning"
|
|
99
121
|
});
|
|
100
122
|
},
|
|
101
|
-
error(
|
|
102
|
-
return
|
|
103
|
-
...
|
|
123
|
+
error(t) {
|
|
124
|
+
return a({
|
|
125
|
+
...t,
|
|
104
126
|
type: "error"
|
|
105
127
|
});
|
|
106
128
|
}
|
|
107
|
-
}),
|
|
108
|
-
const
|
|
129
|
+
}), G = A(() => {
|
|
130
|
+
const t = D();
|
|
109
131
|
return {
|
|
110
|
-
...
|
|
111
|
-
errorHandle(
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
132
|
+
...t.request,
|
|
133
|
+
errorHandle(e, n, o) {
|
|
134
|
+
if (t.request.showErrorMessage && a.error({ message: n }), t.request.errorHandle)
|
|
135
|
+
return t.request.errorHandle(e, n, o);
|
|
114
136
|
}
|
|
115
137
|
};
|
|
116
138
|
});
|
|
117
|
-
class
|
|
139
|
+
class H extends S {
|
|
140
|
+
__handleDispatchEvent(e, ...n) {
|
|
141
|
+
return window?.ue?.web?.[e]?.(...n);
|
|
142
|
+
}
|
|
143
|
+
__handleAddEventListener(e) {
|
|
144
|
+
window[e] || (window[e] = this.dispatchEvent.bind(this, e));
|
|
145
|
+
}
|
|
146
|
+
__handleRemoveEventListener(e) {
|
|
147
|
+
this.listeners(e).length || delete window[e];
|
|
148
|
+
}
|
|
118
149
|
/**
|
|
119
150
|
* 发送事件
|
|
120
151
|
* @param {string} name 事件名称
|
|
121
152
|
* @param {unknown[]} args 参数
|
|
122
153
|
*/
|
|
123
|
-
emit(
|
|
124
|
-
return
|
|
154
|
+
emit(e, ...n) {
|
|
155
|
+
return n = n.map((o) => JSON.parse(JSON.stringify(o))), console.log(`%c发送UE事件 %c${e}`, "color: #529b2e; font-weight: bold;", "color: #337ecc", ...n), this.__handleDispatchEvent(e, ...n);
|
|
125
156
|
}
|
|
126
157
|
/**
|
|
127
158
|
* 注册事件
|
|
128
159
|
* @param {string} name 事件名称
|
|
129
160
|
* @param {UnknownFunction} listener 事件处理函数
|
|
130
161
|
*/
|
|
131
|
-
on(
|
|
132
|
-
return console.log(`%c注册UE事件 %c${
|
|
162
|
+
on(e, n) {
|
|
163
|
+
return console.log(`%c注册UE事件 %c${e}`, "color: #b88230; font-weight: bold;", "color: #337ecc"), this.__handleAddEventListener(e), super.on(e, n);
|
|
133
164
|
}
|
|
134
165
|
/**
|
|
135
166
|
* 注销事件
|
|
136
167
|
* @param {string} name 事件名称
|
|
137
168
|
* @param {UnknownFunction} listener 事件处理函数
|
|
138
169
|
*/
|
|
139
|
-
off(
|
|
140
|
-
console.log(`%c注销UE事件 %c${
|
|
141
|
-
const
|
|
142
|
-
return this.listeners(
|
|
170
|
+
off(e, n) {
|
|
171
|
+
console.log(`%c注销UE事件 %c${e}`, "color: #909399; font-weight: bold;", "color: #337ecc");
|
|
172
|
+
const o = super.off(e, n);
|
|
173
|
+
return this.listeners(e).length || this.__handleRemoveEventListener(e), o;
|
|
143
174
|
}
|
|
144
175
|
}
|
|
145
|
-
const
|
|
146
|
-
install(
|
|
147
|
-
Object.entries(/* @__PURE__ */ Object.assign({ "./components/zf-app/index.ts":
|
|
148
|
-
const r =
|
|
149
|
-
|
|
176
|
+
const K = new H(), Q = {
|
|
177
|
+
install(t) {
|
|
178
|
+
Object.entries(/* @__PURE__ */ Object.assign({ "./components/zf-app/index.ts": q, "./components/zf-scale-container/index.ts": j, "./components/zf-tween-number/index.ts": N })).forEach(([n, o]) => {
|
|
179
|
+
const r = o.default, f = n.split("/")[2];
|
|
180
|
+
t.component(f, r);
|
|
150
181
|
});
|
|
151
182
|
}
|
|
152
183
|
};
|
|
153
184
|
export {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
185
|
+
H as Ue,
|
|
186
|
+
X as ZfApp,
|
|
187
|
+
se as ZfScaleContainer,
|
|
188
|
+
oe as ZfTweenNumber,
|
|
189
|
+
Q as default,
|
|
190
|
+
Y as defineAppConfig,
|
|
191
|
+
A as defineRequest,
|
|
192
|
+
B as defineService,
|
|
193
|
+
D as getAppConfig,
|
|
194
|
+
O as getAppInfo,
|
|
195
|
+
a as notify,
|
|
196
|
+
G as request,
|
|
197
|
+
K as ue,
|
|
198
|
+
ee as useAppConfig,
|
|
199
|
+
te as useAppInfo,
|
|
200
|
+
Z as usePolling,
|
|
201
|
+
k as usePollingRef
|
|
171
202
|
};
|