@skyfox2000/webui 1.4.10 → 1.4.12

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.
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as _, onMounted as I, createBlock as s, openBlock as o, unref as e, withCtx as l, createCommentVNode as r, createVNode as p, createElementVNode as x, createElementBlock as y, toDisplayString as g, renderSlot as h } from "vue";
2
2
  import { Layout as i, LayoutSider as k } from "ant-design-vue";
3
- import { a as b } from "./toolIcon-DDp0EFRE.js";
4
- import { I as C, _ as S, f as w, d as $, g as N } from "./menuTabs-D99nhxm_.js";
5
- import { ag as v, a as B, ai as E } from "./upload-template-BK8iQQYz.js";
3
+ import { a as b } from "./toolIcon-ChaoBuya.js";
4
+ import { I as C, _ as S, f as w, d as $, g as N } from "./menuTabs-L6-Txvgp.js";
5
+ import { ag as v, a as B, ai as E } from "./upload-template-cMYO_YLd.js";
6
6
  import "@skyfox2000/microbase";
7
7
  import "@skyfox2000/fapi";
8
8
  import L from "vue-m-message";
@@ -1,42 +1,42 @@
1
1
  var E = Object.defineProperty;
2
- var m = (n, r, a) => r in n ? E(n, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[r] = a;
3
- var f = (n, r, a) => m(n, typeof r != "symbol" ? r + "" : r, a);
2
+ var m = (n, r, s) => r in n ? E(n, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[r] = s;
3
+ var d = (n, r, s) => m(n, typeof r != "symbol" ? r + "" : r, s);
4
4
  import { hostUrl as w } from "@skyfox2000/fapi";
5
5
  import y from "dayjs";
6
- import d from "vue-m-message";
7
- import { ad as b, u as g } from "./upload-template-BK8iQQYz.js";
8
- import { isMicroApp as F } from "@skyfox2000/microbase";
6
+ import f from "vue-m-message";
7
+ import { ad as b, u as g } from "./upload-template-cMYO_YLd.js";
8
+ import { isMicroApp as O } from "@skyfox2000/microbase";
9
9
  var i = /* @__PURE__ */ ((n) => (n.Pending = "pending", n.Uploading = "uploading", n.Success = "success", n.Error = "error", n.Online = "online", n.Offline = "offline", n))(i || {});
10
- class I {
10
+ class x {
11
11
  /**
12
12
  * 连接路径参数,已判断 undefined 或 null 值
13
13
  * @param args 路径参数数组
14
14
  * @returns 连接后的路径字符串
15
15
  */
16
16
  static join(...r) {
17
- return r.filter((o) => o != null).join("/").replace(/[\/]+/, "/");
17
+ return r.filter((a) => a != null).join("/").replace(/[\/]+/, "/");
18
18
  }
19
19
  }
20
- class x {
20
+ class S {
21
21
  /**
22
22
  * AsyncUploader 构造函数
23
23
  * @param urlInfo 文件上传的 API 配置(IUrlInfo 对象)
24
24
  * @param maxConcurrent 最大允许并发上传的文件数量
25
25
  */
26
- constructor(r, a = 3) {
26
+ constructor(r, s = 3) {
27
27
  /**
28
28
  * 设置 API 端点和最大并发数,所有上传文件通过该类控制
29
29
  */
30
- f(this, "urlInfo");
30
+ d(this, "urlInfo");
31
31
  /**
32
32
  * 最大并发上传数
33
33
  */
34
- f(this, "maxConcurrent");
34
+ d(this, "maxConcurrent");
35
35
  /**
36
36
  * 控制上传任务的中断信号
37
37
  */
38
- f(this, "abortController");
39
- this.urlInfo = r, this.maxConcurrent = a;
38
+ d(this, "abortController");
39
+ this.urlInfo = r, this.maxConcurrent = s;
40
40
  }
41
41
  /**
42
42
  * 执行上传
@@ -47,17 +47,17 @@ class x {
47
47
  * @param onProgress 上传进度回调
48
48
  * @returns 上传结果
49
49
  */
50
- async doUpload(r, a, c, o, e) {
50
+ async doUpload(r, s, c, a, e) {
51
51
  if (r.length) {
52
52
  if (r.length === 0) {
53
- d.warning("请选择上传的文件!");
53
+ f.warning("请选择上传的文件!");
54
54
  return;
55
55
  }
56
- a.value = !0, await this.uploadFiles(r, e, (l) => {
56
+ s.value = !0, await this.uploadFiles(r, e, (l) => {
57
57
  let t = !1, h = 0;
58
- for (const s of l)
59
- s.status === i.Error && h++;
60
- h ? h < l.length ? c ? (d.error("上传结束,部分文件上传失败!"), d.warning("保存上传成功的文件!"), t = !0) : d.error("上传结束,部分文件上传失败,取消保存!") : d.error("上传结束,所有文件上传失败!") : (d.success("全部文件上传成功!"), t = !0), a.value = !1, o == null || o(t, l);
58
+ for (const o of l)
59
+ o.status === i.Error && h++;
60
+ h ? h < l.length ? c ? (f.error("上传结束,部分文件上传失败!"), f.warning("保存上传成功的文件!"), t = !0) : f.error("上传结束,部分文件上传失败,取消保存!") : f.error("上传结束,所有文件上传失败!") : (f.success("全部文件上传成功!"), t = !0), s.value = !1, a == null || a(t, l);
61
61
  });
62
62
  }
63
63
  }
@@ -67,9 +67,9 @@ class x {
67
67
  * @param onProgress 上传进度回调
68
68
  * @param onComplete 上传完成回调
69
69
  */
70
- async uploadFiles(r, a, c) {
70
+ async uploadFiles(r, s, c) {
71
71
  if (!r.length) return;
72
- const o = Math.min(this.maxConcurrent, r.length), e = [];
72
+ const a = Math.min(this.maxConcurrent, r.length), e = [];
73
73
  for (const t of r)
74
74
  switch (t.status) {
75
75
  case i.Success:
@@ -83,15 +83,15 @@ class x {
83
83
  const l = [];
84
84
  this.abortController = new AbortController();
85
85
  try {
86
- for (; l.length < o && e.length > 0; ) {
86
+ for (; l.length < a && e.length > 0; ) {
87
87
  const t = e.shift();
88
88
  if (!t) break;
89
- l.push(this.handleFileStatus(t, l, e, a));
89
+ l.push(this.handleFileStatus(t, l, e, s));
90
90
  }
91
91
  await Promise.all(l);
92
92
  } catch (t) {
93
93
  r.forEach((h) => {
94
- h.status = i.Error, h.error = t instanceof Error ? t : new Error("上传失败"), a == null || a(h);
94
+ h.status = i.Error, h.error = t instanceof Error ? t : new Error("上传失败"), s == null || s(h);
95
95
  });
96
96
  } finally {
97
97
  c == null || c(r);
@@ -104,17 +104,17 @@ class x {
104
104
  * @param pendingFiles 等待上传的文件列表
105
105
  * @param onProgress 上传进度回调
106
106
  */
107
- async handleFileStatus(r, a, c, o) {
107
+ async handleFileStatus(r, s, c, a) {
108
108
  try {
109
109
  await this.uploadFile(r, this.abortController.signal, (e) => {
110
- r.percent = e, o == null || o(r);
110
+ r.percent = e, a == null || a(r);
111
111
  });
112
112
  } catch (e) {
113
113
  r.error = e instanceof Error ? e : new Error("上传失败");
114
114
  } finally {
115
115
  if (c.length > 0) {
116
116
  const e = c.shift();
117
- e && a.push(this.handleFileStatus(e, a, c, o));
117
+ e && s.push(this.handleFileStatus(e, s, c, a));
118
118
  }
119
119
  }
120
120
  }
@@ -124,33 +124,33 @@ class x {
124
124
  * @param signal 中断信号
125
125
  * @param onProgress 上传进度回调
126
126
  */
127
- async uploadFile(r, a, c) {
128
- return r.status = i.Uploading, new Promise(async (o, e) => {
127
+ async uploadFile(r, s, c) {
128
+ return r.status = i.Uploading, new Promise(async (a, e) => {
129
129
  const l = new FormData();
130
130
  if (l.append("file", r.originFileObj), r.params)
131
- for (const s in r.params)
132
- l.append(s, r.params[s]);
131
+ for (const o in r.params)
132
+ l.append(o, r.params[o]);
133
133
  const t = new XMLHttpRequest(), h = w(this.urlInfo);
134
134
  if (h === !1) return Promise.resolve(r);
135
- if (t.open("POST", h, !0), this.urlInfo.header && typeof this.urlInfo.header == "object" && Object.entries(this.urlInfo.header).forEach(([s, u]) => {
136
- t.setRequestHeader(s, u);
135
+ if (t.open("POST", h, !0), this.urlInfo.header && typeof this.urlInfo.header == "object" && Object.entries(this.urlInfo.header).forEach(([o, u]) => {
136
+ t.setRequestHeader(o, u);
137
137
  }), this.urlInfo.authorize) {
138
- const s = F() ? await b.getToken() : g().getToken();
139
- if (!s) {
138
+ const o = O() ? await b.getToken() : g().getToken();
139
+ if (!o) {
140
140
  e(new Error("未授权或授权过期"));
141
141
  return;
142
142
  }
143
- t.setRequestHeader("Authorization", "Bearer " + s);
143
+ t.setRequestHeader("Authorization", "Bearer " + o);
144
144
  }
145
- t.upload.addEventListener("progress", (s) => {
146
- if (s.lengthComputable && s.total > 0) {
147
- const u = Math.round(s.loaded / s.total * 100);
145
+ t.upload.addEventListener("progress", (o) => {
146
+ if (o.lengthComputable && o.total > 0) {
147
+ const u = Math.round(o.loaded / o.total * 100);
148
148
  c(u);
149
149
  }
150
150
  }), t.addEventListener("load", () => {
151
151
  if (t.status >= 200 && t.status < 300) {
152
- const s = t.getResponseHeader("Content-Type");
153
- if (!s || !s.includes("application/json")) {
152
+ const o = t.getResponseHeader("Content-Type");
153
+ if (!o || !o.includes("application/json")) {
154
154
  e(new Error("返回的结果不是 JSON 格式"));
155
155
  return;
156
156
  }
@@ -166,7 +166,7 @@ class x {
166
166
  Type: r.type,
167
167
  UpdateTime: y().format("YYYY-MM-DD HH:mm:ss"),
168
168
  Status: i.Success
169
- }), r.status = i.Success, o(r);
169
+ }), r.status = i.Success, a(r);
170
170
  else {
171
171
  const p = u.msg;
172
172
  r.status = i.Error, e(new Error(p));
@@ -178,7 +178,7 @@ class x {
178
178
  r.status = i.Error, e(new Error(`上传失败,状态码:${t.status}`));
179
179
  }), t.addEventListener("error", () => {
180
180
  r.status = i.Error, e(new Error("上传失败,网络异常"));
181
- }), t.send(l), a.addEventListener("abort", () => {
181
+ }), t.send(l), s.addEventListener("abort", () => {
182
182
  t.abort(), e(new Error("上传已取消"));
183
183
  });
184
184
  });
@@ -190,8 +190,22 @@ class x {
190
190
  this.abortController && this.abortController.abort();
191
191
  }
192
192
  }
193
+ const M = async (n, r) => {
194
+ const s = new S(n, 1), c = [r];
195
+ await s.uploadFiles(
196
+ c,
197
+ (a) => {
198
+ r.percent = a.percent;
199
+ },
200
+ (a) => {
201
+ const e = a[0];
202
+ r.percent = e.percent, e.status === i.Success ? (r.status = i.Online, f.success("文件上传成功!")) : (r.status = i.Error, f.error("上传文件失败!"));
203
+ }
204
+ );
205
+ };
193
206
  export {
194
- x as A,
207
+ S as A,
195
208
  i as U,
196
- I as p
209
+ M as f,
210
+ x as p
197
211
  };
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as B, provide as N, ref as w, watch as p, onMounted as _, createBlock as n, openBlock as r, unref as a, withCtx as s, createElementVNode as b, renderSlot as C, createVNode as V, createCommentVNode as d, createTextVNode as u, toDisplayString as v } from "vue";
2
- import { _ as m } from "./index-C6BAsERS.js";
2
+ import { _ as m } from "./index-CTuByOKL.js";
3
3
  import { Modal as D, Space as $ } from "ant-design-vue";
4
4
  import "@skyfox2000/fapi";
5
- import { P as E, d as M, o as P, b as K } from "./upload-template-BK8iQQYz.js";
5
+ import { P as E, d as M, o as P, b as K } from "./upload-template-cMYO_YLd.js";
6
6
  import "@skyfox2000/microbase";
7
7
  import "vue-m-message";
8
8
  import "async-validator";
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as d, useAttrs as f, createElementBlock as u, openBlock as x, createVNode as e, withCtx as n, unref as o, mergeProps as r, renderSlot as p } from "vue";
2
2
  import { Button as _ } from "ant-design-vue";
3
- import { a as P, _ as k } from "./toolIcon-DDp0EFRE.js";
3
+ import { a as P, _ as k } from "./toolIcon-ChaoBuya.js";
4
4
  const C = /* @__PURE__ */ d({
5
5
  inheritAttrs: !1,
6
6
  __name: "index",
@@ -1,10 +1,10 @@
1
1
  import H from "async-validator";
2
2
  import { httpPost as M, ResStatus as V } from "@skyfox2000/fapi";
3
- import { i as T, al as U, L as $, u as z } from "./upload-template-BK8iQQYz.js";
3
+ import { i as T, al as U, L as $, u as z } from "./upload-template-cMYO_YLd.js";
4
4
  import m from "vue-m-message";
5
5
  import { defineComponent as _, useAttrs as B, createElementBlock as A, openBlock as b, createVNode as O, unref as v, mergeProps as S, computed as E, createBlock as R, withCtx as L, normalizeStyle as N } from "vue";
6
6
  import { Spin as K, Alert as P } from "ant-design-vue";
7
- import { _ as W } from "./toolIcon-DDp0EFRE.js";
7
+ import { _ as W } from "./toolIcon-ChaoBuya.js";
8
8
  const D = (i) => {
9
9
  const e = i.split(`
10
10
  `).filter((l) => l.trim() !== "");
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as x, createBlock as h, createCommentVNode as I, openBlock as u, unref as t, mergeProps as C, useAttrs as H, computed as j, ref as y, watch as k, withCtx as d, createElementBlock as g, normalizeStyle as T, createElementVNode as m, inject as W, onMounted as N, createVNode as l, toDisplayString as $, Fragment as R, createTextVNode as K, reactive as q, nextTick as J, renderList as X, withModifiers as Y } from "vue";
2
- import { a as w, _ as b } from "./toolIcon-DDp0EFRE.js";
3
- import { c as L, U as E, ai as P, X as M, W as U, u as D, ad as G, a as F, V as Q, r as V, ag as z } from "./upload-template-BK8iQQYz.js";
2
+ import { a as w, _ as b } from "./toolIcon-ChaoBuya.js";
3
+ import { c as L, U as E, ai as P, X as M, W as U, u as D, ad as G, a as F, V as Q, r as V, ag as z } from "./upload-template-cMYO_YLd.js";
4
4
  import { _ as Z } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
5
  import { theme as O, Breadcrumb as ee, Modal as te, Flex as ne, LayoutHeader as oe, Space as se, Menu as ie, Tabs as ce, TabPane as ae } from "ant-design-vue";
6
6
  import { isMicroApp as le } from "@skyfox2000/microbase";
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as i, createBlock as s, openBlock as l, unref as a, withCtx as p, renderSlot as f, createCommentVNode as u, mergeProps as d } from "vue";
2
2
  import { Tooltip as I } from "ant-design-vue";
3
3
  import { SERVER_HOST as r } from "@skyfox2000/fapi";
4
- import { c as S } from "./upload-template-BK8iQQYz.js";
4
+ import { c as S } from "./upload-template-cMYO_YLd.js";
5
5
  const T = /* @__PURE__ */ i({
6
6
  __name: "index",
7
7
  props: {