@glodon-aiot/agent-cli-ui 3.19.0-alpha.20 → 3.19.0-alpha.21

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,157 +1,154 @@
1
- var L = (M, P, u) => new Promise((a, I) => {
1
+ var b = (M, P, u) => new Promise((a, F) => {
2
2
  var R = (f) => {
3
3
  try {
4
4
  C(u.next(f));
5
- } catch (F) {
6
- I(F);
5
+ } catch (S) {
6
+ F(S);
7
7
  }
8
- }, w = (f) => {
8
+ }, N = (f) => {
9
9
  try {
10
10
  C(u.throw(f));
11
- } catch (F) {
12
- I(F);
11
+ } catch (S) {
12
+ F(S);
13
13
  }
14
- }, C = (f) => f.done ? a(f.value) : Promise.resolve(f.value).then(R, w);
14
+ }, C = (f) => f.done ? a(f.value) : Promise.resolve(f.value).then(R, N);
15
15
  C((u = u.apply(M, P)).next());
16
16
  });
17
- import { jsx as r, Fragment as fe, jsxs as g } from "react/jsx-runtime";
18
- import { message as Z, Upload as q, Button as _, Badge as he, Spin as me, Popover as ge, Space as ye } from "antd";
19
- import { forwardRef as xe, useState as A, useRef as J, useContext as Ce, useEffect as N, useImperativeHandle as Se } from "react";
20
- import { LoadingOutlined as Fe, CloseCircleFilled as Ne, CloudUploadOutlined as Ie } from "@ant-design/icons";
21
- /* empty css */import we from "lodash/debounce";
17
+ import { jsx as s, Fragment as pe, jsxs as g } from "react/jsx-runtime";
18
+ import { Upload as Z, Button as _, Badge as fe, Spin as he, Popover as me, Space as ge, message as ye } from "antd";
19
+ import { forwardRef as xe, useState as z, useRef as q, useContext as Ce, useEffect as A, useImperativeHandle as Se } from "react";
20
+ import { LoadingOutlined as Fe, CloseCircleFilled as Ne, CloudUploadOutlined as we } from "@ant-design/icons";
21
+ /* empty css */import Ie from "lodash/debounce";
22
22
  import Ee from "./FileCard/index.mjs";
23
23
  import { IFileOrigin as be } from "@glodon-aiot/apis";
24
24
  import ze from "./ClearModal/index.mjs";
25
25
  import $ from "../../../../components/Iconfont/index.mjs";
26
- import Le from "../../../../context.mjs";
27
- import { FILE_NAME_MAX_LENGTH as Q, fileTypes as Ae, isValidImageUrlWithAnyExtension as Ue } from "../../../../utils/index.mjs";
28
- import { MB as ke } from "../../../../constant.mjs";
29
- const j = 50, U = 10, ve = xe((M, P) => {
26
+ import Ae from "../../../../context.mjs";
27
+ import { FILE_NAME_MAX_LENGTH as J, fileTypes as Le, isValidImageUrlWithAnyExtension as Ue } from "../../../../utils/index.mjs";
28
+ import { withAgentCliMessage as ke } from "../../../../utils/scopedMessage.mjs";
29
+ import { MB as ve } from "../../../../constant.mjs";
30
+ const j = 50, L = 10, Me = xe((M, P) => {
30
31
  const {
31
32
  appId: u,
32
33
  sid: a,
33
- onStatusChange: I,
34
+ onStatusChange: F,
34
35
  createSession: R,
35
- disabled: w = !1,
36
+ disabled: N = !1,
36
37
  afterFileAdd: C,
37
38
  afterFileDelete: f,
38
- onFileListChange: F,
39
+ onFileListChange: S,
39
40
  shouldContinue: D = !0,
40
41
  afterFilesClear: K,
41
- docViewerUrl: Y,
42
- isFirstSession: ee
43
- } = M, [i, p] = A([]), c = J(i), [ne, k] = A([]), [te, O] = A(!1), [E, v] = A(""), b = J(D), [B, H] = A(!1), {
44
- Dragger: se
45
- } = q, {
42
+ docViewerUrl: Q,
43
+ isFirstSession: Y
44
+ } = M, [i, p] = z([]), c = q(i), [ee, U] = z([]), [ne, O] = z(!1), [w, k] = z(""), I = q(D), [B, H] = z(!1), {
45
+ Dragger: te
46
+ } = Z, {
46
47
  service: o,
47
- popupContainer: S
48
- } = Ce(Le);
49
- N(() => {
50
- b.current = D;
48
+ popupContainer: v
49
+ } = Ce(Ae);
50
+ A(() => {
51
+ I.current = D;
51
52
  }, [D]), Se(P, () => ({
52
53
  update: V,
53
54
  clear: X,
54
55
  appendFiles: (e) => {
55
- if (w)
56
+ if (N)
56
57
  return;
57
58
  Array.from(e || []).forEach((n) => {
58
59
  T(n);
59
60
  });
60
61
  }
61
- })), N(() => {
62
- ee || (k([]), p([]), V());
62
+ })), A(() => {
63
+ Y || (U([]), p([]), V());
63
64
  }, [a]);
64
- const V = () => a ? new Promise((e, s) => {
65
+ const V = () => a ? new Promise((e, r) => {
65
66
  o == null || o.getApplicationIdSessionKnowledgeFiles(u, a, {
66
67
  //1是未开启
67
68
  enabled: 1
68
69
  }).then((n) => {
69
- k(n), p(n), re(n);
70
+ U(n), p(n), re(n);
70
71
  }).finally(() => {
71
72
  e();
72
73
  });
73
- }) : Promise.resolve(), re = (e) => L(void 0, null, function* () {
74
- a && (e == null || e.map((s) => L(void 0, null, function* () {
74
+ }) : Promise.resolve(), re = (e) => b(void 0, null, function* () {
75
+ a && (e == null || e.map((r) => b(void 0, null, function* () {
75
76
  var n;
76
77
  try {
77
- if (yield o == null ? void 0 : o.checkFileReady(u, a, s.id)) {
78
- const l = [...c.current], h = e.findIndex((d) => d.id === s.id);
79
- h !== -1 && (l[h].status = 2), p(l), C && C(s, a);
78
+ if (yield o == null ? void 0 : o.checkFileReady(u, a, r.id)) {
79
+ const l = [...c.current], h = e.findIndex((d) => d.id === r.id);
80
+ h !== -1 && (l[h].status = 2), p(l), C && C(r, a);
80
81
  }
81
82
  } catch (t) {
82
83
  if (((n = t.cause) == null ? void 0 : n.code) === -101) {
83
- const l = [...c.current], h = e.findIndex((d) => d.id === s.id);
84
+ const l = [...c.current], h = e.findIndex((d) => d.id === r.id);
84
85
  h !== -1 && (l[h].status = 3), p(l);
85
86
  return;
86
87
  }
87
88
  }
88
89
  })));
89
90
  });
90
- N(() => {
91
- Z.config({
92
- getContainer: () => (S == null ? void 0 : S.current) || document.body,
93
- prefixCls: "gbot-message",
94
- maxCount: 5
95
- });
96
- }, [S]), N(() => {
97
- I && I(E);
98
- }, [E]);
99
- const y = (e, s) => {
100
- Z.open({
101
- type: e,
102
- content: s
91
+ A(() => {
92
+ F && F(w);
93
+ }, [w]);
94
+ const y = (e, r) => {
95
+ ke(v, () => {
96
+ ye.open({
97
+ type: e,
98
+ content: r
99
+ });
103
100
  });
104
- }, T = (e) => L(void 0, null, function* () {
101
+ }, T = (e) => b(void 0, null, function* () {
105
102
  if (e.size <= 0)
106
103
  return y("error", "该文件为空,请重新上传文档"), !1;
107
- if (e.name.length > Q)
108
- return y("error", `文件名称不能超过${Q}字符`), !1;
109
- if (e.size > j * ke)
104
+ if (e.name.length > J)
105
+ return y("error", `文件名称不能超过${J}字符`), !1;
106
+ if (e.size > j * ve)
110
107
  return y("error", `${e.name}文件大小不能超过 ${j}M`), !1;
111
- if (Ae.some((t) => t === e.type)) {
108
+ if (Le.some((t) => t === e.type)) {
112
109
  const t = e;
113
- t.status = 1, p((l) => l.length >= U ? (W(`文件最多上传${U}个`), l) : [...l, t]);
110
+ t.status = 1, p((l) => l.length >= L ? (W(`文件最多上传${L}个`), l) : [...l, t]);
114
111
  } else
115
112
  W("存在文件格式不正确的文件,已自动去除");
116
113
  return !1;
117
114
  });
118
- N(() => {
119
- if (i.length < U ? O(!1) : O(!0), !i.length) {
120
- v("");
115
+ A(() => {
116
+ if (i.length < L ? O(!1) : O(!0), !i.length) {
117
+ k("");
121
118
  return;
122
119
  }
123
- const e = i.find((t) => t.status === 1), s = i.find((t) => t.status === 3);
124
- i.every((t) => t.status === 2) ? v("successed") : e ? v("process") : s && v("failed"), F && F(i);
125
- }, [i]), N(() => {
120
+ const e = i.find((t) => t.status === 1), r = i.find((t) => t.status === 3);
121
+ i.every((t) => t.status === 2) ? k("successed") : e ? k("process") : r && k("failed"), S && S(i);
122
+ }, [i]), A(() => {
126
123
  c.current = i;
127
- const e = i.filter((s) => !ne.includes(s));
128
- ae(e), k(i);
124
+ const e = i.filter((r) => !ee.includes(r));
125
+ ie(e), U(i);
129
126
  }, [i]);
130
- const oe = (e, s, n) => L(void 0, null, function* () {
127
+ const se = (e, r, n) => b(void 0, null, function* () {
131
128
  var h;
132
129
  const t = [...c.current], l = c.current.findIndex((d) => d === n);
133
- l !== -1 && (t[l].id = s), p(t);
130
+ l !== -1 && (t[l].id = r), p(t);
134
131
  try {
135
- const d = yield o == null ? void 0 : o.checkFileReady(u, e, s, () => b.current, void 0, (m) => {
136
- const x = [...c.current], z = c.current.findIndex((pe) => pe === n);
137
- x[z].url = m.url, p(x);
132
+ const d = yield o == null ? void 0 : o.checkFileReady(u, e, r, () => I.current, void 0, (m) => {
133
+ const x = [...c.current], E = c.current.findIndex((ue) => ue === n);
134
+ x[E].url = m.url, p(x);
138
135
  });
139
136
  if (d) {
140
- const m = [...c.current], x = c.current.findIndex((z) => z === n);
137
+ const m = [...c.current], x = c.current.findIndex((E) => E === n);
141
138
  x !== -1 && (m[x].status = 2, m[x].url = d.url), p(m), C && C(d, e);
142
139
  }
143
140
  } catch (d) {
144
141
  if (((h = d.cause) == null ? void 0 : h.code) === -101) {
145
- const m = [...c.current], x = c.current.findIndex((z) => z === n);
142
+ const m = [...c.current], x = c.current.findIndex((E) => E === n);
146
143
  x !== -1 && (m[x].status = 3), p(m);
147
144
  return;
148
145
  }
149
146
  }
150
- }), ie = () => a ? Promise.resolve(a) : R(), ae = (e) => {
151
- e.length && ie().then((s) => {
147
+ }), oe = () => a ? Promise.resolve(a) : R(), ie = (e) => {
148
+ e.length && oe().then((r) => {
152
149
  e == null || e.forEach((n) => {
153
150
  var t;
154
- b.current = !0, (t = ue(s, n)) == null || t.then((l) => {
151
+ I.current = !0, (t = ce(r, n)) == null || t.then((l) => {
155
152
  var d;
156
153
  if (!l)
157
154
  return;
@@ -162,26 +159,26 @@ const j = 50, U = 10, ve = xe((M, P) => {
162
159
  type: 1,
163
160
  origin: be.AECPILOT
164
161
  };
165
- b.current && ((d = le(s, h)) == null || d.then((m) => oe(s, m, n)));
162
+ I.current && ((d = ae(r, h)) == null || d.then((m) => se(r, m, n)));
166
163
  });
167
164
  });
168
165
  });
169
- }, le = (e, s) => o == null ? void 0 : o.postApplicationIdSessionKnowledgeSessionFile(u, e, s), W = we((e) => {
166
+ }, ae = (e, r) => o == null ? void 0 : o.postApplicationIdSessionKnowledgeSessionFile(u, e, r), W = Ie((e) => {
170
167
  y("error", e);
171
- }, 300), de = (e) => {
172
- a && e != null && e.id && (o == null || o.delApplicationIdSessionKnowledgeFileId(u, a, e.id).then((s) => {
168
+ }, 300), le = (e) => {
169
+ a && e != null && e.id && (o == null || o.delApplicationIdSessionKnowledgeFileId(u, a, e.id).then((r) => {
173
170
  const n = i.filter((t) => t.id !== e.id);
174
171
  p(n), y("success", "删除成功"), f && f(e.id);
175
172
  }));
176
- }, ce = /* @__PURE__ */ r(fe, {
173
+ }, de = /* @__PURE__ */ s(pe, {
177
174
  children: /* @__PURE__ */ g("div", {
178
175
  className: "card-title",
179
- children: [/* @__PURE__ */ r("span", {
176
+ children: [/* @__PURE__ */ s("span", {
180
177
  className: "name",
181
178
  children: "上传列表"
182
179
  }), /* @__PURE__ */ g("div", {
183
180
  className: "actions",
184
- children: [/* @__PURE__ */ r(q, {
181
+ children: [/* @__PURE__ */ s(Z, {
185
182
  accept: ".doc, .docx, .pdf",
186
183
  beforeUpload: T,
187
184
  showUploadList: !1,
@@ -189,23 +186,23 @@ const j = 50, U = 10, ve = xe((M, P) => {
189
186
  margin: 0
190
187
  },
191
188
  multiple: !0,
192
- children: /* @__PURE__ */ r(_, {
189
+ children: /* @__PURE__ */ s(_, {
193
190
  className: "action",
194
191
  type: "link",
195
- disabled: te,
192
+ disabled: ne,
196
193
  children: /* @__PURE__ */ g("div", {
197
194
  className: "detail",
198
- children: [/* @__PURE__ */ r($, {
195
+ children: [/* @__PURE__ */ s($, {
199
196
  type: "icon-tianjia",
200
197
  style: {
201
198
  fontSize: 16
202
199
  }
203
- }), /* @__PURE__ */ r("div", {
200
+ }), /* @__PURE__ */ s("div", {
204
201
  children: "添加"
205
202
  })]
206
203
  })
207
204
  })
208
- }), /* @__PURE__ */ r(_, {
205
+ }), /* @__PURE__ */ s(_, {
209
206
  className: "action",
210
207
  type: "link",
211
208
  disabled: !i.length,
@@ -214,42 +211,42 @@ const j = 50, U = 10, ve = xe((M, P) => {
214
211
  },
215
212
  children: /* @__PURE__ */ g("div", {
216
213
  className: "detail",
217
- children: [/* @__PURE__ */ r($, {
214
+ children: [/* @__PURE__ */ s($, {
218
215
  type: "icon-shanchu",
219
216
  style: {
220
217
  fontSize: 16
221
218
  }
222
- }), /* @__PURE__ */ r("span", {
219
+ }), /* @__PURE__ */ s("span", {
223
220
  children: "清空"
224
221
  })]
225
222
  })
226
223
  })]
227
224
  })]
228
225
  })
229
- }), ue = (e, s) => {
226
+ }), ce = (e, r) => {
230
227
  if (!e)
231
228
  throw Error("session is not exist.");
232
- return o == null ? void 0 : o.uploadFile(e, s).catch(() => (y("error", "服务异常,请稍后再试"), ""));
233
- }, G = /* @__PURE__ */ r("div", {
234
- className: `upload-enter ${w ? "disabled" : ""}`,
235
- children: /* @__PURE__ */ r(he, {
229
+ return o == null ? void 0 : o.uploadFile(e, r).catch(() => (y("error", "服务异常,请稍后再试"), ""));
230
+ }, G = /* @__PURE__ */ s("div", {
231
+ className: `upload-enter ${N ? "disabled" : ""}`,
232
+ children: /* @__PURE__ */ s(fe, {
236
233
  size: "small",
237
234
  color: "#9C24F2",
238
- count: E === "successed" ? i.length : E === "process" ? /* @__PURE__ */ r(me, {
235
+ count: w === "successed" ? i.length : w === "process" ? /* @__PURE__ */ s(he, {
239
236
  className: "file-action file-process",
240
- indicator: /* @__PURE__ */ r(Fe, {
237
+ indicator: /* @__PURE__ */ s(Fe, {
241
238
  style: {
242
239
  fontSize: 14
243
240
  },
244
241
  spin: !0
245
242
  })
246
- }) : E === "failed" ? /* @__PURE__ */ r(Ne, {
243
+ }) : w === "failed" ? /* @__PURE__ */ s(Ne, {
247
244
  style: {
248
245
  color: "#dc4446",
249
246
  fontSize: 14
250
247
  }
251
248
  }) : 0,
252
- children: /* @__PURE__ */ r($, {
249
+ children: /* @__PURE__ */ s($, {
253
250
  type: "icon-shangchuanwenjian",
254
251
  style: {
255
252
  fontSize: 24
@@ -257,22 +254,22 @@ const j = 50, U = 10, ve = xe((M, P) => {
257
254
  })
258
255
  })
259
256
  }), X = () => new Promise((e) => {
260
- const s = c.current;
257
+ const r = c.current;
261
258
  if (!a)
262
259
  return e();
263
260
  const n = [];
264
- s.filter((t) => t.id).forEach((t) => n.push({
261
+ r.filter((t) => t.id).forEach((t) => n.push({
265
262
  id: t.id,
266
263
  status: t.status
267
264
  })), o == null || o.delApplicationIdSessionKnowledgeFile(u, a, {
268
265
  files: n
269
266
  }).then(() => {
270
- k([]), p([]), c.current = [], K && K(), b.current = !1, e();
267
+ U([]), p([]), c.current = [], K && K(), I.current = !1, e();
271
268
  });
272
269
  });
273
270
  return /* @__PURE__ */ g("div", {
274
271
  className: "footer-upload",
275
- children: [w ? G : /* @__PURE__ */ r(ge, {
272
+ children: [N ? G : /* @__PURE__ */ s(me, {
276
273
  overlayClassName: "upload-popover",
277
274
  overlayInnerStyle: {
278
275
  width: 264,
@@ -282,18 +279,18 @@ const j = 50, U = 10, ve = xe((M, P) => {
282
279
  zIndex: 1
283
280
  },
284
281
  placement: "topLeft",
285
- getPopupContainer: () => (S == null ? void 0 : S.current) || document.body,
286
- content: /* @__PURE__ */ r("div", {
282
+ getPopupContainer: () => (v == null ? void 0 : v.current) || document.body,
283
+ content: /* @__PURE__ */ s("div", {
287
284
  className: "file-upload",
288
- children: i.length > 0 ? /* @__PURE__ */ r("div", {
285
+ children: i.length > 0 ? /* @__PURE__ */ s("div", {
289
286
  className: "upload-wrapper",
290
- children: /* @__PURE__ */ r("div", {
287
+ children: /* @__PURE__ */ s("div", {
291
288
  className: "input-files",
292
289
  style: {
293
290
  display: "flex",
294
291
  flexDirection: "column"
295
292
  },
296
- children: i == null ? void 0 : i.map((e, s) => /* @__PURE__ */ r(Ee, {
293
+ children: i == null ? void 0 : i.map((e, r) => /* @__PURE__ */ s(Ee, {
297
294
  file: e,
298
295
  actions: {
299
296
  preview: () => {
@@ -305,10 +302,10 @@ const j = 50, U = 10, ve = xe((M, P) => {
305
302
  y("error", "链接格式不正确");
306
303
  return;
307
304
  }
308
- window.open(`${Y}?url=${encodeURIComponent(e == null ? void 0 : e.url)}`);
305
+ window.open(`${Q}?url=${encodeURIComponent(e == null ? void 0 : e.url)}`);
309
306
  },
310
307
  remove: () => {
311
- de(e);
308
+ le(e);
312
309
  },
313
310
  download: () => {
314
311
  a && (o == null || o.getApplicationIdSessionKnowledgeFileId(u, a, e.id).then((n) => {
@@ -321,22 +318,22 @@ const j = 50, U = 10, ve = xe((M, P) => {
321
318
  }));
322
319
  }
323
320
  }
324
- }, s))
321
+ }, r))
325
322
  })
326
- }) : /* @__PURE__ */ g(se, {
323
+ }) : /* @__PURE__ */ g(te, {
327
324
  name: "file",
328
325
  showUploadList: !1,
329
326
  multiple: !0,
330
327
  beforeUpload: T,
331
328
  accept: ".pdf, .doc, .docx",
332
- maxCount: U,
329
+ maxCount: L,
333
330
  listType: "picture",
334
- children: [/* @__PURE__ */ r("span", {
331
+ children: [/* @__PURE__ */ s("span", {
335
332
  className: "file-upload-icon",
336
- children: /* @__PURE__ */ r(Ie, {})
337
- }), /* @__PURE__ */ g(ye, {
333
+ children: /* @__PURE__ */ s(we, {})
334
+ }), /* @__PURE__ */ g(ge, {
338
335
  className: "file-upload-action",
339
- children: ["拖拽文件至此,或者", /* @__PURE__ */ r(_, {
336
+ children: ["拖拽文件至此,或者", /* @__PURE__ */ s(_, {
340
337
  type: "link",
341
338
  style: {
342
339
  padding: 0
@@ -345,9 +342,9 @@ const j = 50, U = 10, ve = xe((M, P) => {
345
342
  })]
346
343
  }), /* @__PURE__ */ g("div", {
347
344
  className: "file-upload-desc",
348
- children: [/* @__PURE__ */ r("div", {
345
+ children: [/* @__PURE__ */ s("div", {
349
346
  className: "item-upload-desc",
350
- children: /* @__PURE__ */ r("span", {
347
+ children: /* @__PURE__ */ s("span", {
351
348
  children: "1.支持 doc、pdf、docx 格式;"
352
349
  })
353
350
  }), /* @__PURE__ */ g("div", {
@@ -355,15 +352,15 @@ const j = 50, U = 10, ve = xe((M, P) => {
355
352
  children: ["2.单个文件不超过 ", j, " M;"]
356
353
  }), /* @__PURE__ */ g("div", {
357
354
  className: "item-upload-desc",
358
- children: ["3.最多上传 ", U, " 个文件。"]
355
+ children: ["3.最多上传 ", L, " 个文件。"]
359
356
  })]
360
357
  })]
361
358
  })
362
359
  }),
363
- title: ce,
360
+ title: de,
364
361
  trigger: "click",
365
362
  children: G
366
- }), B && /* @__PURE__ */ r(ze, {
363
+ }), B && /* @__PURE__ */ s(ze, {
367
364
  isvisible: B,
368
365
  onClose: (e) => {
369
366
  e === "clear" && X(), H(!1);
@@ -371,7 +368,7 @@ const j = 50, U = 10, ve = xe((M, P) => {
371
368
  })]
372
369
  });
373
370
  });
374
- ve.displayName = "UploadFiles";
371
+ Me.displayName = "UploadFiles";
375
372
  export {
376
- ve as default
373
+ Me as default
377
374
  };