zf-dbs 2.0.2 → 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 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 事件名称
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { a as b, 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 oe } from "./chunks/qN7meZTV.mjs";
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
3
  import { _ as j } from "./chunks/Ck0Cdfr_.mjs";
4
4
  import { _ as N } from "./chunks/BHHE86vT.mjs";
5
- import { z as ne } from "./chunks/BHHE86vT.mjs";
6
- import { ref as i, shallowRef as z, onMounted as P, onBeforeUnmount as T } from "vue";
7
- import { ElNotification as U } from "element-plus";
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
8
  import { Z as se } from "./chunks/DbOTUn3A.mjs";
9
- const L = function(e) {
10
- return e;
9
+ const B = function(t) {
10
+ return t;
11
11
  };
12
- function Z() {
12
+ function T() {
13
13
  return {
14
- delay: b.value?.pollingInterval || 3e3,
14
+ delay: E.value?.pollingInterval || 3e3,
15
15
  immediate: !0,
16
16
  leading: !0,
17
17
  resetOnExecute: !1,
@@ -23,171 +23,180 @@ function Z() {
23
23
  }
24
24
  };
25
25
  }
26
- function H() {
27
- return new Promise((e) => {
28
- requestAnimationFrame(() => e());
26
+ function U() {
27
+ return new Promise((t) => {
28
+ requestAnimationFrame(() => t());
29
29
  });
30
30
  }
31
- function I(e, o, t) {
32
- const n = Object.assign(Z(), t ?? {}), r = i(0), f = o, p = n.shallow ? z(f) : i(f), d = i(!1), v = i(null), l = i(null), u = i(!0), m = () => {
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
33
  l.value !== null && (clearTimeout(l.value), l.value = null);
34
34
  }, C = (c) => {
35
- Object.assign(n, c);
36
- }, w = async (c) => {
35
+ Object.assign(o, c);
36
+ }, h = async (c) => {
37
37
  const g = Object.assign(
38
38
  {
39
- resetOnExecute: n.resetOnExecute,
40
- throwError: n.throwError,
41
- onError: n.onError,
42
- onSuccess: n.onSuccess
39
+ resetOnExecute: o.resetOnExecute,
40
+ throwError: o.throwError,
41
+ onError: o.onError,
42
+ onSuccess: o.onSuccess
43
43
  },
44
44
  c ?? {}
45
45
  );
46
46
  r.value += 1;
47
- const E = r.value;
48
- d.value = !0, g.resetOnExecute && (p.value = o);
47
+ const _ = r.value;
48
+ d.value = !0, g.resetOnExecute && (p.value = e);
49
49
  try {
50
- const s = await Promise.resolve(e());
51
- E === r.value && (v.value = null, p.value = s, g.onSuccess?.(s));
50
+ const s = await Promise.resolve(t());
51
+ _ === r.value && (v.value = null, p.value = s, g.onSuccess?.(s));
52
52
  } catch (s) {
53
- if (E === r.value && (v.value = s, g.onError?.(s), g.throwError))
53
+ if (_ === r.value && (v.value = s, g.onError?.(s), g.throwError))
54
54
  throw s;
55
55
  } finally {
56
- E === r.value && (d.value = !1);
56
+ _ === r.value && (d.value = !1);
57
57
  }
58
- }, _ = () => {
58
+ }, b = () => {
59
59
  m(), !u.value && (l.value = setTimeout(async () => {
60
60
  if (l.value = null, !u.value)
61
61
  try {
62
- await w();
62
+ await h();
63
63
  } catch {
64
64
  } finally {
65
- await H(), u.value || _();
65
+ await U(), u.value || b();
66
66
  }
67
- }, n.delay));
68
- }, h = () => {
67
+ }, o.delay));
68
+ }, w = () => {
69
69
  u.value = !0, m();
70
- }, x = (c = { leading: n.leading }) => {
71
- u.value = !1, m(), c.leading && w().catch(() => {
72
- }), _();
70
+ }, x = (c = { leading: o.leading }) => {
71
+ u.value = !1, m(), c.leading && h().catch(() => {
72
+ }), b();
73
73
  }, y = () => {
74
- h(), r.value = 0, p.value = o, d.value = !1, v.value = null, n.immediate && x();
74
+ w(), r.value = 0, p.value = e, d.value = !1, v.value = null, o.immediate && x();
75
75
  };
76
- return P(() => {
76
+ return L(() => {
77
77
  y();
78
- }), T(() => {
79
- h();
78
+ }), P(() => {
79
+ w();
80
80
  }), {
81
81
  state: p,
82
82
  isLoading: d,
83
83
  error: v,
84
- execute: w,
85
- pause: h,
84
+ execute: h,
85
+ pause: w,
86
86
  resume: x,
87
87
  reset: y,
88
88
  setConfig: C
89
89
  };
90
90
  }
91
- function k(e, o, t) {
92
- return I(e, o, t).state;
91
+ function k(t, e, n) {
92
+ return Z(t, e, n).state;
93
93
  }
94
- function R() {
95
- if (!b.value)
94
+ function D() {
95
+ if (!E.value)
96
96
  throw new Error("请先调用 defineAppConfig 进行配置");
97
- return b.value;
97
+ return E.value;
98
98
  }
99
- const a = Object.assign(function(e) {
100
- return U({
101
- ...e,
99
+ const a = Object.assign(function(t) {
100
+ return R({
101
+ ...t,
102
102
  appendTo: O().appViewElement || document.body || void 0
103
103
  });
104
104
  }, {
105
- success(e) {
105
+ success(t) {
106
106
  return a({
107
- ...e,
107
+ ...t,
108
108
  type: "success"
109
109
  });
110
110
  },
111
- info(e) {
111
+ info(t) {
112
112
  return a({
113
- ...e,
113
+ ...t,
114
114
  type: "info"
115
115
  });
116
116
  },
117
- warning(e) {
117
+ warning(t) {
118
118
  return a({
119
- ...e,
119
+ ...t,
120
120
  type: "warning"
121
121
  });
122
122
  },
123
- error(e) {
123
+ error(t) {
124
124
  return a({
125
- ...e,
125
+ ...t,
126
126
  type: "error"
127
127
  });
128
128
  }
129
129
  }), G = A(() => {
130
- const e = R();
130
+ const t = D();
131
131
  return {
132
- ...e.request,
133
- errorHandle(o, t, n) {
134
- if (e.request.showErrorMessage && a.error({ message: t }), e.request.errorHandle)
135
- return e.request.errorHandle(o, t, n);
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);
136
136
  }
137
137
  };
138
138
  });
139
- class $ extends S {
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
+ }
140
149
  /**
141
150
  * 发送事件
142
151
  * @param {string} name 事件名称
143
152
  * @param {unknown[]} args 参数
144
153
  */
145
- emit(o, ...t) {
146
- return t = t.map((n) => JSON.parse(JSON.stringify(n))), console.log(`%c发送UE事件 %c${o}`, "color: #529b2e; font-weight: bold;", "color: #337ecc", ...t), window?.ue?.web?.[o]?.(...t);
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);
147
156
  }
148
157
  /**
149
158
  * 注册事件
150
159
  * @param {string} name 事件名称
151
160
  * @param {UnknownFunction} listener 事件处理函数
152
161
  */
153
- on(o, t) {
154
- return console.log(`%c注册UE事件 %c${o}`, "color: #b88230; font-weight: bold;", "color: #337ecc"), window[o] || (window[o] = this.dispatchEvent.bind(this, o)), super.on(o, t);
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);
155
164
  }
156
165
  /**
157
166
  * 注销事件
158
167
  * @param {string} name 事件名称
159
168
  * @param {UnknownFunction} listener 事件处理函数
160
169
  */
161
- off(o, t) {
162
- console.log(`%c注销UE事件 %c${o}`, "color: #909399; font-weight: bold;", "color: #337ecc");
163
- const n = super.off(o, t);
164
- return this.listeners(o).length || delete window[o], n;
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;
165
174
  }
166
175
  }
167
- const K = new $(), Q = {
168
- install(e) {
169
- 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(([t, n]) => {
170
- const r = n.default, f = t.split("/")[2];
171
- e.component(f, r);
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);
172
181
  });
173
182
  }
174
183
  };
175
184
  export {
176
- $ as Ue,
185
+ H as Ue,
177
186
  X as ZfApp,
178
187
  se as ZfScaleContainer,
179
- ne as ZfTweenNumber,
188
+ oe as ZfTweenNumber,
180
189
  Q as default,
181
190
  Y as defineAppConfig,
182
191
  A as defineRequest,
183
- L as defineService,
184
- R as getAppConfig,
192
+ B as defineService,
193
+ D as getAppConfig,
185
194
  O as getAppInfo,
186
195
  a as notify,
187
196
  G as request,
188
197
  K as ue,
189
198
  ee as useAppConfig,
190
- oe as useAppInfo,
191
- I as usePolling,
199
+ te as useAppInfo,
200
+ Z as usePolling,
192
201
  k as usePollingRef
193
202
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "zf-dbs",
3
3
  "type": "module",
4
4
  "description": "",
5
- "version": "2.0.2",
5
+ "version": "2.1.2",
6
6
  "main": "./dist/index.mjs",
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",