xl-app-sdk 0.0.8 → 0.1.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/es/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { v as o } from "./event-CGLPzfQO.js";
2
- import { g as q, m as k, n as B, r as U, v as j } from "./vue-CSCtfgHT.js";
3
- import { s as G } from "./scene-DeuRXFje.js";
4
- import { u as K } from "./utils-IPr2Rakl.js";
2
+ import { g as q, m as k, n as B, r as U } from "./request-DXNZ2mjR.js";
5
3
  function m() {
6
4
  return o;
7
5
  }
@@ -45,19 +43,19 @@ function P(e) {
45
43
  return new Promise((t, n) => {
46
44
  let r = null, a = null;
47
45
  e?.onMessage && (r = "_open_onMessage_" + Math.random().toString(36).substring(2, 15) + "_", a = o.on(r, e.onMessage));
48
- let s = null, i = null;
49
- e?.onShow && (s = "_open_onShow_" + Math.random().toString(36).substring(2, 15) + "_", i = o.on(s, e.onShow));
46
+ let u = null, i = null;
47
+ e?.onShow && (u = "_open_onShow_" + Math.random().toString(36).substring(2, 15) + "_", i = o.on(u, e.onShow));
50
48
  let l = null, c = null;
51
49
  e?.onHide && (l = "_open_onHide_" + Math.random().toString(36).substring(2, 15) + "_", c = o.on(l, e.onHide));
52
- let u = null;
53
- e?.onClose && (u = "_open_onClose_" + Math.random().toString(36).substring(2, 15) + "_", o.ononce(u, () => {
50
+ let s = null;
51
+ e?.onClose && (s = "_open_onClose_" + Math.random().toString(36).substring(2, 15) + "_", o.ononce(s, () => {
54
52
  o.off(a), o.off(i), o.off(c), e.onClose();
55
53
  })), o.call("open", {
56
54
  ...e,
57
55
  onMessage: r,
58
- onShow: s,
56
+ onShow: u,
59
57
  onHide: l,
60
- onClose: u
58
+ onClose: s
61
59
  }).then((h) => {
62
60
  t(h);
63
61
  }).catch((h) => {
@@ -101,7 +99,7 @@ function E() {
101
99
  });
102
100
  });
103
101
  }
104
- function x() {
102
+ function R() {
105
103
  return new Promise((e, t) => {
106
104
  o.call("getTheme").then((n) => {
107
105
  e(n);
@@ -110,7 +108,7 @@ function x() {
110
108
  });
111
109
  });
112
110
  }
113
- function R(e) {
111
+ function x(e) {
114
112
  return new Promise((t, n) => {
115
113
  o.call("setTheme", e).then((r) => {
116
114
  t(r);
@@ -119,12 +117,12 @@ function R(e) {
119
117
  });
120
118
  });
121
119
  }
122
- function v(e, t = !1) {
120
+ function b(e, t = !1) {
123
121
  return t ? o.ononce("onTheme", e) : o.on("onTheme", e);
124
122
  }
125
123
  function H(e = {}) {
126
124
  const { accept: t = "*", multiple: n = !1, capture: r } = e;
127
- return new Promise((a, s) => {
125
+ return new Promise((a, u) => {
128
126
  try {
129
127
  const i = document.createElement("input");
130
128
  i.type = "file", i.accept = t, i.multiple = n, r && (i.capture = r), i.addEventListener("change", () => {
@@ -135,11 +133,11 @@ function H(e = {}) {
135
133
  }
136
134
  }, { once: !0 }), i.click();
137
135
  } catch (i) {
138
- s(i);
136
+ u(i);
139
137
  }
140
138
  });
141
139
  }
142
- async function b(e, t) {
140
+ async function V(e, t) {
143
141
  if (!e)
144
142
  throw new Error("上传文件不能为空");
145
143
  if (!(e instanceof File))
@@ -153,7 +151,7 @@ async function b(e, t) {
153
151
  } catch {
154
152
  }
155
153
  return c;
156
- }, s = await o.sendFile(e, async (c) => {
154
+ }, u = await o.sendFile(e, async (c) => {
157
155
  n = c, await a();
158
156
  });
159
157
  let i = null, l = null;
@@ -161,14 +159,14 @@ async function b(e, t) {
161
159
  r = c, await a();
162
160
  }));
163
161
  try {
164
- return await o.call("uploadImage", { id: s, onProgress: i });
162
+ return await o.call("uploadImage", { id: u, onProgress: i });
165
163
  } catch (c) {
166
164
  throw c;
167
165
  } finally {
168
166
  l && o.off(l);
169
167
  }
170
168
  }
171
- function V(e = null, t = null) {
169
+ function v(e = null, t = null) {
172
170
  return new Promise((n, r) => {
173
171
  o.call("getTableList").then((a) => {
174
172
  n(a);
@@ -223,8 +221,8 @@ export {
223
221
  E as getActivateView,
224
222
  w as getData,
225
223
  q as getRequestBaseURL,
226
- V as getTableList,
227
- x as getTheme,
224
+ v as getTableList,
225
+ R as getTheme,
228
226
  d as getViewData,
229
227
  m as getViewEventManager,
230
228
  g as getViewInfo,
@@ -234,17 +232,14 @@ export {
234
232
  _ as onHide,
235
233
  A as onRichTextEditComplete,
236
234
  T as onShow,
237
- v as onTheme,
235
+ b as onTheme,
238
236
  P as open,
239
237
  H as openFilePicker,
240
238
  N as openRichTextEdit,
241
239
  C as refreshTableList,
242
240
  U as request,
243
241
  L as resetTableList,
244
- G as scene,
245
242
  p as sendMessage,
246
- R as setTheme,
247
- b as uploadImage,
248
- K as utils,
249
- j as vueHooks
243
+ x as setTheme,
244
+ V as uploadImage
250
245
  };
@@ -0,0 +1,268 @@
1
+ import O from "axios";
2
+ import { v as o } from "./event-CGLPzfQO.js";
3
+ import { s as r, e as D, h as P, v as S, j as m } from "./utils-CnDqFMmf.js";
4
+ function f(e, a = {}) {
5
+ const n = o.getMode(!0), i = ["info", "warning", "error", "success", "loading"];
6
+ if (!(a?.type && !i.includes(a.type))) {
7
+ if (n === null || n === "window") {
8
+ if (a?.duration === 0 && a?.type !== "loading")
9
+ return;
10
+ if ((!a?.duration || a?.duration < 0) && (a.duration = 2e3), a?.type !== "loading" && a?.duration === 0 && (a.duration = 2e3), !a?.type) {
11
+ if (!window?.naive?.message) {
12
+ setTimeout(() => {
13
+ window.naive.message.destroyAll();
14
+ }, 100);
15
+ return;
16
+ }
17
+ window.naive.message.destroyAll();
18
+ return;
19
+ }
20
+ try {
21
+ if (!window?.naive?.message) {
22
+ setTimeout(() => {
23
+ window.naive.message.create(e, a);
24
+ }, 100);
25
+ return;
26
+ }
27
+ window.naive.message.create(e, a);
28
+ } catch {
29
+ }
30
+ return;
31
+ }
32
+ o.call("message", {
33
+ content: e,
34
+ ...a
35
+ }).then((c) => {
36
+ }).catch((c) => {
37
+ });
38
+ }
39
+ }
40
+ function v(e, a = {}) {
41
+ f(e, { ...a, type: "success" });
42
+ }
43
+ function k(e, a = {}) {
44
+ f(e, { ...a, type: "info" });
45
+ }
46
+ function N(e, a = {}) {
47
+ f(e, { ...a, type: "warning" });
48
+ }
49
+ function h(e, a = {}) {
50
+ f(e, { ...a, type: "error" });
51
+ }
52
+ function A(e, a = {}) {
53
+ f(e, { ...a, type: "loading" });
54
+ }
55
+ function _() {
56
+ o.getParent(!0) && o.call("message", {});
57
+ try {
58
+ if (!window?.naive?.message) {
59
+ setTimeout(() => {
60
+ window.naive.message.destroyAll();
61
+ }, 100);
62
+ return;
63
+ }
64
+ window.naive.message.destroyAll();
65
+ } catch {
66
+ }
67
+ }
68
+ function M(e) {
69
+ r(window, "naive.message", e);
70
+ }
71
+ const C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
72
+ __proto__: null,
73
+ create: f,
74
+ destroyAll: _,
75
+ error: h,
76
+ info: k,
77
+ loading: A,
78
+ setInstance: M,
79
+ success: v,
80
+ warning: N
81
+ }, Symbol.toStringTag, { value: "Module" }));
82
+ function g(e) {
83
+ const a = o.getMode(!0), n = ["info", "warning", "error", "success"];
84
+ if (!(e?.type && !n.includes(e.type))) {
85
+ if (e?.closable === void 0 && (e.closable = !0), a === null || a === "window") {
86
+ if (e.closable === !1 && e.duration === 0 && (e.duration = 5e3), (!e?.duration || e?.duration < 0) && (e.duration = 5e3), !e?.type) {
87
+ if (!window?.naive?.notification) {
88
+ setTimeout(() => {
89
+ window.naive.notification.destroyAll();
90
+ }, 100);
91
+ return;
92
+ }
93
+ window.naive.notification.destroyAll();
94
+ return;
95
+ }
96
+ try {
97
+ if (!window?.naive?.notification) {
98
+ setTimeout(() => {
99
+ window.naive.notification.create(e);
100
+ }, 100);
101
+ return;
102
+ }
103
+ window.naive.notification.create(e);
104
+ } catch {
105
+ }
106
+ return;
107
+ }
108
+ o.call("notification", e).then((i) => {
109
+ }).catch((i) => {
110
+ });
111
+ }
112
+ }
113
+ function q(e) {
114
+ g({ ...e, type: "success" });
115
+ }
116
+ function U(e) {
117
+ g({ ...e, type: "info" });
118
+ }
119
+ function L(e) {
120
+ g({ ...e, type: "warning" });
121
+ }
122
+ function p(e) {
123
+ g({ ...e, type: "error" });
124
+ }
125
+ function $() {
126
+ o.getParent(!0) && o.call("notification", {});
127
+ try {
128
+ if (!window?.naive?.notification) {
129
+ setTimeout(() => {
130
+ window.naive.notification.destroyAll();
131
+ }, 100);
132
+ return;
133
+ }
134
+ window.naive.notification.destroyAll();
135
+ } catch {
136
+ }
137
+ }
138
+ function j(e) {
139
+ r(window, "naive.notification", e);
140
+ }
141
+ const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
142
+ __proto__: null,
143
+ create: g,
144
+ destroyAll: $,
145
+ error: p,
146
+ info: U,
147
+ setInstance: j,
148
+ success: q,
149
+ warning: L
150
+ }, Symbol.toStringTag, { value: "Module" }));
151
+ async function T(e = null, a = {}) {
152
+ const n = new URLSearchParams(window.location.search), i = new URLSearchParams(a);
153
+ n.has("_token") && i.append("_token", n.get("_token"));
154
+ try {
155
+ const c = await o.call("getRequestBaseURL", e);
156
+ return i.size > 0 ? c + "?" + i.toString() : c;
157
+ } catch {
158
+ return i.size > 0 ? e + "?" + i.toString() : e;
159
+ }
160
+ }
161
+ async function E(e, a) {
162
+ if (!e) return;
163
+ let n = 300, i = 0;
164
+ Array.isArray(e) && (n = e[0] || 300, i = e[1] || 0);
165
+ const l = Date.now() - a;
166
+ i > 0 ? l > i && l < n && await new Promise((w) => setTimeout(w, n - l)) : l < n && await new Promise((w) => setTimeout(w, n - l));
167
+ }
168
+ async function F(e) {
169
+ let {
170
+ crossWindow: a = void 0,
171
+ cloneData: n = !1,
172
+ filterEmpty: i = !1,
173
+ loading: c = !1,
174
+ replenish: l = !1,
175
+ showMsg: w = !1,
176
+ showErrorMsg: b = !1,
177
+ msgField: s = "msg"
178
+ } = e;
179
+ a === void 0 && o.getMode(!0) === "iframe" && (a = !0), a && o.getMode(!0) === null && (e.method === "get" || e.method === "GET" ? e.url = await T(e?.url, e?.data) : e.url = await T(e?.url)), n && e.data && (e.data = D(e.data)), i && e.data && typeof e.data == "object" && (e.data = P(e.data)), c && A(typeof c == "string" ? c : "加载中", { duration: 0 });
180
+ const R = Date.now();
181
+ try {
182
+ let t;
183
+ if (a)
184
+ t = await o.call("request", {
185
+ ...e,
186
+ cloneData: !1,
187
+ replenish: !1,
188
+ loading: !1,
189
+ showMsg: !1,
190
+ showErrorMsg: !1
191
+ }), l && await E(l, R);
192
+ else {
193
+ (e.method === "get" || e.method === "GET") && (e.params = e.data, e.data = null);
194
+ const u = await O.request(e);
195
+ t = u.data, l && await E(l, R);
196
+ let d = !1;
197
+ if ((u.config.responseType === "json" || u.config.responseType === void 0) && (d = !0), d && !S(u.request.responseText))
198
+ throw t.code = "ERR_BAD_RESPONSE", t;
199
+ }
200
+ _();
201
+ const y = m(t, s || "msg");
202
+ if (t?.code < 0 || t?.code == 404 || t?.code == 403 || t?.code == 500)
203
+ throw t;
204
+ return w && setTimeout(() => {
205
+ v(y || "请求成功");
206
+ }, 300), t;
207
+ } catch (t) {
208
+ switch (await E(l, R), _(), t.request_code = t.code, t.code) {
209
+ case "ECONNABORTED":
210
+ r(t, s, "连接被中止"), r(t, "msg", "连接被中止");
211
+ break;
212
+ case "ERR_BAD_OPTION":
213
+ r(t, s, "错误的选项"), r(t, "msg", "错误的选项");
214
+ break;
215
+ case "ERR_BAD_OPTION_VALUE":
216
+ r(t, s, "错误的选项数值"), r(t, "msg", "错误的选项数值");
217
+ break;
218
+ case "ERR_CANCELED":
219
+ r(t, s, "操作被取消"), r(t, "msg", "操作被取消");
220
+ break;
221
+ case "ERR_DEPRECATED":
222
+ r(t, s, "已废弃的功能"), r(t, "msg", "已废弃的功能");
223
+ break;
224
+ case "ERR_FR_TOO_MANY_REDIRECTS":
225
+ r(t, s, "页面重定向次数过多"), r(t, "msg", "页面重定向次数过多");
226
+ break;
227
+ case "ERR_INVALID_URL":
228
+ r(t, s, "无效的URL"), r(t, "msg", "无效的URL");
229
+ break;
230
+ case "ERR_NETWORK":
231
+ r(t, s, "无法连接目标地址"), r(t, "msg", "无法连接目标地址");
232
+ break;
233
+ case "ERR_NOT_SUPPORT":
234
+ r(t, s, "不支持的功能"), r(t, "msg", "不支持的功能");
235
+ break;
236
+ case "ETIMEDOUT":
237
+ r(t, s, "连接超时"), r(t, "msg", "连接超时");
238
+ break;
239
+ case "ERR_BAD_REQUEST":
240
+ r(t, s, "错误的请求"), r(t, "msg", "错误的请求");
241
+ break;
242
+ case "ERR_BAD_RESPONSE":
243
+ if (r(t, s, "错误的响应"), r(t, "msg", "错误的响应"), t?.request?.responseText)
244
+ try {
245
+ const u = JSON.parse(t.request.responseText), d = m(u, s) || m(u, "msg");
246
+ d && (r(t, s, d), r(t, "msg", d));
247
+ } catch {
248
+ r(t, s, t.request.responseText), r(t, "msg", t.request.responseText);
249
+ }
250
+ break;
251
+ default:
252
+ r(t, s, t.message), r(t, "msg", t.message);
253
+ }
254
+ const y = m(t, s || "msg") || m(t, "msg");
255
+ throw t.code && typeof t.code == "string" ? (t.code = 0, p({
256
+ title: "请求错误",
257
+ description: y
258
+ }), t) : (b && setTimeout(() => {
259
+ h(y || "请求失败");
260
+ }, 300), t);
261
+ }
262
+ }
263
+ export {
264
+ T as g,
265
+ C as m,
266
+ z as n,
267
+ F as r
268
+ };
package/dist/es/scene.js CHANGED
@@ -1,10 +1,73 @@
1
- import { e as o, a as s, b as a, c as d, d as g, g as t, r as f } from "./scene-DeuRXFje.js";
1
+ import { v as n } from "./event-CGLPzfQO.js";
2
+ function s() {
3
+ return new Promise((r, t) => {
4
+ n.call("getUserInfo").then((e) => {
5
+ r(e);
6
+ }).catch((e) => {
7
+ t(e);
8
+ });
9
+ });
10
+ }
11
+ function a() {
12
+ return new Promise((r, t) => {
13
+ n.call("getCategoryInfo").then((e) => {
14
+ r(e);
15
+ }).catch((e) => {
16
+ t(e);
17
+ });
18
+ });
19
+ }
20
+ function d() {
21
+ return new Promise((r, t) => {
22
+ n.call("getGoodsInfo").then((e) => {
23
+ r(e);
24
+ }).catch((e) => {
25
+ t(e);
26
+ });
27
+ });
28
+ }
29
+ function f() {
30
+ return new Promise((r, t) => {
31
+ n.call("getGoodsOrder").then((e) => {
32
+ r(e);
33
+ }).catch((e) => {
34
+ t(e);
35
+ });
36
+ });
37
+ }
38
+ function h(r) {
39
+ return new Promise((t, e) => {
40
+ n.call("editGoodsOrder", r).then((o) => {
41
+ t(o);
42
+ }).catch((o) => {
43
+ e(o);
44
+ });
45
+ });
46
+ }
47
+ function i() {
48
+ return new Promise((r, t) => {
49
+ n.call("refreshGoodsOrder").then((e) => {
50
+ r(e);
51
+ }).catch((e) => {
52
+ t(e);
53
+ });
54
+ });
55
+ }
56
+ function g() {
57
+ return new Promise((r, t) => {
58
+ n.call("getRechargeOrderInfo").then((e) => {
59
+ r(e);
60
+ }).catch((e) => {
61
+ t(e);
62
+ });
63
+ });
64
+ }
2
65
  export {
3
- o as editGoodsOrder,
4
- s as getCategoryInfo,
5
- a as getGoodsInfo,
6
- d as getGoodsOrder,
66
+ h as editGoodsOrder,
67
+ a as getCategoryInfo,
68
+ d as getGoodsInfo,
69
+ f as getGoodsOrder,
7
70
  g as getRechargeOrderInfo,
8
- t as getUserInfo,
9
- f as refreshGoodsOrder
71
+ s as getUserInfo,
72
+ i as refreshGoodsOrder
10
73
  };