yc-component 0.1.12 → 0.1.14

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.
Files changed (39) hide show
  1. package/dist/ai-task/style.css +1 -1
  2. package/dist/image-selector/components/YcImageSelectorDialog.d.ts +7 -6
  3. package/dist/image-selector/components/YcImageSelectorDialog.d.ts.map +1 -1
  4. package/dist/image-selector/components/YcImageSelectorProvider.d.ts +8 -8
  5. package/dist/image-selector/components/YcImageSelectorProvider.d.ts.map +1 -1
  6. package/dist/image-selector/composables/useImageSelector.d.ts +3 -3
  7. package/dist/image-selector/composables/useImageSelector.d.ts.map +1 -1
  8. package/dist/image-selector/config.d.ts +3 -1
  9. package/dist/image-selector/config.d.ts.map +1 -1
  10. package/dist/image-selector/context.d.ts +4 -2
  11. package/dist/image-selector/context.d.ts.map +1 -1
  12. package/dist/image-selector/dialog-state.d.ts +8 -2
  13. package/dist/image-selector/dialog-state.d.ts.map +1 -1
  14. package/dist/image-selector/errors.d.ts +5 -0
  15. package/dist/image-selector/errors.d.ts.map +1 -0
  16. package/dist/image-selector/index.d.ts +3 -1
  17. package/dist/image-selector/index.d.ts.map +1 -1
  18. package/dist/image-selector/inject.d.ts +3 -1
  19. package/dist/image-selector/inject.d.ts.map +1 -1
  20. package/dist/image-selector/service.d.ts +4 -0
  21. package/dist/image-selector/service.d.ts.map +1 -0
  22. package/dist/image-selector/style.css +1 -1
  23. package/dist/image-selector/types/index.d.ts +2 -1
  24. package/dist/image-selector/types/index.d.ts.map +1 -1
  25. package/dist/index.css +1 -1
  26. package/dist/page-window/YcPageWindow.d.ts +9 -9
  27. package/dist/page-window/YcPageWindow.d.ts.map +1 -1
  28. package/dist/page-window/style.css +1 -1
  29. package/dist/plugin.d.ts +2 -0
  30. package/dist/plugin.d.ts.map +1 -1
  31. package/dist/yc-component.cjs.full.js +22 -22
  32. package/dist/yc-component.cjs.js +2 -2
  33. package/dist/yc-component.esm.full.js +6237 -6167
  34. package/dist/yc-component.esm.js +1525 -1456
  35. package/dist/yc-component.umd.full.js +46 -46
  36. package/dist/yc-component.umd.full.min.js +1 -1
  37. package/dist/yc-component.umd.js +3 -3
  38. package/dist/yc-component.umd.min.js +1 -1
  39. package/package.json +1 -1
@@ -1,54 +1,54 @@
1
- import Ze from "axios";
2
- import { defineComponent as ue, ref as k, computed as B, watch as te, onBeforeUnmount as Mt, resolveComponent as O, resolveDirective as et, openBlock as d, createBlock as M, Transition as tt, withCtx as p, withDirectives as ve, createElementVNode as _, normalizeStyle as He, createVNode as f, unref as h, toDisplayString as V, createElementBlock as A, createCommentVNode as P, createTextVNode as q, renderSlot as Ce, Fragment as ae, vShow as Ee, reactive as nt, inject as Oe, onMounted as Fe, onUnmounted as Ue, renderList as ge, Teleport as Et, normalizeClass as re, provide as $e, normalizeProps as $t, mergeProps as ot, withKeys as Pt, withModifiers as Lt, nextTick as Je, isRef as Dt } from "vue";
3
- import { ArrowLeft as Bt, ArrowUpBold as Vt, ArrowDownBold as Ot, Switch as Ft, Close as at, Check as lt, Refresh as Xe, ArrowDown as Ut, CircleCheck as Rt, CircleClose as Kt, Remove as Nt, Search as zt, Upload as Yt } from "@element-plus/icons-vue";
4
- import { storeToRefs as Wt, defineStore as jt } from "pinia";
1
+ import ot from "axios";
2
+ import { reactive as lt, defineComponent as ce, computed as D, ref as b, watch as ne, onMounted as Re, onUnmounted as Ke, resolveComponent as V, resolveDirective as at, openBlock as d, createBlock as E, withCtx as p, createElementVNode as h, createVNode as f, withKeys as Ot, unref as w, createCommentVNode as $, createTextVNode as W, createElementBlock as M, normalizeClass as ue, toDisplayString as B, Fragment as ie, renderList as ve, withDirectives as _e, withModifiers as Ut, nextTick as Xe, render as Ft, onBeforeUnmount as Rt, Transition as it, normalizeStyle as Qe, renderSlot as Ce, vShow as Le, inject as Ne, Teleport as Kt, provide as De, normalizeProps as Nt, mergeProps as st, isRef as zt } from "vue";
5
3
  import { ElMessage as Z } from "element-plus";
6
- const Re = {
4
+ import { Search as Yt, Upload as jt, Check as rt, ArrowLeft as Gt, ArrowUpBold as Wt, ArrowDownBold as qt, Switch as Ht, Close as ut, Refresh as Ze, ArrowDown as Jt, CircleCheck as Xt, CircleClose as Qt, Remove as Zt } from "@element-plus/icons-vue";
5
+ import { storeToRefs as en, defineStore as tn } from "pinia";
6
+ const ze = {
7
7
  projectId: "default-project",
8
8
  storageKey: "yc-ai-task-queue-v1"
9
9
  };
10
- let _e = { ...Re };
11
- function Gt(e) {
12
- _e = { ..._e, ...e };
10
+ let he = { ...ze };
11
+ function nn(e) {
12
+ he = { ...he, ...e };
13
13
  }
14
- function it() {
15
- return _e;
14
+ function ct() {
15
+ return he;
16
16
  }
17
- function qt() {
18
- return _e.projectId ?? Re.projectId;
17
+ function on() {
18
+ return he.projectId ?? ze.projectId;
19
19
  }
20
- function st() {
21
- return _e.storageKey ?? Re.storageKey;
20
+ function dt() {
21
+ return he.storageKey ?? ze.storageKey;
22
22
  }
23
- let le = null;
24
- function Ht() {
25
- le = null;
23
+ let re = null;
24
+ function ln() {
25
+ re = null;
26
26
  }
27
- function ce() {
28
- if (le) return le;
29
- const { baseURL: e, getToken: n, onUnauthorized: t } = it();
30
- return le = Ze.create({
27
+ function de() {
28
+ if (re) return re;
29
+ const { baseURL: e, getToken: n, onUnauthorized: t } = ct();
30
+ return re = ot.create({
31
31
  baseURL: e ?? "",
32
32
  timeout: 6e4,
33
33
  headers: { "Content-Type": "application/json" }
34
- }), le.interceptors.request.use((o) => {
34
+ }), re.interceptors.request.use((o) => {
35
35
  const l = n == null ? void 0 : n();
36
36
  return l && (o.headers.Authorization = `Bearer ${l}`), o;
37
- }), le.interceptors.response.use(
37
+ }), re.interceptors.response.use(
38
38
  (o) => {
39
39
  const l = o.data;
40
40
  return (l == null ? void 0 : l.code) != null && l.code !== 200 ? Promise.reject(new Error(l.message || "请求失败")) : (o.data = (l == null ? void 0 : l.data) ?? l, o);
41
41
  },
42
42
  (o) => {
43
- var g, w, S;
44
- ((g = o.response) == null ? void 0 : g.status) === 401 && (t == null || t());
45
- const l = (S = (w = o.response) == null ? void 0 : w.data) == null ? void 0 : S.message;
43
+ var m, y, T;
44
+ ((m = o.response) == null ? void 0 : m.status) === 401 && (t == null || t());
45
+ const l = (T = (y = o.response) == null ? void 0 : y.data) == null ? void 0 : T.message;
46
46
  return Promise.reject(new Error(l || o.message || "请求失败"));
47
47
  }
48
- ), le;
48
+ ), re;
49
49
  }
50
- async function Jt(e, n) {
51
- const o = (await ce().get(
50
+ async function an(e, n) {
51
+ const o = (await de().get(
52
52
  `/yc-ai/workflows/runs/${e}/artifacts/${n}`,
53
53
  { transformResponse: [(l) => l] }
54
54
  )).data;
@@ -60,144 +60,727 @@ async function Jt(e, n) {
60
60
  }
61
61
  return o;
62
62
  }
63
- let Pe = {};
64
- function Xt(e) {
65
- Pe = { ...Pe, ...e };
63
+ let Be = {};
64
+ function sn(e) {
65
+ Be = { ...Be, ...e };
66
66
  }
67
- function Ke() {
68
- return Pe;
67
+ function ke() {
68
+ return Be;
69
69
  }
70
- const Qt = { class: "yc-page-window__header" }, Zt = { class: "yc-page-window__title" }, en = {
70
+ class Se extends Error {
71
+ constructor(n = "Image selector cancelled") {
72
+ super(n), this.name = "ImageSelectorCancelledError";
73
+ }
74
+ }
75
+ let ee = null;
76
+ function rn() {
77
+ return ee && (ee.reject(new Se()), ee = null), new Promise((e, n) => {
78
+ ee = { resolve: e, reject: n };
79
+ });
80
+ }
81
+ function un(e) {
82
+ ee == null || ee.resolve(e), ee = null;
83
+ }
84
+ function et() {
85
+ ee == null || ee.reject(new Se()), ee = null;
86
+ }
87
+ const Pe = "__YC_COMPONENT_IMAGE_SELECTOR__", Ve = "yc-component:image-selector-open";
88
+ function cn() {
89
+ const e = globalThis;
90
+ return e[Pe] || (e[Pe] = lt({
91
+ visible: !1,
92
+ options: {}
93
+ })), e[Pe];
94
+ }
95
+ const H = cn();
96
+ function dn(e = {}) {
97
+ H.options = { ...e }, H.visible = !0, globalThis.dispatchEvent(
98
+ new CustomEvent(Ve, { detail: { ...e } })
99
+ );
100
+ }
101
+ function ft() {
102
+ H.visible = !1;
103
+ }
104
+ function pt() {
105
+ ft();
106
+ }
107
+ function mt(e = {}) {
108
+ const n = rn();
109
+ return dn(e), n;
110
+ }
111
+ const fn = { class: "yc-image-selector" }, pn = { class: "yc-image-selector__toolbar" }, mn = { class: "yc-image-selector__body" }, gn = {
71
112
  key: 0,
72
- class: "yc-page-window__nav"
73
- }, tn = { class: "yc-page-window__opera" }, nn = { class: "yc-page-window__content" }, on = /* @__PURE__ */ ue({
74
- __name: "YcPageWindow",
113
+ class: "yc-image-selector__aside"
114
+ }, vn = ["onClick"], _n = {
115
+ key: 0,
116
+ class: "yc-image-selector__category-count"
117
+ }, hn = { class: "yc-image-selector__main" }, yn = {
118
+ key: 1,
119
+ class: "yc-image-selector__grid"
120
+ }, wn = ["onClick"], Tn = { class: "yc-image-selector__thumb" }, In = ["src", "alt", "onLoad"], Cn = {
121
+ key: 0,
122
+ class: "yc-image-selector__order"
123
+ }, Sn = ["title"], kn = {
124
+ key: 0,
125
+ class: "yc-image-selector__selected-bar"
126
+ }, xn = { class: "yc-image-selector__selected-bar-label" }, bn = { class: "yc-image-selector__selected-bar-list" }, An = ["onClick"], Mn = ["src", "alt"], En = {
127
+ key: 1,
128
+ class: "yc-image-selector__pagination"
129
+ }, Pn = {
130
+ key: 0,
131
+ class: "yc-image-selector__footer"
132
+ }, $n = { class: "yc-image-selector__selected-tip" }, Ln = { class: "yc-image-selector__footer-actions" }, Dn = {
133
+ key: 1,
134
+ class: "yc-image-selector__footer yc-image-selector__footer--quick"
135
+ }, Bn = { class: "yc-image-selector__selected-tip" }, Vn = /* @__PURE__ */ ce({
136
+ __name: "YcImageSelectorDialog",
75
137
  props: {
76
- visible: { type: Boolean },
77
- title: { default: "" },
78
- type: { default: "" },
79
- showButtons: { type: Boolean, default: !0 },
80
- showConfirm: { type: Boolean, default: !0 },
81
- contentMinHeight: { default: "calc(100vh - 175px)" },
138
+ modelValue: { type: [Boolean, null], default: null },
139
+ title: { default: "选择图片" },
140
+ multiple: { type: Boolean, default: !1 },
141
+ maxCount: { default: 9 },
142
+ selected: {},
143
+ width: { default: "860px" },
144
+ pageSize: { default: 8 },
145
+ showUpload: { type: Boolean, default: !0 },
146
+ accept: { default: "image/*" },
147
+ showCategories: { type: Boolean, default: !1 },
148
+ categories: {},
149
+ categoryAllLabel: { default: "全部" },
150
+ showModeSwitch: { type: Boolean, default: !1 },
151
+ confirmOnSelect: { type: Boolean, default: !1 },
152
+ confirmText: { default: "确定" },
82
153
  cancelText: { default: "取消" },
83
- confirmText: { default: "保存" },
84
- disabled: { type: Boolean, default: !1 },
85
- loading: { type: Boolean, default: !1 },
86
- zIndex: { default: 9 },
87
- list: { default: () => [] },
88
- row: { default: null },
89
- rowKey: { default: "id" }
154
+ emptyText: { default: "暂无图片资源" },
155
+ getImages: {},
156
+ upload: {},
157
+ urlField: { default: "url" }
90
158
  },
91
- emits: ["update:visible", "update:type", "confirm", "close", "opened", "changeType", "prev", "next", "checkRow"],
92
- setup(e, { expose: n, emit: t }) {
93
- const o = e, l = t, g = k(!1), w = B(() => o.loading || g.value), S = B(() => o.type === "detail" ? "详情" : o.type === "edit" ? "编辑" : o.type === "add" ? "新增" : ""), m = B(
94
- () => o.list.length > 0 && o.row != null
95
- ), r = B(
96
- () => ["detail", "edit"].includes(o.type)
97
- ), L = B(() => o.type !== "detail");
98
- function U() {
99
- if (!o.row) return -1;
100
- const C = o.rowKey, F = o.row[C];
101
- return o.list.findIndex((Y) => Y[C] === F);
159
+ emits: ["update:modelValue", "confirm", "cancel"],
160
+ setup(e, { emit: n }) {
161
+ const t = e, o = n, l = D(() => t.modelValue != null), m = b(!1);
162
+ ne(
163
+ () => t.modelValue,
164
+ (i) => {
165
+ l.value && (m.value = !!i);
166
+ },
167
+ { immediate: !0 }
168
+ ), ne(m, (i) => {
169
+ if (l.value) {
170
+ o("update:modelValue", i);
171
+ return;
172
+ }
173
+ H.visible = i, i || ft();
174
+ }), ne(
175
+ () => H.visible,
176
+ (i) => {
177
+ l.value || (m.value = i);
178
+ },
179
+ { immediate: !0 }
180
+ );
181
+ const y = D(
182
+ () => (l.value ? void 0 : H.options.title) ?? t.title ?? "选择图片"
183
+ ), T = D(
184
+ () => (l.value ? void 0 : H.options.multiple) ?? t.multiple
185
+ ), v = D(
186
+ () => (l.value ? void 0 : H.options.maxCount) ?? t.maxCount
187
+ ), r = D(
188
+ () => (l.value ? void 0 : H.options.showModeSwitch) ?? t.showModeSwitch
189
+ ), I = D(
190
+ () => (l.value ? void 0 : H.options.showCategories) ?? t.showCategories
191
+ ), U = D(() => {
192
+ var i, s;
193
+ if ((i = t.categories) != null && i.length) return t.categories;
194
+ if (!l.value && ((s = H.options.categories) != null && s.length))
195
+ return H.options.categories;
196
+ }), R = D(() => I.value ? U.value ?? q.value : []), Y = D(
197
+ () => (l.value ? void 0 : H.options.confirmOnSelect) ?? t.confirmOnSelect
198
+ ), L = b("single"), g = [
199
+ { label: "单选", value: "single" },
200
+ { label: "多选", value: "multiple" }
201
+ ], x = D(
202
+ () => r.value ? L.value === "multiple" : T.value
203
+ ), N = b(""), k = b(""), O = b(1), j = b(0), _ = b(!1), C = b(!1), G = b([]), q = b([]), A = b(/* @__PURE__ */ new Map()), J = b(/* @__PURE__ */ new Map()), X = b(), te = b(), Q = b(!1), K = D(() => [...A.value.values()]), z = D(() => {
204
+ var s, P;
205
+ const i = K.value.length;
206
+ return Y.value ? i ? `已选:${((s = K.value[0]) == null ? void 0 : s.name) || "1 张图片"}` : "单击图片即可完成选择" : i ? x.value ? `已选 ${i} / ${v.value} 张` : `已选:${((P = K.value[0]) == null ? void 0 : P.name) || "1 张图片"}` : x.value ? `多选模式:最多 ${v.value} 张` : "单选模式:请选择一张图片";
207
+ });
208
+ function fe(i) {
209
+ const s = K.value.findIndex((P) => u(P) === u(i));
210
+ return s >= 0 ? s + 1 : "";
102
211
  }
103
- function E(C) {
104
- const F = U();
105
- return F < 0 ? !0 : C === "prev" ? F <= 0 : F >= o.list.length - 1;
212
+ function be(i) {
213
+ if (i === "single" && K.value.length > 1) {
214
+ const s = K.value[0];
215
+ A.value = /* @__PURE__ */ new Map([[u(s), s]]), Z.info("已切换为单选,仅保留第一张");
216
+ }
106
217
  }
107
- function D() {
108
- const C = U();
109
- if (C <= 0) return;
110
- const F = o.list[C - 1];
111
- l("checkRow", F), l("prev", F);
218
+ function ye() {
219
+ L.value = T.value ? "multiple" : "single";
112
220
  }
113
- function N() {
114
- const C = U();
115
- if (C < 0 || C >= o.list.length - 1) return;
116
- const F = o.list[C + 1];
117
- l("checkRow", F), l("next", F);
221
+ function Ae() {
222
+ A.value = /* @__PURE__ */ new Map();
118
223
  }
119
- function y() {
120
- const C = o.type === "detail" ? "edit" : "detail";
121
- l("update:type", C), l("changeType");
224
+ function a(i) {
225
+ return i[t.urlField];
122
226
  }
123
- function $() {
124
- l("update:visible", !1), l("close");
227
+ function u(i) {
228
+ return i.id ?? i.url;
125
229
  }
126
- function z() {
127
- g.value = !0, l("confirm", (C) => {
128
- g.value = !1, C && $();
129
- });
230
+ function c(i) {
231
+ return A.value.has(u(i));
130
232
  }
131
- return te(
132
- () => o.visible,
133
- (C) => {
134
- C && l("opened");
233
+ function F(i, s) {
234
+ return i < s ? "portrait" : i > s ? "landscape" : "square";
235
+ }
236
+ function se(i, s) {
237
+ const P = u(i);
238
+ J.value.get(P) !== s && (J.value.set(P, s), J.value = new Map(J.value));
239
+ }
240
+ function pe(i) {
241
+ const s = J.value.get(u(i));
242
+ return s ? `yc-image-selector__img--${s}` : "";
243
+ }
244
+ function xt(i, s) {
245
+ const P = i.target;
246
+ !(P != null && P.naturalWidth) || !(P != null && P.naturalHeight) || se(s, F(P.naturalWidth, P.naturalHeight));
247
+ }
248
+ function bt(i) {
249
+ i.width && i.height && se(i, F(i.width, i.height));
250
+ }
251
+ function Ge(i) {
252
+ const s = /* @__PURE__ */ new Map();
253
+ if (!(i != null && i.length)) {
254
+ A.value = s;
255
+ return;
135
256
  }
136
- ), Mt(() => {
137
- o.visible && $();
138
- }), n({ closeWindow: $ }), (C, F) => {
139
- const Y = O("el-icon"), v = O("el-button"), T = O("el-tooltip"), W = O("el-scrollbar"), H = et("loading");
140
- return d(), M(tt, {
141
- name: "yc-page-window-fade",
142
- mode: "out-in"
257
+ if (typeof i[0] == "string")
258
+ for (const le of i)
259
+ s.set(le, { id: le, url: le, name: le.split("/").pop() });
260
+ else
261
+ for (const le of i)
262
+ s.set(u(le), le);
263
+ A.value = s;
264
+ }
265
+ function Me(i) {
266
+ X.value = i.onConfirm, te.value = i.onCancel, Ge(i.selected ?? t.selected);
267
+ }
268
+ function We(i) {
269
+ if (l.value) return;
270
+ const s = i.detail ?? {};
271
+ Me(s), m.value = !0;
272
+ }
273
+ Re(() => {
274
+ globalThis.addEventListener(Ve, We), l.value || (m.value = H.visible);
275
+ }), Ke(() => {
276
+ globalThis.removeEventListener(Ve, We);
277
+ });
278
+ async function Ee() {
279
+ var i;
280
+ if (!t.getImages) {
281
+ Z.error("请通过 props.getImages 传入图片列表请求方法");
282
+ return;
283
+ }
284
+ _.value = !0;
285
+ try {
286
+ const s = await t.getImages({
287
+ keyword: N.value.trim() || void 0,
288
+ category: I.value && k.value || void 0,
289
+ page: O.value,
290
+ pageSize: t.pageSize
291
+ });
292
+ G.value = s.list, j.value = s.total;
293
+ for (const P of s.list)
294
+ bt(P);
295
+ I.value && !U.value && ((i = s.categories) != null && i.length) && (q.value = s.categories);
296
+ } catch (s) {
297
+ Z.error(s instanceof Error ? s.message : "加载图片失败");
298
+ } finally {
299
+ _.value = !1;
300
+ }
301
+ }
302
+ function we() {
303
+ O.value = 1, Ee();
304
+ }
305
+ function qe(i) {
306
+ k.value !== i && (k.value = i, we());
307
+ }
308
+ function He(i) {
309
+ const s = u(i);
310
+ if (x.value) {
311
+ if (A.value.has(s)) {
312
+ A.value.delete(s), A.value = new Map(A.value);
313
+ return;
314
+ }
315
+ if (K.value.length >= v.value) {
316
+ Z.warning(`最多选择 ${v.value} 张图片`);
317
+ return;
318
+ }
319
+ A.value.set(s, i), A.value = new Map(A.value);
320
+ return;
321
+ }
322
+ if (A.value.has(s)) {
323
+ if (Y.value) {
324
+ Xe(() => Te());
325
+ return;
326
+ }
327
+ A.value = /* @__PURE__ */ new Map();
328
+ return;
329
+ }
330
+ A.value = /* @__PURE__ */ new Map([[s, i]]), Y.value && Xe(() => Te());
331
+ }
332
+ async function At(i) {
333
+ if (!t.upload) {
334
+ Z.error("请通过 props.upload 传入图片上传方法");
335
+ return;
336
+ }
337
+ C.value = !0;
338
+ try {
339
+ const { resource: s } = await t.upload(i.file);
340
+ if (Z.success("上传成功"), x.value)
341
+ K.value.length < v.value && (A.value.set(u(s), s), A.value = new Map(A.value));
342
+ else if (A.value = /* @__PURE__ */ new Map([[u(s), s]]), Y.value) {
343
+ Te();
344
+ return;
345
+ }
346
+ we();
347
+ } catch (s) {
348
+ Z.error(s instanceof Error ? s.message : "上传失败");
349
+ } finally {
350
+ C.value = !1;
351
+ }
352
+ }
353
+ function Mt() {
354
+ Q.value = !1, N.value = "", k.value = "", O.value = 1, q.value = [], J.value = /* @__PURE__ */ new Map(), ye(), l.value ? Me({}) : Me(H.options), ye(), Ee();
355
+ }
356
+ function Et() {
357
+ C.value = !1;
358
+ }
359
+ function Je() {
360
+ var i;
361
+ Q.value || (Q.value = !0, (i = te.value) == null || i.call(te), l.value || et(), o("cancel"), m.value = !1);
362
+ }
363
+ function Te() {
364
+ var s;
365
+ if (!K.value.length) {
366
+ Z.warning("请选择图片");
367
+ return;
368
+ }
369
+ if (Q.value) return;
370
+ Q.value = !0;
371
+ const i = [...K.value];
372
+ if (l.value) {
373
+ o("confirm", i), m.value = !1;
374
+ return;
375
+ }
376
+ (s = X.value) == null || s.call(X, i), l.value || un(i), o("confirm", i), m.value = !1;
377
+ }
378
+ return ne(m, (i, s) => {
379
+ var P;
380
+ s && !i && !Q.value && ((P = te.value) == null || P.call(te), l.value || et(), o("cancel"));
381
+ }), ne(
382
+ () => t.selected,
383
+ (i) => {
384
+ m.value || Ge(i);
385
+ },
386
+ { deep: !0 }
387
+ ), (i, s) => {
388
+ const P = V("el-icon"), le = V("el-input"), Pt = V("el-segmented"), me = V("el-button"), $t = V("el-upload"), Lt = V("el-empty"), Dt = V("el-pagination"), Bt = V("el-dialog"), Vt = at("loading");
389
+ return d(), E(Bt, {
390
+ modelValue: m.value,
391
+ "onUpdate:modelValue": s[4] || (s[4] = (S) => m.value = S),
392
+ title: y.value,
393
+ width: e.width,
394
+ "append-to-body": "",
395
+ "destroy-on-close": "",
396
+ class: "yc-image-selector-dialog",
397
+ onClosed: Et,
398
+ onOpen: Mt
143
399
  }, {
400
+ footer: p(() => [
401
+ Y.value ? (d(), M("div", Dn, [
402
+ h("span", Bn, B(z.value), 1),
403
+ f(me, {
404
+ link: "",
405
+ type: "primary",
406
+ onClick: Je
407
+ }, {
408
+ default: p(() => [
409
+ W(B(e.cancelText), 1)
410
+ ]),
411
+ _: 1
412
+ })
413
+ ])) : (d(), M("div", Pn, [
414
+ h("span", $n, B(z.value), 1),
415
+ h("div", Ln, [
416
+ f(me, { onClick: Je }, {
417
+ default: p(() => [
418
+ W(B(e.cancelText), 1)
419
+ ]),
420
+ _: 1
421
+ }),
422
+ f(me, {
423
+ type: "primary",
424
+ disabled: !K.value.length,
425
+ onClick: Te
426
+ }, {
427
+ default: p(() => [
428
+ W(B(e.confirmText), 1)
429
+ ]),
430
+ _: 1
431
+ }, 8, ["disabled"])
432
+ ])
433
+ ]))
434
+ ]),
144
435
  default: p(() => [
145
- ve(_("div", {
146
- class: "yc-page-window",
147
- style: He({ zIndex: e.zIndex })
148
- }, [
149
- _("div", Qt, [
150
- _("div", Zt, [
151
- f(Y, {
152
- class: "yc-page-window__back",
153
- onClick: $
154
- }, {
155
- default: p(() => [
156
- f(h(Bt))
157
- ]),
158
- _: 1
159
- }),
160
- _("span", null, V(e.title) + V(S.value), 1),
161
- m.value ? (d(), A("div", en, [
162
- f(T, {
163
- content: "上一条",
164
- placement: "top"
436
+ h("div", fn, [
437
+ h("div", pn, [
438
+ f(le, {
439
+ modelValue: N.value,
440
+ "onUpdate:modelValue": s[0] || (s[0] = (S) => N.value = S),
441
+ clearable: "",
442
+ placeholder: "搜索图片名称",
443
+ class: "yc-image-selector__search",
444
+ onKeyup: Ot(we, ["enter"]),
445
+ onClear: we
446
+ }, {
447
+ prefix: p(() => [
448
+ f(P, null, {
449
+ default: p(() => [
450
+ f(w(Yt))
451
+ ]),
452
+ _: 1
453
+ })
454
+ ]),
455
+ _: 1
456
+ }, 8, ["modelValue"]),
457
+ r.value ? (d(), E(Pt, {
458
+ key: 0,
459
+ modelValue: L.value,
460
+ "onUpdate:modelValue": s[1] || (s[1] = (S) => L.value = S),
461
+ options: g,
462
+ class: "yc-image-selector__mode",
463
+ onChange: be
464
+ }, null, 8, ["modelValue"])) : $("", !0),
465
+ e.showUpload && e.upload ? (d(), E($t, {
466
+ key: 1,
467
+ "show-file-list": !1,
468
+ accept: e.accept,
469
+ "http-request": At,
470
+ disabled: C.value
471
+ }, {
472
+ default: p(() => [
473
+ f(me, {
474
+ type: "primary",
475
+ plain: "",
476
+ loading: C.value
165
477
  }, {
166
478
  default: p(() => [
167
- f(v, {
168
- round: "",
169
- text: "",
170
- disabled: E("prev"),
171
- onClick: D
172
- }, {
479
+ f(P, { class: "m-r-4" }, {
173
480
  default: p(() => [
174
- f(Y, null, {
175
- default: p(() => [
176
- f(h(Vt))
177
- ]),
178
- _: 1
179
- })
481
+ f(w(jt))
180
482
  ]),
181
483
  _: 1
182
- }, 8, ["disabled"])
484
+ }),
485
+ s[5] || (s[5] = W(" 上传图片 ", -1))
486
+ ]),
487
+ _: 1
488
+ }, 8, ["loading"])
489
+ ]),
490
+ _: 1
491
+ }, 8, ["accept", "disabled"])) : $("", !0)
492
+ ]),
493
+ h("div", mn, [
494
+ I.value ? (d(), M("aside", gn, [
495
+ h("div", {
496
+ class: ue(["yc-image-selector__category", { "is-active": k.value === "" }]),
497
+ onClick: s[2] || (s[2] = (S) => qe(""))
498
+ }, B(e.categoryAllLabel), 3),
499
+ (d(!0), M(ie, null, ve(R.value, (S) => (d(), M("div", {
500
+ key: S.id,
501
+ class: ue(["yc-image-selector__category", { "is-active": k.value === S.id }]),
502
+ onClick: (Ie) => qe(S.id)
503
+ }, [
504
+ h("span", null, B(S.name), 1),
505
+ S.count != null ? (d(), M("span", _n, B(S.count), 1)) : $("", !0)
506
+ ], 10, vn))), 128))
507
+ ])) : $("", !0),
508
+ _e((d(), M("div", hn, [
509
+ !_.value && !G.value.length ? (d(), E(Lt, {
510
+ key: 0,
511
+ description: e.emptyText
512
+ }, null, 8, ["description"])) : (d(), M("div", yn, [
513
+ (d(!0), M(ie, null, ve(G.value, (S) => (d(), M("div", {
514
+ key: String(S.id),
515
+ class: ue(["yc-image-selector__item", {
516
+ "is-selected": c(S),
517
+ "is-single-mode": !x.value,
518
+ "is-multi-mode": x.value
519
+ }]),
520
+ onClick: (Ie) => He(S)
521
+ }, [
522
+ h("div", Tn, [
523
+ h("img", {
524
+ src: a(S),
525
+ alt: S.name || "image",
526
+ loading: "lazy",
527
+ class: ue(pe(S)),
528
+ onLoad: (Ie) => xt(Ie, S)
529
+ }, null, 42, In),
530
+ h("div", {
531
+ class: ue(["yc-image-selector__indicator", {
532
+ "is-checked": c(S),
533
+ "is-radio": !x.value,
534
+ "is-checkbox": x.value
535
+ }])
536
+ }, [
537
+ c(S) && x.value ? (d(), M("span", Cn, B(fe(S)), 1)) : c(S) ? (d(), E(P, { key: 1 }, {
538
+ default: p(() => [
539
+ f(w(rt))
540
+ ]),
541
+ _: 1
542
+ })) : $("", !0)
543
+ ], 2)
544
+ ]),
545
+ h("div", {
546
+ class: "yc-image-selector__meta",
547
+ title: S.name
548
+ }, B(S.name || "未命名"), 9, Sn)
549
+ ], 10, wn))), 128))
550
+ ]))
551
+ ])), [
552
+ [Vt, _.value]
553
+ ])
554
+ ]),
555
+ x.value && K.value.length ? (d(), M("div", kn, [
556
+ h("span", xn, "已选 " + B(K.value.length) + " 张", 1),
557
+ h("div", bn, [
558
+ (d(!0), M(ie, null, ve(K.value, (S) => (d(), M("div", {
559
+ key: String(S.id),
560
+ class: "yc-image-selector__selected-chip",
561
+ onClick: Ut((Ie) => He(S), ["stop"])
562
+ }, [
563
+ h("img", {
564
+ src: a(S),
565
+ alt: S.name
566
+ }, null, 8, Mn),
567
+ s[6] || (s[6] = h("span", { class: "yc-image-selector__selected-chip-remove" }, "×", -1))
568
+ ], 8, An))), 128))
569
+ ]),
570
+ f(me, {
571
+ link: "",
572
+ type: "primary",
573
+ onClick: Ae
574
+ }, {
575
+ default: p(() => [...s[7] || (s[7] = [
576
+ W("清空", -1)
577
+ ])]),
578
+ _: 1
579
+ })
580
+ ])) : $("", !0),
581
+ j.value > 0 ? (d(), M("div", En, [
582
+ f(Dt, {
583
+ "current-page": O.value,
584
+ "onUpdate:currentPage": s[3] || (s[3] = (S) => O.value = S),
585
+ background: "",
586
+ layout: "total, prev, pager, next, jumper",
587
+ "page-size": e.pageSize,
588
+ total: j.value,
589
+ onCurrentChange: Ee
590
+ }, null, 8, ["current-page", "page-size", "total"])
591
+ ])) : $("", !0)
592
+ ])
593
+ ]),
594
+ _: 1
595
+ }, 8, ["modelValue", "title", "width"]);
596
+ };
597
+ }
598
+ }), xe = (e, n) => {
599
+ const t = e.__vccOpts || e;
600
+ for (const [o, l] of n)
601
+ t[o] = l;
602
+ return t;
603
+ }, gt = /* @__PURE__ */ xe(Vn, [["__scopeId", "data-v-88947fca"]]);
604
+ function vt() {
605
+ const { baseURL: e = "" } = ke();
606
+ return ot.create({ baseURL: e, timeout: 3e4 });
607
+ }
608
+ async function On(e) {
609
+ const n = ke().fetchImages;
610
+ if (n) return n(e);
611
+ const t = vt(), { data: o } = await t.get(
612
+ "/yc-media/images",
613
+ { params: e }
614
+ );
615
+ if (o.code !== 200)
616
+ throw new Error("加载图片资源失败");
617
+ return o.data;
618
+ }
619
+ async function Un(e) {
620
+ const n = ke().uploadImage;
621
+ if (n) return n(e);
622
+ const t = vt(), o = new FormData();
623
+ o.append("file", e);
624
+ const { data: l } = await t.post(
625
+ "/yc-media/images/upload",
626
+ o,
627
+ { headers: { "Content-Type": "multipart/form-data" } }
628
+ );
629
+ if (l.code !== 200)
630
+ throw new Error("上传图片失败");
631
+ return l.data;
632
+ }
633
+ const tt = "__YC_IMAGE_SELECTOR_MOUNT__";
634
+ function Fn(e) {
635
+ const n = globalThis;
636
+ if (n[tt] || typeof document > "u") return;
637
+ const t = document.createElement("div");
638
+ t.setAttribute("data-yc-image-selector-host", ""), document.body.appendChild(t);
639
+ const o = ke().dialog ?? {}, l = f(gt, {
640
+ getImages: On,
641
+ upload: Un,
642
+ showUpload: o.showUpload ?? !0,
643
+ ...o
644
+ });
645
+ l.appContext = e._context, Ft(l, t), n[tt] = !0;
646
+ }
647
+ function Rn(e) {
648
+ e.config.globalProperties.openImageSelector = mt, e.config.globalProperties.closeImageSelector = pt;
649
+ }
650
+ function Kn(e) {
651
+ Fn(e), Rn(e);
652
+ }
653
+ const Nn = { class: "yc-page-window__header" }, zn = { class: "yc-page-window__title" }, Yn = {
654
+ key: 0,
655
+ class: "yc-page-window__nav"
656
+ }, jn = { class: "yc-page-window__opera" }, Gn = { class: "yc-page-window__content" }, Wn = /* @__PURE__ */ ce({
657
+ __name: "YcPageWindow",
658
+ props: {
659
+ visible: { type: Boolean },
660
+ title: { default: "" },
661
+ type: { default: "" },
662
+ showButtons: { type: Boolean, default: !0 },
663
+ showConfirm: { type: Boolean, default: !0 },
664
+ contentMinHeight: { default: "calc(100vh - 175px)" },
665
+ cancelText: { default: "取消" },
666
+ confirmText: { default: "保存" },
667
+ disabled: { type: Boolean, default: !1 },
668
+ loading: { type: Boolean, default: !1 },
669
+ zIndex: { default: 9 },
670
+ list: { default: () => [] },
671
+ row: { default: null },
672
+ rowKey: { default: "id" }
673
+ },
674
+ emits: ["update:visible", "update:type", "confirm", "close", "opened", "changeType", "prev", "next", "checkRow"],
675
+ setup(e, { expose: n, emit: t }) {
676
+ const o = e, l = t, m = b(!1), y = D(() => o.loading || m.value), T = D(() => o.type === "detail" ? "详情" : o.type === "edit" ? "编辑" : o.type === "add" ? "新增" : ""), v = D(
677
+ () => o.list.length > 0 && o.row != null
678
+ ), r = D(
679
+ () => ["detail", "edit"].includes(o.type)
680
+ ), I = D(() => o.type !== "detail");
681
+ function U() {
682
+ if (!o.row) return -1;
683
+ const k = o.rowKey, O = o.row[k];
684
+ return o.list.findIndex((j) => j[k] === O);
685
+ }
686
+ function R(k) {
687
+ const O = U();
688
+ return O < 0 ? !0 : k === "prev" ? O <= 0 : O >= o.list.length - 1;
689
+ }
690
+ function Y() {
691
+ const k = U();
692
+ if (k <= 0) return;
693
+ const O = o.list[k - 1];
694
+ l("checkRow", O), l("prev", O);
695
+ }
696
+ function L() {
697
+ const k = U();
698
+ if (k < 0 || k >= o.list.length - 1) return;
699
+ const O = o.list[k + 1];
700
+ l("checkRow", O), l("next", O);
701
+ }
702
+ function g() {
703
+ const k = o.type === "detail" ? "edit" : "detail";
704
+ l("update:type", k), l("changeType");
705
+ }
706
+ function x() {
707
+ l("update:visible", !1), l("close");
708
+ }
709
+ function N() {
710
+ m.value = !0, l("confirm", (k) => {
711
+ m.value = !1, k && x();
712
+ });
713
+ }
714
+ return ne(
715
+ () => o.visible,
716
+ (k) => {
717
+ k && l("opened");
718
+ }
719
+ ), Rt(() => {
720
+ o.visible && x();
721
+ }), n({ closeWindow: x }), (k, O) => {
722
+ const j = V("el-icon"), _ = V("el-button"), C = V("el-tooltip"), G = V("el-scrollbar"), q = at("loading");
723
+ return d(), E(it, {
724
+ name: "yc-page-window-fade",
725
+ mode: "out-in"
726
+ }, {
727
+ default: p(() => [
728
+ _e(h("div", {
729
+ class: "yc-page-window",
730
+ style: Qe({ zIndex: e.zIndex })
731
+ }, [
732
+ h("div", Nn, [
733
+ h("div", zn, [
734
+ f(j, {
735
+ class: "yc-page-window__back",
736
+ onClick: x
737
+ }, {
738
+ default: p(() => [
739
+ f(w(Gt))
740
+ ]),
741
+ _: 1
742
+ }),
743
+ h("span", null, B(e.title) + B(T.value), 1),
744
+ v.value ? (d(), M("div", Yn, [
745
+ f(C, {
746
+ content: "上一条",
747
+ placement: "top"
748
+ }, {
749
+ default: p(() => [
750
+ f(_, {
751
+ round: "",
752
+ text: "",
753
+ disabled: R("prev"),
754
+ onClick: Y
755
+ }, {
756
+ default: p(() => [
757
+ f(j, null, {
758
+ default: p(() => [
759
+ f(w(Wt))
760
+ ]),
761
+ _: 1
762
+ })
763
+ ]),
764
+ _: 1
765
+ }, 8, ["disabled"])
183
766
  ]),
184
767
  _: 1
185
768
  }),
186
- f(T, {
769
+ f(C, {
187
770
  content: "下一条",
188
771
  placement: "top"
189
772
  }, {
190
773
  default: p(() => [
191
- f(v, {
774
+ f(_, {
192
775
  round: "",
193
776
  text: "",
194
- disabled: E("next"),
195
- onClick: N
777
+ disabled: R("next"),
778
+ onClick: L
196
779
  }, {
197
780
  default: p(() => [
198
- f(Y, null, {
781
+ f(j, null, {
199
782
  default: p(() => [
200
- f(h(Ot))
783
+ f(w(qt))
201
784
  ]),
202
785
  _: 1
203
786
  })
@@ -207,148 +790,146 @@ const Qt = { class: "yc-page-window__header" }, Zt = { class: "yc-page-window__t
207
790
  ]),
208
791
  _: 1
209
792
  })
210
- ])) : P("", !0),
211
- r.value ? (d(), M(v, {
793
+ ])) : $("", !0),
794
+ r.value ? (d(), E(_, {
212
795
  key: 1,
213
796
  text: "",
214
797
  class: "yc-page-window__type-switch",
215
798
  type: e.type === "detail" ? "primary" : "success",
216
- onClick: y
799
+ onClick: g
217
800
  }, {
218
801
  default: p(() => [
219
- f(Y, { class: "m-r-4" }, {
802
+ f(j, { class: "m-r-4" }, {
220
803
  default: p(() => [
221
- f(h(Ft))
804
+ f(w(Ht))
222
805
  ]),
223
806
  _: 1
224
807
  }),
225
- q(" " + V(e.type === "detail" ? "切换编辑" : "切换详情"), 1)
808
+ W(" " + B(e.type === "detail" ? "切换编辑" : "切换详情"), 1)
226
809
  ]),
227
810
  _: 1
228
- }, 8, ["type"])) : P("", !0)
811
+ }, 8, ["type"])) : $("", !0)
229
812
  ]),
230
- _("div", tn, [
231
- Ce(C.$slots, "opera", {}, void 0, !0),
232
- e.showButtons && L.value ? (d(), A(ae, { key: 0 }, [
233
- f(v, {
813
+ h("div", jn, [
814
+ Ce(k.$slots, "opera", {}, void 0, !0),
815
+ e.showButtons && I.value ? (d(), M(ie, { key: 0 }, [
816
+ f(_, {
234
817
  text: "",
235
- disabled: w.value,
236
- onClick: $
818
+ disabled: y.value,
819
+ onClick: x
237
820
  }, {
238
821
  default: p(() => [
239
- f(Y, { class: "m-r-4" }, {
822
+ f(j, { class: "m-r-4" }, {
240
823
  default: p(() => [
241
- f(h(at))
824
+ f(w(ut))
242
825
  ]),
243
826
  _: 1
244
827
  }),
245
- q(" " + V(e.cancelText), 1)
828
+ W(" " + B(e.cancelText), 1)
246
829
  ]),
247
830
  _: 1
248
831
  }, 8, ["disabled"]),
249
- e.showConfirm ? (d(), M(v, {
832
+ e.showConfirm ? (d(), E(_, {
250
833
  key: 0,
251
834
  type: "primary",
252
- loading: w.value,
835
+ loading: y.value,
253
836
  disabled: e.disabled,
254
- onClick: z
837
+ onClick: N
255
838
  }, {
256
839
  default: p(() => [
257
- f(Y, { class: "m-r-4" }, {
840
+ f(j, { class: "m-r-4" }, {
258
841
  default: p(() => [
259
- f(h(lt))
842
+ f(w(rt))
260
843
  ]),
261
844
  _: 1
262
845
  }),
263
- q(" " + V(e.confirmText), 1)
846
+ W(" " + B(e.confirmText), 1)
264
847
  ]),
265
848
  _: 1
266
- }, 8, ["loading", "disabled"])) : P("", !0)
267
- ], 64)) : P("", !0)
849
+ }, 8, ["loading", "disabled"])) : $("", !0)
850
+ ], 64)) : $("", !0)
268
851
  ])
269
852
  ]),
270
- ve((d(), A("div", nn, [
271
- f(W, { class: "yc-page-window__scroll" }, {
853
+ _e((d(), M("div", Gn, [
854
+ f(G, { class: "yc-page-window__scroll" }, {
272
855
  default: p(() => [
273
- e.visible ? (d(), A("div", {
856
+ e.visible ? (d(), M("div", {
274
857
  key: 0,
275
858
  class: "yc-page-window__body",
276
- style: He({ minHeight: e.contentMinHeight })
859
+ style: Qe({ minHeight: e.contentMinHeight })
277
860
  }, [
278
- Ce(C.$slots, "default", {}, void 0, !0)
279
- ], 4)) : P("", !0)
861
+ Ce(k.$slots, "default", {}, void 0, !0)
862
+ ], 4)) : $("", !0)
280
863
  ]),
281
864
  _: 3
282
865
  })
283
866
  ])), [
284
- [H, w.value]
867
+ [q, y.value]
285
868
  ])
286
869
  ], 4), [
287
- [Ee, e.visible]
870
+ [Le, e.visible]
288
871
  ])
289
872
  ]),
290
873
  _: 3
291
874
  });
292
875
  };
293
876
  }
294
- }), Se = (e, n) => {
295
- const t = e.__vccOpts || e;
296
- for (const [o, l] of n)
297
- t[o] = l;
298
- return t;
299
- }, Qe = /* @__PURE__ */ Se(on, [["__scopeId", "data-v-b3e784c3"]]);
300
- function an(e) {
301
- e != null && e.aiTask && (Gt(e.aiTask), Ht()), e != null && e.imageSelector && Xt(e.imageSelector);
877
+ }), nt = /* @__PURE__ */ xe(Wn, [["__scopeId", "data-v-b3e784c3"]]);
878
+ function qn(e) {
879
+ e != null && e.aiTask && (nn(e.aiTask), ln()), e != null && e.imageSelector && sn(e.imageSelector);
880
+ }
881
+ function Hn(e, n) {
882
+ (n == null ? void 0 : n.registerPageWindow) !== !1 && (e.component("YcPageWindow", nt), e.component("SkyPageWindow", nt));
302
883
  }
303
- function ln(e, n) {
304
- (n == null ? void 0 : n.registerPageWindow) !== !1 && (e.component("YcPageWindow", Qe), e.component("SkyPageWindow", Qe));
884
+ function Jn(e, n) {
885
+ (n == null ? void 0 : n.registerImageSelector) !== !1 && Kn(e);
305
886
  }
306
- const Do = {
887
+ const Ho = {
307
888
  install(e, n) {
308
- an(n), ln(e, n);
889
+ qn(n), Hn(e, n), Jn(e, n);
309
890
  }
310
- }, Ae = "__YC_COMPONENT_AI_DIALOG__", Le = "yc-component:ai-dialog-open";
311
- function sn() {
891
+ }, $e = "__YC_COMPONENT_AI_DIALOG__", Oe = "yc-component:ai-dialog-open";
892
+ function Xn() {
312
893
  const e = globalThis;
313
- return e[Ae] || (e[Ae] = nt({
894
+ return e[$e] || (e[$e] = lt({
314
895
  visible: !1,
315
896
  options: {}
316
- })), e[Ae];
897
+ })), e[$e];
317
898
  }
318
- const ee = sn();
319
- function Ne(e = {}) {
320
- ee.options = { ...e }, ee.visible = !0, globalThis.dispatchEvent(
321
- new CustomEvent(Le, { detail: { ...e } })
899
+ const oe = Xn();
900
+ function Ye(e = {}) {
901
+ oe.options = { ...e }, oe.visible = !0, globalThis.dispatchEvent(
902
+ new CustomEvent(Oe, { detail: { ...e } })
322
903
  );
323
904
  }
324
- function rt() {
325
- ee.visible = !1;
905
+ function _t() {
906
+ oe.visible = !1;
326
907
  }
327
- function Bo(e = {}) {
328
- Ne(e);
908
+ function Jo(e = {}) {
909
+ Ye(e);
329
910
  }
330
- function ut(e) {
911
+ function ht(e) {
331
912
  const {
332
913
  tasks: n,
333
914
  panelVisible: t,
334
915
  panelMinimized: o,
335
916
  dialogVisible: l,
336
- runningCount: g,
337
- activeCount: w,
338
- panelTitle: S,
339
- panelSubtitle: m
340
- } = Wt(e);
917
+ runningCount: m,
918
+ activeCount: y,
919
+ panelTitle: T,
920
+ panelSubtitle: v
921
+ } = en(e);
341
922
  return {
342
923
  tasks: n,
343
924
  panelVisible: t,
344
925
  panelMinimized: o,
345
926
  dialogVisible: l,
346
- runningCount: g,
347
- activeCount: w,
348
- panelTitle: S,
349
- panelSubtitle: m,
927
+ runningCount: m,
928
+ activeCount: y,
929
+ panelTitle: T,
930
+ panelSubtitle: v,
350
931
  openUseDialog: (r) => {
351
- Ne(r ?? {}), e.openDialog(r ?? {});
932
+ Ye(r ?? {}), e.openDialog(r ?? {});
352
933
  },
353
934
  closeUseDialog: () => e.closeDialog(),
354
935
  openTaskPanel: () => e.showPanel(),
@@ -364,19 +945,19 @@ function ut(e) {
364
945
  onTaskFinish: (r) => e.onTaskFinish(r)
365
946
  };
366
947
  }
367
- const rn = "__YC_AI_TASK_CTX_KEY__", un = "__YC_AI_TASK_STORE_KEY__";
368
- function ct(e) {
948
+ const Qn = "__YC_AI_TASK_CTX_KEY__", Zn = "__YC_AI_TASK_STORE_KEY__";
949
+ function yt(e) {
369
950
  const n = globalThis;
370
951
  return n[e] || (n[e] = Symbol(e)), n[e];
371
952
  }
372
- const dt = ct(rn), ft = ct(un), cn = async (e) => (await ce().post(
953
+ const wt = yt(Qn), Tt = yt(Zn), eo = async (e) => (await de().post(
373
954
  "/yc-ai/workflows/runs",
374
955
  e
375
- )).data, pt = async (e) => (await ce().get(`/yc-ai/workflows/runs/${e}`)).data, dn = (e) => ce().post(`/yc-ai/workflows/runs/${e}/cancel`), fn = (e, n) => ce().post(`/yc-ai/workflows/runs/${e}/client-continue`, n);
376
- async function De(e, n) {
377
- return Jt(e, n);
956
+ )).data, It = async (e) => (await de().get(`/yc-ai/workflows/runs/${e}`)).data, to = (e) => de().post(`/yc-ai/workflows/runs/${e}/cancel`), no = (e, n) => de().post(`/yc-ai/workflows/runs/${e}/client-continue`, n);
957
+ async function Ue(e, n) {
958
+ return an(e, n);
378
959
  }
379
- function pn(e, n) {
960
+ function oo(e, n) {
380
961
  const t = e.trim();
381
962
  if (!t)
382
963
  return n;
@@ -399,70 +980,70 @@ function pn(e, n) {
399
980
  throw new Error(`自定义脚本执行失败: ${l instanceof Error ? l.message : String(l)}`);
400
981
  }
401
982
  }
402
- async function mn(e) {
403
- return (await cn({
404
- projectId: qt(),
983
+ async function lo(e) {
984
+ return (await eo({
985
+ projectId: on(),
405
986
  freeText: e.freeText,
406
987
  promptId: e.promptId,
407
988
  autoMatch: e.autoMatch
408
989
  })).runId;
409
990
  }
410
- async function gn(e, n) {
411
- var o, l, g, w;
412
- const t = await pt(e);
991
+ async function ao(e, n) {
992
+ var o, l, m, y;
993
+ const t = await It(e);
413
994
  if (t.status === "WAITING_CLIENT" && t.waitingStepKey && t.waitingClientScript) {
414
995
  (o = n == null ? void 0 : n.onProgress) == null || o.call(n, 60, `执行脚本:${t.waitingStepKey}`);
415
- let S = {};
416
- t.waitingArtifactId && (S = await De(e, t.waitingArtifactId));
417
- const m = pn(t.waitingClientScript, S);
418
- return await fn(e, {
996
+ let T = {};
997
+ t.waitingArtifactId && (T = await Ue(e, t.waitingArtifactId));
998
+ const v = oo(t.waitingClientScript, T);
999
+ return await no(e, {
419
1000
  stepKey: t.waitingStepKey,
420
- output: m ?? {}
1001
+ output: v ?? {}
421
1002
  }), null;
422
1003
  }
423
1004
  if (t.status === "SUCCEEDED") {
424
1005
  if (t.finalArtifactId) {
425
1006
  (l = n == null ? void 0 : n.onProgress) == null || l.call(n, 95, "加载结果…");
426
- const S = await De(e, t.finalArtifactId);
427
- return (g = n == null ? void 0 : n.onProgress) == null || g.call(n, 100, "已完成"), { phase: "SUCCEEDED", runId: e, result: S };
1007
+ const T = await Ue(e, t.finalArtifactId);
1008
+ return (m = n == null ? void 0 : n.onProgress) == null || m.call(n, 100, "已完成"), { phase: "SUCCEEDED", runId: e, result: T };
428
1009
  }
429
1010
  return { phase: "SUCCEEDED", runId: e, result: {} };
430
1011
  }
431
- return t.status === "FAILED" ? { phase: "FAILED", runId: e, errorMessage: t.errorMessage || "工作流失败" } : t.status === "CANCELLED" ? { phase: "FAILED", runId: e, errorMessage: "已取消" } : ((w = n == null ? void 0 : n.onProgress) == null || w.call(n, hn(t), yn(t)), null);
1012
+ return t.status === "FAILED" ? { phase: "FAILED", runId: e, errorMessage: t.errorMessage || "工作流失败" } : t.status === "CANCELLED" ? { phase: "FAILED", runId: e, errorMessage: "已取消" } : ((y = n == null ? void 0 : n.onProgress) == null || y.call(n, ro(t), uo(t)), null);
432
1013
  }
433
- async function vn(e) {
434
- const n = await pt(e);
435
- return n.status !== "SUCCEEDED" || !n.finalArtifactId ? null : await De(e, n.finalArtifactId);
1014
+ async function io(e) {
1015
+ const n = await It(e);
1016
+ return n.status !== "SUCCEEDED" || !n.finalArtifactId ? null : await Ue(e, n.finalArtifactId);
436
1017
  }
437
- async function _n(e) {
438
- await dn(e);
1018
+ async function so(e) {
1019
+ await to(e);
439
1020
  }
440
- function hn(e) {
1021
+ function ro(e) {
441
1022
  if (e.status === "PENDING") return 8;
442
1023
  const n = e.steps ?? [];
443
1024
  if (!n.length) return 35;
444
1025
  const t = n.filter((o) => o.status === "SUCCEEDED" || o.status === "SKIPPED").length;
445
1026
  return Math.min(90, Math.round(20 + t / n.length * 70));
446
1027
  }
447
- function yn(e) {
1028
+ function uo(e) {
448
1029
  var t;
449
1030
  if (e.status === "PENDING") return "排队中…";
450
1031
  const n = (t = e.steps) == null ? void 0 : t.find((o) => o.status === "RUNNING");
451
1032
  return n ? `执行中:${n.stepKey}` : "后端处理中…";
452
1033
  }
453
- const mt = 80;
454
- function wn() {
1034
+ const Ct = 80;
1035
+ function co() {
455
1036
  try {
456
- const e = localStorage.getItem(st());
1037
+ const e = localStorage.getItem(dt());
457
1038
  if (!e) return [];
458
1039
  const n = JSON.parse(e);
459
- return Array.isArray(n) ? n.filter((t) => t && t.id && t.createdAt).sort((t, o) => o.createdAt - t.createdAt).slice(0, mt) : [];
1040
+ return Array.isArray(n) ? n.filter((t) => t && t.id && t.createdAt).sort((t, o) => o.createdAt - t.createdAt).slice(0, Ct) : [];
460
1041
  } catch {
461
1042
  return [];
462
1043
  }
463
1044
  }
464
- function Tn(e) {
465
- const n = e.slice(0, mt).map((t) => ({
1045
+ function fo(e) {
1046
+ const n = e.slice(0, Ct).map((t) => ({
466
1047
  id: t.id,
467
1048
  title: t.title,
468
1049
  freeText: t.freeText,
@@ -476,29 +1057,29 @@ function Tn(e) {
476
1057
  createdAt: t.createdAt,
477
1058
  finishedAt: t.finishedAt
478
1059
  }));
479
- localStorage.setItem(st(), JSON.stringify(n));
1060
+ localStorage.setItem(dt(), JSON.stringify(n));
480
1061
  }
481
- function In(e) {
1062
+ function po(e) {
482
1063
  return {
483
1064
  ...e,
484
1065
  logs: e.runId ? [`ℹ 已从本地恢复,runId=${e.runId}`] : [],
485
1066
  result: void 0
486
1067
  };
487
1068
  }
488
- function oe(e) {
1069
+ function ae(e) {
489
1070
  return e === "pending" || e === "running";
490
1071
  }
491
- let Be = 0, me = null;
492
- const Cn = 5e3;
493
- function Sn() {
494
- return Be += 1, `ai_task_${Date.now()}_${Be}`;
1072
+ let Fe = 0, ge = null;
1073
+ const mo = 5e3;
1074
+ function go() {
1075
+ return Fe += 1, `ai_task_${Date.now()}_${Fe}`;
495
1076
  }
496
- function kn(e, n = 28) {
1077
+ function vo(e, n = 28) {
497
1078
  const t = e.trim();
498
1079
  return t.length <= n ? t : `${t.slice(0, n)}…`;
499
1080
  }
500
- const gt = jt("ycAiTask", () => {
501
- const e = k([]), n = k(!1), t = k(!1), o = k(!1), l = k({}), g = k(!1), w = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
1081
+ const St = tn("ycAiTask", () => {
1082
+ const e = b([]), n = b(!1), t = b(!1), o = b(!1), l = b({}), m = b(!1), y = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set();
502
1083
  function r(a, u) {
503
1084
  return {
504
1085
  taskId: a.id,
@@ -510,86 +1091,86 @@ const gt = jt("ycAiTask", () => {
510
1091
  finishedAt: a.finishedAt ?? Date.now()
511
1092
  };
512
1093
  }
513
- function L(a, u) {
1094
+ function I(a, u) {
514
1095
  var se;
515
- const c = e.value.find((fe) => fe.id === a);
1096
+ const c = e.value.find((pe) => pe.id === a);
516
1097
  if (!(c != null && c.runId)) return;
517
- const R = r(c, u);
518
- (se = S.get(a)) == null || se(R), S.delete(a), m.forEach((fe) => fe(R));
1098
+ const F = r(c, u);
1099
+ (se = T.get(a)) == null || se(F), T.delete(a), v.forEach((pe) => pe(F));
519
1100
  }
520
1101
  function U(a) {
521
- return m.add(a), () => m.delete(a);
1102
+ return v.add(a), () => v.delete(a);
522
1103
  }
523
- const E = B(
524
- () => e.value.filter((a) => oe(a.status)).length
525
- ), D = B(() => e.value.filter((a) => a.status === "running").length), N = B(() => E.value > 0 ? "AI 处理中" : e.value.some((a) => a.status === "failed") ? "部分任务失败" : "AI 任务"), y = B(() => {
526
- const a = e.value.length, u = E.value;
1104
+ const R = D(
1105
+ () => e.value.filter((a) => ae(a.status)).length
1106
+ ), Y = D(() => e.value.filter((a) => a.status === "running").length), L = D(() => R.value > 0 ? "AI 处理中" : e.value.some((a) => a.status === "failed") ? "部分任务失败" : "AI 任务"), g = D(() => {
1107
+ const a = e.value.length, u = R.value;
527
1108
  return a === 0 ? "暂无任务" : u > 0 ? `${u}/${a} 项任务进行中` : `${a} 项任务已完成`;
528
1109
  });
529
- function $() {
530
- Tn(e.value);
1110
+ function x() {
1111
+ fo(e.value);
531
1112
  }
532
- function z(a, u) {
533
- const c = e.value.findIndex((R) => R.id === a);
534
- c >= 0 && (e.value[c] = { ...e.value[c], ...u }, $());
1113
+ function N(a, u) {
1114
+ const c = e.value.findIndex((F) => F.id === a);
1115
+ c >= 0 && (e.value[c] = { ...e.value[c], ...u }, x());
535
1116
  }
536
- function C(a, u) {
537
- const c = e.value.find((R) => R.id === a);
1117
+ function k(a, u) {
1118
+ const c = e.value.find((F) => F.id === a);
538
1119
  c && (c.logs.unshift(u), c.logs.length > 20 && c.logs.pop());
539
1120
  }
540
- function F() {
1121
+ function O() {
541
1122
  n.value = !0, t.value = !1;
542
1123
  }
543
- function Y() {
1124
+ function j() {
544
1125
  n.value = !1;
545
1126
  }
546
- function v() {
1127
+ function _() {
547
1128
  t.value = !t.value;
548
1129
  }
549
- function T(a = {}) {
550
- l.value = { ...a }, o.value = !0, Ne(a);
1130
+ function C(a = {}) {
1131
+ l.value = { ...a }, o.value = !0, Ye(a);
551
1132
  }
552
- function W() {
553
- o.value = !1, rt();
1133
+ function G() {
1134
+ o.value = !1, _t();
554
1135
  }
555
- function H() {
556
- me || (me = setInterval(() => {
1136
+ function q() {
1137
+ ge || (ge = setInterval(() => {
557
1138
  J();
558
- }, Cn));
1139
+ }, mo));
559
1140
  }
560
- function x() {
561
- E.value > 0 || me && (clearInterval(me), me = null);
1141
+ function A() {
1142
+ R.value > 0 || ge && (clearInterval(ge), ge = null);
562
1143
  }
563
1144
  async function J() {
564
- const a = e.value.filter((u) => u.runId && oe(u.status));
1145
+ const a = e.value.filter((u) => u.runId && ae(u.status));
565
1146
  if (!a.length) {
566
- x();
1147
+ A();
567
1148
  return;
568
1149
  }
569
1150
  await Promise.all(a.map((u) => X(u.id)));
570
1151
  }
571
1152
  async function X(a) {
572
- if (w.has(a)) return;
1153
+ if (y.has(a)) return;
573
1154
  const u = e.value.find((c) => c.id === a);
574
- if (!(!(u != null && u.runId) || !oe(u.status))) {
575
- w.add(a);
1155
+ if (!(!(u != null && u.runId) || !ae(u.status))) {
1156
+ y.add(a);
576
1157
  try {
577
- const c = await gn(u.runId, {
578
- onProgress: (R, se) => z(a, { progress: R, summary: se, status: "running" })
1158
+ const c = await ao(u.runId, {
1159
+ onProgress: (F, se) => N(a, { progress: F, summary: se, status: "running" })
579
1160
  });
580
1161
  if (!c) return;
581
1162
  if (c.phase === "SUCCEEDED") {
582
- const R = c.result ?? {};
583
- z(a, {
1163
+ const F = c.result ?? {};
1164
+ N(a, {
584
1165
  status: "succeeded",
585
1166
  progress: 100,
586
1167
  summary: "已完成",
587
- result: R,
1168
+ result: F,
588
1169
  runId: c.runId,
589
1170
  finishedAt: Date.now()
590
- }), L(a, R);
1171
+ }), I(a, F);
591
1172
  } else
592
- z(a, {
1173
+ N(a, {
593
1174
  status: c.errorMessage === "已取消" ? "cancelled" : "failed",
594
1175
  progress: 100,
595
1176
  summary: c.errorMessage || "失败",
@@ -597,29 +1178,29 @@ const gt = jt("ycAiTask", () => {
597
1178
  runId: c.runId,
598
1179
  finishedAt: Date.now()
599
1180
  });
600
- x();
1181
+ A();
601
1182
  } catch (c) {
602
- const R = c instanceof Error ? c.message : "同步失败";
603
- C(a, `✗ ${R}`);
1183
+ const F = c instanceof Error ? c.message : "同步失败";
1184
+ k(a, `✗ ${F}`);
604
1185
  } finally {
605
- w.delete(a);
1186
+ y.delete(a);
606
1187
  }
607
1188
  }
608
1189
  }
609
- async function ne() {
610
- if (g.value) return;
611
- g.value = !0;
612
- const a = wn();
613
- a.length && (e.value = a.map(In), Be = a.length);
614
- const u = e.value.filter((c) => c.runId && oe(c.status));
615
- u.length && (await Promise.all(u.map((c) => X(c.id))), H());
1190
+ async function te() {
1191
+ if (m.value) return;
1192
+ m.value = !0;
1193
+ const a = co();
1194
+ a.length && (e.value = a.map(po), Fe = a.length);
1195
+ const u = e.value.filter((c) => c.runId && ae(c.status));
1196
+ u.length && (await Promise.all(u.map((c) => X(c.id))), q());
616
1197
  for (const c of e.value)
617
- c.status === "pending" && !c.runId && z(c.id, { status: "failed", summary: "页面刷新前未提交成功", finishedAt: Date.now() });
1198
+ c.status === "pending" && !c.runId && N(c.id, { status: "failed", summary: "页面刷新前未提交成功", finishedAt: Date.now() });
618
1199
  }
619
- function K(a) {
620
- const u = Sn(), c = {
1200
+ function Q(a) {
1201
+ const u = go(), c = {
621
1202
  id: u,
622
- title: a.title ?? kn(a.freeText),
1203
+ title: a.title ?? vo(a.freeText),
623
1204
  freeText: a.freeText.trim(),
624
1205
  promptId: a.promptId,
625
1206
  autoMatch: a.autoMatch,
@@ -629,1164 +1210,676 @@ const gt = jt("ycAiTask", () => {
629
1210
  createdAt: Date.now(),
630
1211
  logs: []
631
1212
  };
632
- return e.value.unshift(c), $(), a.onFinish && S.set(u, a.onFinish), a.showPanel !== !1 && F(), ie(u), u;
1213
+ return e.value.unshift(c), x(), a.onFinish && T.set(u, a.onFinish), a.showPanel !== !1 && O(), K(u), u;
633
1214
  }
634
- async function ie(a) {
1215
+ async function K(a) {
635
1216
  const u = e.value.find((c) => c.id === a);
636
1217
  if (u)
637
1218
  try {
638
- const c = await mn({
1219
+ const c = await lo({
639
1220
  freeText: u.freeText,
640
1221
  promptId: u.promptId,
641
1222
  autoMatch: u.autoMatch
642
1223
  });
643
- z(a, {
1224
+ N(a, {
644
1225
  runId: c,
645
1226
  status: "running",
646
1227
  progress: 10,
647
1228
  summary: "后端异步处理中…"
648
- }), C(a, `▶ 已提交 runId=${c}`), H(), X(a);
1229
+ }), k(a, `▶ 已提交 runId=${c}`), q(), X(a);
649
1230
  } catch (c) {
650
- const R = c instanceof Error ? c.message : "提交失败";
651
- z(a, {
1231
+ const F = c instanceof Error ? c.message : "提交失败";
1232
+ N(a, {
652
1233
  status: "failed",
653
1234
  progress: 100,
654
- summary: R,
655
- errorMessage: R,
1235
+ summary: F,
1236
+ errorMessage: F,
656
1237
  finishedAt: Date.now()
657
1238
  });
658
1239
  }
659
1240
  }
660
- async function j(a) {
661
- const u = e.value.find((R) => R.id === a);
1241
+ async function z(a) {
1242
+ const u = e.value.find((F) => F.id === a);
662
1243
  if (!(u != null && u.runId)) return null;
663
1244
  if (u.result) return u.result;
664
- const c = await vn(u.runId);
665
- return c && z(a, { result: c }), c;
1245
+ const c = await io(u.runId);
1246
+ return c && N(a, { result: c }), c;
666
1247
  }
667
- async function de(a) {
1248
+ async function fe(a) {
668
1249
  const u = e.value.find((c) => c.id === a);
669
- if (u != null && u.runId && oe(u.status))
1250
+ if (u != null && u.runId && ae(u.status))
670
1251
  try {
671
- await _n(u.runId);
1252
+ await so(u.runId);
672
1253
  } catch {
673
1254
  }
674
- u && oe(u.status) && z(a, { status: "cancelled", summary: "已取消", finishedAt: Date.now() }), S.delete(a), x();
1255
+ u && ae(u.status) && N(a, { status: "cancelled", summary: "已取消", finishedAt: Date.now() }), T.delete(a), A();
675
1256
  }
676
- function he() {
1257
+ function be() {
677
1258
  for (const a of e.value)
678
- oe(a.status) && de(a.id);
1259
+ ae(a.status) && fe(a.id);
679
1260
  }
680
- function ke() {
681
- e.value = e.value.filter((a) => oe(a.status)), $();
1261
+ function ye() {
1262
+ e.value = e.value.filter((a) => ae(a.status)), x();
682
1263
  }
683
- function ye(a) {
684
- de(a), S.delete(a), e.value = e.value.filter((u) => u.id !== a), $();
1264
+ function Ae(a) {
1265
+ fe(a), T.delete(a), e.value = e.value.filter((u) => u.id !== a), x();
685
1266
  }
686
1267
  return {
687
1268
  tasks: e,
688
1269
  panelVisible: n,
689
1270
  panelMinimized: t,
690
- dialogVisible: o,
691
- dialogOptions: l,
692
- hydrated: g,
693
- runningCount: E,
694
- activeCount: D,
695
- panelTitle: N,
696
- panelSubtitle: y,
697
- hydrate: ne,
698
- showPanel: F,
699
- hidePanel: Y,
700
- toggleMinimize: v,
701
- openDialog: T,
702
- closeDialog: W,
703
- enqueue: K,
704
- onTaskFinish: U,
705
- refreshActiveTasks: J,
706
- loadTaskResult: j,
707
- cancelTask: de,
708
- cancelAll: he,
709
- clearFinished: ke,
710
- removeTask: ye
711
- };
712
- });
713
- async function xn(e) {
714
- return (await ce().get("/yc-ai/ai/prompts", {
715
- params: e ? { category: e } : {}
716
- })).data;
717
- }
718
- function ze() {
719
- const e = Oe(ft, null);
720
- return e || gt();
721
- }
722
- const bn = { class: "ai-use-dialog__footer" }, An = { class: "ai-use-dialog__footer-actions" }, Mn = /* @__PURE__ */ ue({
723
- __name: "AiUseDialog",
724
- props: {
725
- title: { default: "AI 生成" },
726
- freeText: { default: "" },
727
- promptId: {},
728
- autoMatch: { type: Boolean, default: !1 },
729
- prompts: {},
730
- showAutoMatch: { type: Boolean, default: !1 },
731
- showPromptSelect: { type: Boolean, default: !1 },
732
- autoMatchLabel: { default: "自动匹配提示词" },
733
- promptLabel: { default: "提示词" },
734
- freeTextLabel: { default: "需求描述" },
735
- freeTextPlaceholder: { default: "描述要生成的页面或项目 JSON" },
736
- submitText: { default: "发送" },
737
- showTaskListButton: { type: Boolean, default: !0 },
738
- taskListButtonText: { default: "查看 AI 任务" },
739
- width: { default: "520px" },
740
- modelValue: { type: Boolean },
741
- showDialog: { type: Boolean }
742
- },
743
- emits: ["update:modelValue", "submitted"],
744
- setup(e, { emit: n }) {
745
- const t = e, o = n, l = ze(), g = B(() => t.modelValue !== void 0), w = k(!1);
746
- te(
747
- () => t.modelValue,
748
- (v) => {
749
- g.value && (w.value = !!v);
750
- },
751
- { immediate: !0 }
752
- ), te(w, (v) => {
753
- if (g.value) {
754
- o("update:modelValue", v);
755
- return;
756
- }
757
- ee.visible = v, v || rt();
758
- }), te(
759
- () => ee.visible,
760
- (v) => {
761
- g.value || (w.value = v);
762
- },
763
- { immediate: !0 }
764
- );
765
- function S(v) {
766
- if (g.value) return;
767
- const T = v.detail ?? {};
768
- N(T), w.value = !0;
769
- }
770
- Fe(() => {
771
- globalThis.addEventListener(Le, S), g.value || (w.value = ee.visible);
772
- }), Ue(() => {
773
- globalThis.removeEventListener(Le, S);
774
- });
775
- const m = B(
776
- () => (g.value ? void 0 : ee.options.title) ?? t.title ?? "AI 生成"
777
- ), r = k({
778
- freeText: t.freeText,
779
- promptId: t.promptId,
780
- autoMatch: t.autoMatch
781
- }), L = k(t.prompts ? [...t.prompts] : []), U = k(!1), E = k(!1), D = k();
782
- function N(v) {
783
- var T, W;
784
- r.value.freeText = v.freeText ?? t.freeText ?? "", r.value.promptId = v.promptId ?? t.promptId, r.value.autoMatch = v.autoMatch ?? t.autoMatch ?? !1, D.value = v.onFinish, (T = v.prompts) != null && T.length ? L.value = [...v.prompts] : (W = t.prompts) != null && W.length && (L.value = [...t.prompts]);
785
- }
786
- async function y() {
787
- if (!(L.value.length > 0)) {
788
- U.value = !0;
789
- try {
790
- const v = it().listPrompts;
791
- L.value = v ? await v() : await xn();
792
- } catch {
793
- Z.warning("加载提示词失败");
794
- } finally {
795
- U.value = !1;
796
- }
797
- }
798
- }
799
- function $() {
800
- g.value ? N({}) : N(ee.options), t.showPromptSelect && y();
801
- }
802
- te(
803
- () => t.prompts,
804
- (v) => {
805
- v != null && v.length && (L.value = [...v]);
806
- },
807
- { deep: !0 }
808
- ), te(
809
- () => [t.freeText, t.promptId, t.autoMatch],
810
- ([v, T, W]) => {
811
- w.value || (r.value.freeText = v ?? "", r.value.promptId = T, r.value.autoMatch = W ?? !1);
812
- }
813
- );
814
- function z() {
815
- r.value.autoMatch && (r.value.promptId = void 0);
816
- }
817
- function C() {
818
- E.value = !1;
819
- }
820
- function F() {
821
- l.showPanel();
822
- }
823
- async function Y() {
824
- var x, J;
825
- if (!r.value.freeText.trim()) {
826
- Z.warning("请填写需求描述");
827
- return;
828
- }
829
- const v = r.value.autoMatch, T = v ? void 0 : r.value.promptId;
830
- if (!v && T == null) {
831
- const X = t.showPromptSelect || t.showAutoMatch ? "请选择提示词或开启自动匹配" : "请通过 promptId 传入提示词,或设置 autoMatch 为 true";
832
- Z.warning(X);
833
- return;
834
- }
835
- E.value = !0;
836
- const W = g.value ? D.value : ee.options.onFinish, H = l.enqueue({
837
- freeText: r.value.freeText.trim(),
838
- promptId: T,
839
- autoMatch: v && T == null ? !0 : void 0,
840
- showPanel: !0,
841
- onFinish: W
842
- });
843
- g.value ? o("submitted", H) : (J = (x = ee.options).onSubmitted) == null || J.call(x, H), w.value = !1, E.value = !1, Z.success("已加入任务队列,可在任务面板查看进度");
844
- }
845
- return (v, T) => {
846
- const W = O("el-switch"), H = O("el-form-item"), x = O("el-option"), J = O("el-select"), X = O("el-input"), ne = O("el-form"), K = O("el-button"), ie = O("el-dialog");
847
- return d(), M(ie, {
848
- modelValue: w.value,
849
- "onUpdate:modelValue": T[4] || (T[4] = (j) => w.value = j),
850
- title: m.value,
851
- width: e.width,
852
- "append-to-body": "",
853
- class: "ai-use-dialog",
854
- onClosed: C,
855
- onOpen: $
856
- }, {
857
- footer: p(() => [
858
- _("div", bn, [
859
- e.showTaskListButton ? (d(), M(K, {
860
- key: 0,
861
- link: "",
862
- type: "primary",
863
- onClick: F
864
- }, {
865
- default: p(() => [
866
- q(V(e.taskListButtonText), 1)
867
- ]),
868
- _: 1
869
- })) : P("", !0),
870
- _("div", An, [
871
- f(K, {
872
- onClick: T[3] || (T[3] = (j) => w.value = !1)
873
- }, {
874
- default: p(() => [...T[5] || (T[5] = [
875
- q("取消", -1)
876
- ])]),
877
- _: 1
878
- }),
879
- f(K, {
880
- type: "primary",
881
- loading: E.value,
882
- onClick: Y
883
- }, {
884
- default: p(() => [
885
- q(V(e.submitText), 1)
886
- ]),
887
- _: 1
888
- }, 8, ["loading"])
889
- ])
890
- ])
891
- ]),
892
- default: p(() => [
893
- f(ne, { "label-position": "top" }, {
894
- default: p(() => [
895
- e.showAutoMatch ? (d(), M(H, {
896
- key: 0,
897
- label: e.autoMatchLabel
898
- }, {
899
- default: p(() => [
900
- f(W, {
901
- modelValue: r.value.autoMatch,
902
- "onUpdate:modelValue": T[0] || (T[0] = (j) => r.value.autoMatch = j),
903
- "active-text": "按需求自动选",
904
- "inactive-text": "手动指定",
905
- onChange: z
906
- }, null, 8, ["modelValue"])
907
- ]),
908
- _: 1
909
- }, 8, ["label"])) : P("", !0),
910
- e.showPromptSelect ? (d(), M(H, {
911
- key: 1,
912
- label: e.promptLabel,
913
- required: !r.value.autoMatch
914
- }, {
915
- default: p(() => [
916
- f(J, {
917
- modelValue: r.value.promptId,
918
- "onUpdate:modelValue": T[1] || (T[1] = (j) => r.value.promptId = j),
919
- filterable: "",
920
- clearable: "",
921
- placeholder: r.value.autoMatch ? "留空则自动匹配" : "请选择提示词",
922
- style: { width: "100%" },
923
- loading: U.value
924
- }, {
925
- default: p(() => [
926
- (d(!0), A(ae, null, ge(L.value, (j) => (d(), M(x, {
927
- key: j.id,
928
- label: j.name,
929
- value: j.id
930
- }, null, 8, ["label", "value"]))), 128))
931
- ]),
932
- _: 1
933
- }, 8, ["modelValue", "placeholder", "loading"])
934
- ]),
935
- _: 1
936
- }, 8, ["label", "required"])) : P("", !0),
937
- f(H, {
938
- label: e.freeTextLabel,
939
- required: ""
940
- }, {
941
- default: p(() => [
942
- f(X, {
943
- modelValue: r.value.freeText,
944
- "onUpdate:modelValue": T[2] || (T[2] = (j) => r.value.freeText = j),
945
- type: "textarea",
946
- rows: 4,
947
- placeholder: e.freeTextPlaceholder
948
- }, null, 8, ["modelValue", "placeholder"])
949
- ]),
950
- _: 1
951
- }, 8, ["label"])
952
- ]),
953
- _: 1
954
- })
955
- ]),
956
- _: 1
957
- }, 8, ["modelValue", "title", "width"]);
958
- };
959
- }
960
- }), En = /* @__PURE__ */ Se(Mn, [["__scopeId", "data-v-9aa82e83"]]), $n = { class: "ai-task-panel" }, Pn = { class: "ai-task-panel__header" }, Ln = { class: "ai-task-panel__header-left" }, Dn = { class: "ai-task-panel__titles" }, Bn = { class: "ai-task-panel__subtitle" }, Vn = { class: "ai-task-panel__title" }, On = { class: "ai-task-panel__header-actions" }, Fn = { class: "ai-task-panel__body" }, Un = {
961
- key: 1,
962
- class: "ai-task-list"
963
- }, Rn = { class: "ai-task-row__icon" }, Kn = { class: "ai-task-row__main" }, Nn = { class: "ai-task-row__title" }, zn = { class: "ai-task-row__meta" }, Yn = { key: 0 }, Wn = {
964
- key: 0,
965
- class: "ai-task-row__summary"
966
- }, jn = { class: "ai-task-row__ops" }, Gn = {
967
- key: 0,
968
- class: "ai-task-panel__footer"
969
- }, qn = /* @__PURE__ */ ue({
970
- __name: "AiTaskPanel",
971
- emits: ["use"],
972
- setup(e, { emit: n }) {
973
- const t = n, o = ze(), l = k(null), g = {
974
- pending: "等待中",
975
- running: "执行中",
976
- succeeded: "已完成",
977
- failed: "失败",
978
- cancelled: "已取消"
979
- };
980
- function w(m) {
981
- return g[m] ?? m;
982
- }
983
- async function S(m) {
984
- l.value = m.id;
985
- try {
986
- const r = m.result ?? await o.loadTaskResult(m.id);
987
- if (!r) return;
988
- t("use", {
989
- taskId: m.id,
990
- runId: m.runId,
991
- title: m.title,
992
- freeText: m.freeText,
993
- promptId: m.promptId,
994
- result: r,
995
- finishedAt: m.finishedAt ?? Date.now()
996
- });
997
- } finally {
998
- l.value = null;
999
- }
1000
- }
1001
- return (m, r) => {
1002
- const L = O("el-icon"), U = O("el-button"), E = O("el-empty"), D = O("el-progress"), N = O("el-badge");
1003
- return d(), M(Et, { to: "body" }, [
1004
- f(tt, { name: "ai-panel-slide" }, {
1005
- default: p(() => [
1006
- ve(_("div", $n, [
1007
- _("div", Pn, [
1008
- _("div", Ln, [
1009
- _("div", {
1010
- class: re(["ai-task-panel__icon", { spinning: h(o).activeCount > 0 }])
1011
- }, [
1012
- f(L, null, {
1013
- default: p(() => [
1014
- f(h(Xe))
1015
- ]),
1016
- _: 1
1017
- })
1018
- ], 2),
1019
- _("div", Dn, [
1020
- _("div", Bn, V(h(o).panelSubtitle), 1),
1021
- _("div", Vn, V(h(o).panelTitle), 1)
1022
- ])
1023
- ]),
1024
- _("div", On, [
1025
- h(o).runningCount > 0 ? (d(), M(U, {
1026
- key: 0,
1027
- link: "",
1028
- type: "primary",
1029
- onClick: r[0] || (r[0] = (y) => h(o).cancelAll())
1030
- }, {
1031
- default: p(() => [...r[5] || (r[5] = [
1032
- q(" 取消全部 ", -1)
1033
- ])]),
1034
- _: 1
1035
- })) : P("", !0),
1036
- f(U, {
1037
- link: "",
1038
- onClick: r[1] || (r[1] = (y) => h(o).toggleMinimize())
1039
- }, {
1040
- default: p(() => [
1041
- f(L, null, {
1042
- default: p(() => [
1043
- f(h(Ut))
1044
- ]),
1045
- _: 1
1046
- })
1047
- ]),
1048
- _: 1
1049
- }),
1050
- f(U, {
1051
- link: "",
1052
- onClick: r[2] || (r[2] = (y) => h(o).hidePanel())
1053
- }, {
1054
- default: p(() => [
1055
- f(L, null, {
1056
- default: p(() => [
1057
- f(h(at))
1058
- ]),
1059
- _: 1
1060
- })
1061
- ]),
1062
- _: 1
1063
- })
1064
- ])
1065
- ]),
1066
- _("div", Fn, [
1067
- h(o).tasks.length ? (d(), A("div", Un, [
1068
- (d(!0), A(ae, null, ge(h(o).tasks, (y) => (d(), A("div", {
1069
- key: y.id,
1070
- class: "ai-task-row"
1071
- }, [
1072
- _("div", Rn, [
1073
- y.status === "succeeded" ? (d(), M(L, {
1074
- key: 0,
1075
- class: "ok"
1076
- }, {
1077
- default: p(() => [
1078
- f(h(Rt))
1079
- ]),
1080
- _: 1
1081
- })) : y.status === "failed" ? (d(), M(L, {
1082
- key: 1,
1083
- class: "err"
1084
- }, {
1085
- default: p(() => [
1086
- f(h(Kt))
1087
- ]),
1088
- _: 1
1089
- })) : y.status === "running" || y.status === "pending" ? (d(), M(D, {
1090
- key: 2,
1091
- type: "circle",
1092
- percentage: y.progress,
1093
- width: 36,
1094
- "stroke-width": 3
1095
- }, null, 8, ["percentage"])) : (d(), M(L, {
1096
- key: 3,
1097
- class: "muted"
1098
- }, {
1099
- default: p(() => [
1100
- f(h(Nt))
1101
- ]),
1102
- _: 1
1103
- }))
1104
- ]),
1105
- _("div", Kn, [
1106
- _("div", Nn, V(y.title), 1),
1107
- _("div", zn, [
1108
- _("span", null, V(w(y.status)), 1),
1109
- y.runId ? (d(), A("span", Yn, " · #" + V(y.runId), 1)) : P("", !0)
1110
- ]),
1111
- y.summary ? (d(), A("div", Wn, V(y.summary), 1)) : P("", !0)
1112
- ]),
1113
- _("div", jn, [
1114
- y.status === "running" || y.status === "pending" ? (d(), M(U, {
1115
- key: 0,
1116
- link: "",
1117
- type: "danger",
1118
- size: "small",
1119
- onClick: ($) => h(o).cancelTask(y.id)
1120
- }, {
1121
- default: p(() => [...r[6] || (r[6] = [
1122
- q(" 取消 ", -1)
1123
- ])]),
1124
- _: 1
1125
- }, 8, ["onClick"])) : P("", !0),
1126
- y.status === "succeeded" && y.runId ? (d(), M(U, {
1127
- key: 1,
1128
- link: "",
1129
- type: "primary",
1130
- size: "small",
1131
- loading: l.value === y.id,
1132
- onClick: ($) => S(y)
1133
- }, {
1134
- default: p(() => [...r[7] || (r[7] = [
1135
- q(" 使用 ", -1)
1136
- ])]),
1137
- _: 1
1138
- }, 8, ["loading", "onClick"])) : P("", !0),
1139
- y.status !== "running" && y.status !== "pending" ? (d(), M(U, {
1140
- key: 2,
1141
- link: "",
1142
- size: "small",
1143
- onClick: ($) => h(o).removeTask(y.id)
1144
- }, {
1145
- default: p(() => [...r[8] || (r[8] = [
1146
- q(" 移除 ", -1)
1147
- ])]),
1148
- _: 1
1149
- }, 8, ["onClick"])) : P("", !0)
1150
- ])
1151
- ]))), 128))
1152
- ])) : (d(), M(E, {
1153
- key: 0,
1154
- description: "暂无 AI 任务",
1155
- "image-size": 64
1156
- }))
1157
- ]),
1158
- h(o).tasks.some((y) => y.status !== "running" && y.status !== "pending") ? (d(), A("div", Gn, [
1159
- f(U, {
1160
- link: "",
1161
- type: "info",
1162
- onClick: r[3] || (r[3] = (y) => h(o).clearFinished())
1163
- }, {
1164
- default: p(() => [...r[9] || (r[9] = [
1165
- q("清除已完成", -1)
1166
- ])]),
1167
- _: 1
1168
- })
1169
- ])) : P("", !0)
1170
- ], 512), [
1171
- [Ee, h(o).panelVisible && !h(o).panelMinimized]
1172
- ])
1173
- ]),
1174
- _: 1
1175
- }),
1176
- ve(_("div", {
1177
- class: "ai-task-panel-mini",
1178
- onClick: r[4] || (r[4] = (y) => h(o).toggleMinimize())
1179
- }, [
1180
- h(o).activeCount > 0 ? (d(), M(L, {
1181
- key: 0,
1182
- class: "spinning"
1183
- }, {
1184
- default: p(() => [
1185
- f(h(Xe))
1186
- ]),
1187
- _: 1
1188
- })) : P("", !0),
1189
- _("span", null, V(h(o).panelSubtitle), 1),
1190
- h(o).runningCount > 0 ? (d(), M(N, {
1191
- key: 1,
1192
- value: h(o).runningCount,
1193
- class: "m-l-8"
1194
- }, null, 8, ["value"])) : P("", !0)
1195
- ], 512), [
1196
- [Ee, h(o).panelVisible && h(o).panelMinimized]
1197
- ])
1198
- ]);
1199
- };
1200
- }
1201
- }), Hn = /* @__PURE__ */ Se(qn, [["__scopeId", "data-v-812b3127"]]), Vo = /* @__PURE__ */ ue({
1202
- __name: "AiTaskProvider",
1203
- props: {
1204
- title: {},
1205
- freeText: {},
1206
- promptId: {},
1207
- autoMatch: { type: Boolean },
1208
- prompts: {},
1209
- showAutoMatch: { type: Boolean },
1210
- showPromptSelect: { type: Boolean },
1211
- autoMatchLabel: {},
1212
- promptLabel: {},
1213
- freeTextLabel: {},
1214
- freeTextPlaceholder: {},
1215
- submitText: {},
1216
- showTaskListButton: { type: Boolean },
1217
- taskListButtonText: {},
1218
- width: {},
1219
- modelValue: { type: Boolean },
1220
- showDialog: { type: Boolean, default: !0 }
1221
- },
1222
- emits: ["finish", "use"],
1223
- setup(e, { emit: n }) {
1224
- const t = e, o = n, l = gt();
1225
- $e(ft, l), $e(dt, ut(l));
1226
- const g = B(() => {
1227
- const m = {
1228
- title: t.title,
1229
- freeText: t.freeText,
1230
- promptId: t.promptId,
1231
- autoMatch: t.autoMatch,
1232
- prompts: t.prompts,
1233
- showAutoMatch: t.showAutoMatch,
1234
- showPromptSelect: t.showPromptSelect,
1235
- autoMatchLabel: t.autoMatchLabel,
1236
- promptLabel: t.promptLabel,
1237
- freeTextLabel: t.freeTextLabel,
1238
- freeTextPlaceholder: t.freeTextPlaceholder,
1239
- submitText: t.submitText,
1240
- showTaskListButton: t.showTaskListButton,
1241
- taskListButtonText: t.taskListButtonText,
1242
- width: t.width
1243
- };
1244
- return t.modelValue !== void 0 && (m.modelValue = t.modelValue), m;
1245
- });
1246
- let w;
1247
- function S(m) {
1248
- o("use", m);
1249
- }
1250
- return Fe(() => {
1251
- l.hydrate(), w = l.onTaskFinish((m) => o("finish", m));
1252
- }), Ue(() => {
1253
- w == null || w();
1254
- }), (m, r) => (d(), A(ae, null, [
1255
- e.showDialog !== !1 ? (d(), M(En, $t(ot({ key: 0 }, g.value)), null, 16)) : P("", !0),
1256
- f(Hn, { onUse: S }),
1257
- Ce(m.$slots, "default")
1258
- ], 64));
1259
- }
1260
- });
1261
- function Oo() {
1262
- const e = Oe(dt, null);
1263
- return e || ut(ze());
1264
- }
1265
- const Me = "__YC_COMPONENT_IMAGE_SELECTOR__", Ve = "yc-component:image-selector-open";
1266
- function Jn() {
1267
- const e = globalThis;
1268
- return e[Me] || (e[Me] = nt({
1269
- visible: !1,
1270
- options: {}
1271
- })), e[Me];
1272
- }
1273
- const G = Jn();
1274
- function Xn(e = {}) {
1275
- G.options = { ...e }, G.visible = !0, globalThis.dispatchEvent(
1276
- new CustomEvent(Ve, { detail: { ...e } })
1277
- );
1278
- }
1279
- function Qn() {
1280
- G.visible = !1;
1281
- }
1282
- function Zn(e = {}) {
1283
- Xn(e);
1284
- }
1285
- const eo = { class: "yc-image-selector" }, to = { class: "yc-image-selector__toolbar" }, no = { class: "yc-image-selector__body" }, oo = {
1286
- key: 0,
1287
- class: "yc-image-selector__aside"
1288
- }, ao = ["onClick"], lo = {
1289
- key: 0,
1290
- class: "yc-image-selector__category-count"
1291
- }, io = { class: "yc-image-selector__main" }, so = {
1292
- key: 1,
1293
- class: "yc-image-selector__grid"
1294
- }, ro = ["onClick"], uo = { class: "yc-image-selector__thumb" }, co = ["src", "alt", "onLoad"], fo = {
1295
- key: 0,
1296
- class: "yc-image-selector__order"
1297
- }, po = ["title"], mo = {
1298
- key: 0,
1299
- class: "yc-image-selector__selected-bar"
1300
- }, go = { class: "yc-image-selector__selected-bar-label" }, vo = { class: "yc-image-selector__selected-bar-list" }, _o = ["onClick"], ho = ["src", "alt"], yo = {
1301
- key: 1,
1302
- class: "yc-image-selector__pagination"
1303
- }, wo = {
1304
- key: 0,
1305
- class: "yc-image-selector__footer"
1306
- }, To = { class: "yc-image-selector__selected-tip" }, Io = { class: "yc-image-selector__footer-actions" }, Co = {
1307
- key: 1,
1308
- class: "yc-image-selector__footer yc-image-selector__footer--quick"
1309
- }, So = { class: "yc-image-selector__selected-tip" }, ko = /* @__PURE__ */ ue({
1310
- __name: "YcImageSelectorDialog",
1271
+ dialogVisible: o,
1272
+ dialogOptions: l,
1273
+ hydrated: m,
1274
+ runningCount: R,
1275
+ activeCount: Y,
1276
+ panelTitle: L,
1277
+ panelSubtitle: g,
1278
+ hydrate: te,
1279
+ showPanel: O,
1280
+ hidePanel: j,
1281
+ toggleMinimize: _,
1282
+ openDialog: C,
1283
+ closeDialog: G,
1284
+ enqueue: Q,
1285
+ onTaskFinish: U,
1286
+ refreshActiveTasks: J,
1287
+ loadTaskResult: z,
1288
+ cancelTask: fe,
1289
+ cancelAll: be,
1290
+ clearFinished: ye,
1291
+ removeTask: Ae
1292
+ };
1293
+ });
1294
+ async function _o(e) {
1295
+ return (await de().get("/yc-ai/ai/prompts", {
1296
+ params: e ? { category: e } : {}
1297
+ })).data;
1298
+ }
1299
+ function je() {
1300
+ const e = Ne(Tt, null);
1301
+ return e || St();
1302
+ }
1303
+ const ho = { class: "ai-use-dialog__footer" }, yo = { class: "ai-use-dialog__footer-actions" }, wo = /* @__PURE__ */ ce({
1304
+ __name: "AiUseDialog",
1311
1305
  props: {
1306
+ title: { default: "AI 生成" },
1307
+ freeText: { default: "" },
1308
+ promptId: {},
1309
+ autoMatch: { type: Boolean, default: !1 },
1310
+ prompts: {},
1311
+ showAutoMatch: { type: Boolean, default: !1 },
1312
+ showPromptSelect: { type: Boolean, default: !1 },
1313
+ autoMatchLabel: { default: "自动匹配提示词" },
1314
+ promptLabel: { default: "提示词" },
1315
+ freeTextLabel: { default: "需求描述" },
1316
+ freeTextPlaceholder: { default: "描述要生成的页面或项目 JSON" },
1317
+ submitText: { default: "发送" },
1318
+ showTaskListButton: { type: Boolean, default: !0 },
1319
+ taskListButtonText: { default: "查看 AI 任务" },
1320
+ width: { default: "520px" },
1312
1321
  modelValue: { type: Boolean },
1313
- title: { default: "选择图片" },
1314
- multiple: { type: Boolean, default: !1 },
1315
- maxCount: { default: 9 },
1316
- selected: {},
1317
- width: { default: "860px" },
1318
- pageSize: { default: 8 },
1319
- showUpload: { type: Boolean, default: !0 },
1320
- accept: { default: "image/*" },
1321
- showCategories: { type: Boolean, default: !1 },
1322
- categories: {},
1323
- categoryAllLabel: { default: "全部" },
1324
- showModeSwitch: { type: Boolean, default: !1 },
1325
- confirmOnSelect: { type: Boolean, default: !1 },
1326
- confirmText: { default: "确定" },
1327
- cancelText: { default: "取消" },
1328
- emptyText: { default: "暂无图片资源" },
1329
- getImages: {},
1330
- upload: {},
1331
- urlField: { default: "url" }
1322
+ showDialog: { type: Boolean }
1332
1323
  },
1333
- emits: ["update:modelValue", "confirm", "cancel"],
1324
+ emits: ["update:modelValue", "submitted"],
1334
1325
  setup(e, { emit: n }) {
1335
- const t = e, o = n, l = B(() => t.modelValue !== void 0), g = k(!1);
1336
- te(
1326
+ const t = e, o = n, l = je(), m = D(() => t.modelValue !== void 0), y = b(!1);
1327
+ ne(
1337
1328
  () => t.modelValue,
1338
- (i) => {
1339
- l.value && (g.value = !!i);
1329
+ (_) => {
1330
+ m.value && (y.value = !!_);
1340
1331
  },
1341
1332
  { immediate: !0 }
1342
- ), te(g, (i) => {
1343
- if (l.value) {
1344
- o("update:modelValue", i);
1333
+ ), ne(y, (_) => {
1334
+ if (m.value) {
1335
+ o("update:modelValue", _);
1345
1336
  return;
1346
1337
  }
1347
- G.visible = i, i || Qn();
1348
- }), te(
1349
- () => G.visible,
1350
- (i) => {
1351
- l.value || (g.value = i);
1338
+ oe.visible = _, _ || _t();
1339
+ }), ne(
1340
+ () => oe.visible,
1341
+ (_) => {
1342
+ m.value || (y.value = _);
1352
1343
  },
1353
1344
  { immediate: !0 }
1354
1345
  );
1355
- const w = B(
1356
- () => (l.value ? void 0 : G.options.title) ?? t.title ?? "选择图片"
1357
- ), S = B(
1358
- () => (l.value ? void 0 : G.options.multiple) ?? t.multiple
1359
- ), m = B(
1360
- () => (l.value ? void 0 : G.options.maxCount) ?? t.maxCount
1361
- ), r = B(
1362
- () => (l.value ? void 0 : G.options.showModeSwitch) ?? t.showModeSwitch
1363
- ), L = B(
1364
- () => (l.value ? void 0 : G.options.showCategories) ?? t.showCategories
1365
- ), U = B(() => {
1366
- var i, s;
1367
- if ((i = t.categories) != null && i.length) return t.categories;
1368
- if (!l.value && ((s = G.options.categories) != null && s.length))
1369
- return G.options.categories;
1370
- }), E = B(() => L.value ? U.value ?? H.value : []), D = B(() => !!t.confirmOnSelect), N = k("single"), y = [
1371
- { label: "单选", value: "single" },
1372
- { label: "多选", value: "multiple" }
1373
- ], $ = B(
1374
- () => r.value ? N.value === "multiple" : S.value
1375
- ), z = k(""), C = k(""), F = k(1), Y = k(0), v = k(!1), T = k(!1), W = k([]), H = k([]), x = k(/* @__PURE__ */ new Map()), J = k(/* @__PURE__ */ new Map()), X = k(), ne = k(), K = B(() => [...x.value.values()]), ie = B(() => {
1376
- var s, b;
1377
- const i = K.value.length;
1378
- return D.value ? i ? `已选:${((s = K.value[0]) == null ? void 0 : s.name) || "1 张图片"}` : "单击图片即可完成选择" : i ? $.value ? `已选 ${i} / ${m.value} 张` : `已选:${((b = K.value[0]) == null ? void 0 : b.name) || "1 张图片"}` : $.value ? `多选模式:最多 ${m.value} 张` : "单选模式:请选择一张图片";
1379
- });
1380
- function j(i) {
1381
- const s = K.value.findIndex((b) => a(b) === a(i));
1382
- return s >= 0 ? s + 1 : "";
1383
- }
1384
- function de(i) {
1385
- if (i === "single" && K.value.length > 1) {
1386
- const s = K.value[0];
1387
- x.value = /* @__PURE__ */ new Map([[a(s), s]]), Z.info("已切换为单选,仅保留第一张");
1388
- }
1389
- }
1390
- function he() {
1391
- N.value = S.value ? "multiple" : "single";
1346
+ function T(_) {
1347
+ if (m.value) return;
1348
+ const C = _.detail ?? {};
1349
+ L(C), y.value = !0;
1392
1350
  }
1393
- function ke() {
1394
- x.value = /* @__PURE__ */ new Map();
1395
- }
1396
- function ye(i) {
1397
- return i[t.urlField];
1398
- }
1399
- function a(i) {
1400
- return i.id ?? i.url;
1401
- }
1402
- function u(i) {
1403
- return x.value.has(a(i));
1404
- }
1405
- function c(i, s) {
1406
- return i < s ? "portrait" : i > s ? "landscape" : "square";
1407
- }
1408
- function R(i, s) {
1409
- const b = a(i);
1410
- J.value.get(b) !== s && (J.value.set(b, s), J.value = new Map(J.value));
1411
- }
1412
- function se(i) {
1413
- const s = J.value.get(a(i));
1414
- return s ? `yc-image-selector__img--${s}` : "";
1415
- }
1416
- function fe(i, s) {
1417
- const b = i.target;
1418
- !(b != null && b.naturalWidth) || !(b != null && b.naturalHeight) || R(s, c(b.naturalWidth, b.naturalHeight));
1419
- }
1420
- function yt(i) {
1421
- i.width && i.height && R(i, c(i.width, i.height));
1422
- }
1423
- function Ye(i) {
1424
- const s = /* @__PURE__ */ new Map();
1425
- if (!(i != null && i.length)) {
1426
- x.value = s;
1427
- return;
1428
- }
1429
- if (typeof i[0] == "string")
1430
- for (const Q of i)
1431
- s.set(Q, { id: Q, url: Q, name: Q.split("/").pop() });
1432
- else
1433
- for (const Q of i)
1434
- s.set(a(Q), Q);
1435
- x.value = s;
1436
- }
1437
- function xe(i) {
1438
- X.value = i.onConfirm, ne.value = i.onCancel, Ye(i.selected ?? t.selected);
1439
- }
1440
- function We(i) {
1441
- if (l.value) return;
1442
- const s = i.detail ?? {};
1443
- xe(s), g.value = !0;
1444
- }
1445
- Fe(() => {
1446
- globalThis.addEventListener(Ve, We), l.value || (g.value = G.visible);
1447
- }), Ue(() => {
1448
- globalThis.removeEventListener(Ve, We);
1351
+ Re(() => {
1352
+ globalThis.addEventListener(Oe, T), m.value || (y.value = oe.visible);
1353
+ }), Ke(() => {
1354
+ globalThis.removeEventListener(Oe, T);
1449
1355
  });
1450
- async function be() {
1451
- var i;
1452
- if (!t.getImages) {
1453
- Z.error("请通过 props.getImages 传入图片列表请求方法");
1454
- return;
1455
- }
1456
- v.value = !0;
1457
- try {
1458
- const s = await t.getImages({
1459
- keyword: z.value.trim() || void 0,
1460
- category: L.value && C.value || void 0,
1461
- page: F.value,
1462
- pageSize: t.pageSize
1463
- });
1464
- W.value = s.list, Y.value = s.total;
1465
- for (const b of s.list)
1466
- yt(b);
1467
- L.value && !U.value && ((i = s.categories) != null && i.length) && (H.value = s.categories);
1468
- } catch (s) {
1469
- Z.error(s instanceof Error ? s.message : "加载图片失败");
1470
- } finally {
1471
- v.value = !1;
1472
- }
1473
- }
1474
- function we() {
1475
- F.value = 1, be();
1476
- }
1477
- function je(i) {
1478
- C.value !== i && (C.value = i, we());
1356
+ const v = D(
1357
+ () => (m.value ? void 0 : oe.options.title) ?? t.title ?? "AI 生成"
1358
+ ), r = b({
1359
+ freeText: t.freeText,
1360
+ promptId: t.promptId,
1361
+ autoMatch: t.autoMatch
1362
+ }), I = b(t.prompts ? [...t.prompts] : []), U = b(!1), R = b(!1), Y = b();
1363
+ function L(_) {
1364
+ var C, G;
1365
+ r.value.freeText = _.freeText ?? t.freeText ?? "", r.value.promptId = _.promptId ?? t.promptId, r.value.autoMatch = _.autoMatch ?? t.autoMatch ?? !1, Y.value = _.onFinish, (C = _.prompts) != null && C.length ? I.value = [..._.prompts] : (G = t.prompts) != null && G.length && (I.value = [...t.prompts]);
1479
1366
  }
1480
- function Ge(i) {
1481
- const s = a(i);
1482
- if ($.value) {
1483
- if (x.value.has(s)) {
1484
- x.value.delete(s), x.value = new Map(x.value);
1485
- return;
1486
- }
1487
- if (K.value.length >= m.value) {
1488
- Z.warning(`最多选择 ${m.value} 张图片`);
1489
- return;
1490
- }
1491
- x.value.set(s, i), x.value = new Map(x.value);
1492
- return;
1493
- }
1494
- if (x.value.has(s)) {
1495
- if (D.value) {
1496
- Je(() => Te());
1497
- return;
1367
+ async function g() {
1368
+ if (!(I.value.length > 0)) {
1369
+ U.value = !0;
1370
+ try {
1371
+ const _ = ct().listPrompts;
1372
+ I.value = _ ? await _() : await _o();
1373
+ } catch {
1374
+ Z.warning("加载提示词失败");
1375
+ } finally {
1376
+ U.value = !1;
1498
1377
  }
1499
- x.value = /* @__PURE__ */ new Map();
1500
- return;
1501
1378
  }
1502
- x.value = /* @__PURE__ */ new Map([[s, i]]), D.value && Je(() => Te());
1503
1379
  }
1504
- async function wt(i) {
1505
- if (!t.upload) {
1506
- Z.error("请通过 props.upload 传入图片上传方法");
1507
- return;
1508
- }
1509
- T.value = !0;
1510
- try {
1511
- const { resource: s } = await t.upload(i.file);
1512
- if (Z.success("上传成功"), $.value)
1513
- K.value.length < m.value && (x.value.set(a(s), s), x.value = new Map(x.value));
1514
- else if (x.value = /* @__PURE__ */ new Map([[a(s), s]]), D.value) {
1515
- Te();
1516
- return;
1517
- }
1518
- we();
1519
- } catch (s) {
1520
- Z.error(s instanceof Error ? s.message : "上传失败");
1521
- } finally {
1522
- T.value = !1;
1523
- }
1380
+ function x() {
1381
+ m.value ? L({}) : L(oe.options), t.showPromptSelect && g();
1524
1382
  }
1525
- function Tt() {
1526
- z.value = "", C.value = "", F.value = 1, H.value = [], J.value = /* @__PURE__ */ new Map(), he(), l.value ? xe({}) : xe(G.options), he(), be();
1383
+ ne(
1384
+ () => t.prompts,
1385
+ (_) => {
1386
+ _ != null && _.length && (I.value = [..._]);
1387
+ },
1388
+ { deep: !0 }
1389
+ ), ne(
1390
+ () => [t.freeText, t.promptId, t.autoMatch],
1391
+ ([_, C, G]) => {
1392
+ y.value || (r.value.freeText = _ ?? "", r.value.promptId = C, r.value.autoMatch = G ?? !1);
1393
+ }
1394
+ );
1395
+ function N() {
1396
+ r.value.autoMatch && (r.value.promptId = void 0);
1527
1397
  }
1528
- function It() {
1529
- T.value = !1;
1398
+ function k() {
1399
+ R.value = !1;
1530
1400
  }
1531
- function qe() {
1532
- var i, s, b;
1533
- (i = ne.value) == null || i.call(ne), l.value || (b = (s = G.options).onCancel) == null || b.call(s), o("cancel"), g.value = !1;
1401
+ function O() {
1402
+ l.showPanel();
1534
1403
  }
1535
- function Te() {
1536
- var s, b, Q;
1537
- if (!K.value.length) {
1538
- Z.warning("请选择图片");
1404
+ async function j() {
1405
+ var A, J;
1406
+ if (!r.value.freeText.trim()) {
1407
+ Z.warning("请填写需求描述");
1539
1408
  return;
1540
1409
  }
1541
- const i = [...K.value];
1542
- if (l.value) {
1543
- o("confirm", i), g.value = !1;
1410
+ const _ = r.value.autoMatch, C = _ ? void 0 : r.value.promptId;
1411
+ if (!_ && C == null) {
1412
+ const X = t.showPromptSelect || t.showAutoMatch ? "请选择提示词或开启自动匹配" : "请通过 promptId 传入提示词,或设置 autoMatch 为 true";
1413
+ Z.warning(X);
1544
1414
  return;
1545
1415
  }
1546
- (s = X.value) == null || s.call(X, i), (Q = (b = G.options).onConfirm) == null || Q.call(b, i), o("confirm", i), g.value = !1;
1416
+ R.value = !0;
1417
+ const G = m.value ? Y.value : oe.options.onFinish, q = l.enqueue({
1418
+ freeText: r.value.freeText.trim(),
1419
+ promptId: C,
1420
+ autoMatch: _ && C == null ? !0 : void 0,
1421
+ showPanel: !0,
1422
+ onFinish: G
1423
+ });
1424
+ m.value ? o("submitted", q) : (J = (A = oe.options).onSubmitted) == null || J.call(A, q), y.value = !1, R.value = !1, Z.success("已加入任务队列,可在任务面板查看进度");
1547
1425
  }
1548
- return te(
1549
- () => t.selected,
1550
- (i) => {
1551
- g.value || Ye(i);
1552
- },
1553
- { deep: !0 }
1554
- ), (i, s) => {
1555
- const b = O("el-icon"), Q = O("el-input"), Ct = O("el-segmented"), pe = O("el-button"), St = O("el-upload"), kt = O("el-empty"), xt = O("el-pagination"), bt = O("el-dialog"), At = et("loading");
1556
- return d(), M(bt, {
1557
- modelValue: g.value,
1558
- "onUpdate:modelValue": s[4] || (s[4] = (I) => g.value = I),
1559
- title: w.value,
1426
+ return (_, C) => {
1427
+ const G = V("el-switch"), q = V("el-form-item"), A = V("el-option"), J = V("el-select"), X = V("el-input"), te = V("el-form"), Q = V("el-button"), K = V("el-dialog");
1428
+ return d(), E(K, {
1429
+ modelValue: y.value,
1430
+ "onUpdate:modelValue": C[4] || (C[4] = (z) => y.value = z),
1431
+ title: v.value,
1560
1432
  width: e.width,
1561
1433
  "append-to-body": "",
1562
- "destroy-on-close": "",
1563
- class: "yc-image-selector-dialog",
1564
- onClosed: It,
1565
- onOpen: Tt
1434
+ class: "ai-use-dialog",
1435
+ onClosed: k,
1436
+ onOpen: x
1566
1437
  }, {
1567
1438
  footer: p(() => [
1568
- D.value ? (d(), A("div", Co, [
1569
- _("span", So, V(ie.value), 1),
1570
- f(pe, {
1439
+ h("div", ho, [
1440
+ e.showTaskListButton ? (d(), E(Q, {
1441
+ key: 0,
1571
1442
  link: "",
1572
1443
  type: "primary",
1573
- onClick: qe
1444
+ onClick: O
1574
1445
  }, {
1575
1446
  default: p(() => [
1576
- q(V(e.cancelText), 1)
1447
+ W(B(e.taskListButtonText), 1)
1577
1448
  ]),
1578
1449
  _: 1
1579
- })
1580
- ])) : (d(), A("div", wo, [
1581
- _("span", To, V(ie.value), 1),
1582
- _("div", Io, [
1583
- f(pe, { onClick: qe }, {
1584
- default: p(() => [
1585
- q(V(e.cancelText), 1)
1586
- ]),
1450
+ })) : $("", !0),
1451
+ h("div", yo, [
1452
+ f(Q, {
1453
+ onClick: C[3] || (C[3] = (z) => y.value = !1)
1454
+ }, {
1455
+ default: p(() => [...C[5] || (C[5] = [
1456
+ W("取消", -1)
1457
+ ])]),
1587
1458
  _: 1
1588
1459
  }),
1589
- f(pe, {
1460
+ f(Q, {
1590
1461
  type: "primary",
1591
- disabled: !K.value.length,
1592
- onClick: Te
1462
+ loading: R.value,
1463
+ onClick: j
1464
+ }, {
1465
+ default: p(() => [
1466
+ W(B(e.submitText), 1)
1467
+ ]),
1468
+ _: 1
1469
+ }, 8, ["loading"])
1470
+ ])
1471
+ ])
1472
+ ]),
1473
+ default: p(() => [
1474
+ f(te, { "label-position": "top" }, {
1475
+ default: p(() => [
1476
+ e.showAutoMatch ? (d(), E(q, {
1477
+ key: 0,
1478
+ label: e.autoMatchLabel
1479
+ }, {
1480
+ default: p(() => [
1481
+ f(G, {
1482
+ modelValue: r.value.autoMatch,
1483
+ "onUpdate:modelValue": C[0] || (C[0] = (z) => r.value.autoMatch = z),
1484
+ "active-text": "按需求自动选",
1485
+ "inactive-text": "手动指定",
1486
+ onChange: N
1487
+ }, null, 8, ["modelValue"])
1488
+ ]),
1489
+ _: 1
1490
+ }, 8, ["label"])) : $("", !0),
1491
+ e.showPromptSelect ? (d(), E(q, {
1492
+ key: 1,
1493
+ label: e.promptLabel,
1494
+ required: !r.value.autoMatch
1495
+ }, {
1496
+ default: p(() => [
1497
+ f(J, {
1498
+ modelValue: r.value.promptId,
1499
+ "onUpdate:modelValue": C[1] || (C[1] = (z) => r.value.promptId = z),
1500
+ filterable: "",
1501
+ clearable: "",
1502
+ placeholder: r.value.autoMatch ? "留空则自动匹配" : "请选择提示词",
1503
+ style: { width: "100%" },
1504
+ loading: U.value
1505
+ }, {
1506
+ default: p(() => [
1507
+ (d(!0), M(ie, null, ve(I.value, (z) => (d(), E(A, {
1508
+ key: z.id,
1509
+ label: z.name,
1510
+ value: z.id
1511
+ }, null, 8, ["label", "value"]))), 128))
1512
+ ]),
1513
+ _: 1
1514
+ }, 8, ["modelValue", "placeholder", "loading"])
1515
+ ]),
1516
+ _: 1
1517
+ }, 8, ["label", "required"])) : $("", !0),
1518
+ f(q, {
1519
+ label: e.freeTextLabel,
1520
+ required: ""
1593
1521
  }, {
1594
1522
  default: p(() => [
1595
- q(V(e.confirmText), 1)
1523
+ f(X, {
1524
+ modelValue: r.value.freeText,
1525
+ "onUpdate:modelValue": C[2] || (C[2] = (z) => r.value.freeText = z),
1526
+ type: "textarea",
1527
+ rows: 4,
1528
+ placeholder: e.freeTextPlaceholder
1529
+ }, null, 8, ["modelValue", "placeholder"])
1530
+ ]),
1531
+ _: 1
1532
+ }, 8, ["label"])
1533
+ ]),
1534
+ _: 1
1535
+ })
1536
+ ]),
1537
+ _: 1
1538
+ }, 8, ["modelValue", "title", "width"]);
1539
+ };
1540
+ }
1541
+ }), To = /* @__PURE__ */ xe(wo, [["__scopeId", "data-v-9aa82e83"]]), Io = { class: "ai-task-panel" }, Co = { class: "ai-task-panel__header" }, So = { class: "ai-task-panel__header-left" }, ko = { class: "ai-task-panel__titles" }, xo = { class: "ai-task-panel__subtitle" }, bo = { class: "ai-task-panel__title" }, Ao = { class: "ai-task-panel__header-actions" }, Mo = { class: "ai-task-panel__body" }, Eo = {
1542
+ key: 1,
1543
+ class: "ai-task-list"
1544
+ }, Po = { class: "ai-task-row__icon" }, $o = { class: "ai-task-row__main" }, Lo = { class: "ai-task-row__title" }, Do = { class: "ai-task-row__meta" }, Bo = { key: 0 }, Vo = {
1545
+ key: 0,
1546
+ class: "ai-task-row__summary"
1547
+ }, Oo = { class: "ai-task-row__ops" }, Uo = {
1548
+ key: 0,
1549
+ class: "ai-task-panel__footer"
1550
+ }, Fo = /* @__PURE__ */ ce({
1551
+ __name: "AiTaskPanel",
1552
+ emits: ["use"],
1553
+ setup(e, { emit: n }) {
1554
+ const t = n, o = je(), l = b(null), m = {
1555
+ pending: "等待中",
1556
+ running: "执行中",
1557
+ succeeded: "已完成",
1558
+ failed: "失败",
1559
+ cancelled: "已取消"
1560
+ };
1561
+ function y(v) {
1562
+ return m[v] ?? v;
1563
+ }
1564
+ async function T(v) {
1565
+ l.value = v.id;
1566
+ try {
1567
+ const r = v.result ?? await o.loadTaskResult(v.id);
1568
+ if (!r) return;
1569
+ t("use", {
1570
+ taskId: v.id,
1571
+ runId: v.runId,
1572
+ title: v.title,
1573
+ freeText: v.freeText,
1574
+ promptId: v.promptId,
1575
+ result: r,
1576
+ finishedAt: v.finishedAt ?? Date.now()
1577
+ });
1578
+ } finally {
1579
+ l.value = null;
1580
+ }
1581
+ }
1582
+ return (v, r) => {
1583
+ const I = V("el-icon"), U = V("el-button"), R = V("el-empty"), Y = V("el-progress"), L = V("el-badge");
1584
+ return d(), E(Kt, { to: "body" }, [
1585
+ f(it, { name: "ai-panel-slide" }, {
1586
+ default: p(() => [
1587
+ _e(h("div", Io, [
1588
+ h("div", Co, [
1589
+ h("div", So, [
1590
+ h("div", {
1591
+ class: ue(["ai-task-panel__icon", { spinning: w(o).activeCount > 0 }])
1592
+ }, [
1593
+ f(I, null, {
1594
+ default: p(() => [
1595
+ f(w(Ze))
1596
+ ]),
1597
+ _: 1
1598
+ })
1599
+ ], 2),
1600
+ h("div", ko, [
1601
+ h("div", xo, B(w(o).panelSubtitle), 1),
1602
+ h("div", bo, B(w(o).panelTitle), 1)
1603
+ ])
1596
1604
  ]),
1597
- _: 1
1598
- }, 8, ["disabled"])
1599
- ])
1600
- ]))
1601
- ]),
1602
- default: p(() => [
1603
- _("div", eo, [
1604
- _("div", to, [
1605
- f(Q, {
1606
- modelValue: z.value,
1607
- "onUpdate:modelValue": s[0] || (s[0] = (I) => z.value = I),
1608
- clearable: "",
1609
- placeholder: "搜索图片名称",
1610
- class: "yc-image-selector__search",
1611
- onKeyup: Pt(we, ["enter"]),
1612
- onClear: we
1613
- }, {
1614
- prefix: p(() => [
1615
- f(b, null, {
1605
+ h("div", Ao, [
1606
+ w(o).runningCount > 0 ? (d(), E(U, {
1607
+ key: 0,
1608
+ link: "",
1609
+ type: "primary",
1610
+ onClick: r[0] || (r[0] = (g) => w(o).cancelAll())
1611
+ }, {
1612
+ default: p(() => [...r[5] || (r[5] = [
1613
+ W(" 取消全部 ", -1)
1614
+ ])]),
1615
+ _: 1
1616
+ })) : $("", !0),
1617
+ f(U, {
1618
+ link: "",
1619
+ onClick: r[1] || (r[1] = (g) => w(o).toggleMinimize())
1620
+ }, {
1616
1621
  default: p(() => [
1617
- f(h(zt))
1622
+ f(I, null, {
1623
+ default: p(() => [
1624
+ f(w(Jt))
1625
+ ]),
1626
+ _: 1
1627
+ })
1618
1628
  ]),
1619
1629
  _: 1
1620
- })
1621
- ]),
1622
- _: 1
1623
- }, 8, ["modelValue"]),
1624
- r.value ? (d(), M(Ct, {
1625
- key: 0,
1626
- modelValue: N.value,
1627
- "onUpdate:modelValue": s[1] || (s[1] = (I) => N.value = I),
1628
- options: y,
1629
- class: "yc-image-selector__mode",
1630
- onChange: de
1631
- }, null, 8, ["modelValue"])) : P("", !0),
1632
- e.showUpload && e.upload ? (d(), M(St, {
1633
- key: 1,
1634
- "show-file-list": !1,
1635
- accept: e.accept,
1636
- "http-request": wt,
1637
- disabled: T.value
1638
- }, {
1639
- default: p(() => [
1640
- f(pe, {
1641
- type: "primary",
1642
- plain: "",
1643
- loading: T.value
1630
+ }),
1631
+ f(U, {
1632
+ link: "",
1633
+ onClick: r[2] || (r[2] = (g) => w(o).hidePanel())
1644
1634
  }, {
1645
1635
  default: p(() => [
1646
- f(b, { class: "m-r-4" }, {
1636
+ f(I, null, {
1647
1637
  default: p(() => [
1648
- f(h(Yt))
1638
+ f(w(ut))
1649
1639
  ]),
1650
1640
  _: 1
1651
- }),
1652
- s[5] || (s[5] = q(" 上传图片 ", -1))
1641
+ })
1653
1642
  ]),
1654
1643
  _: 1
1655
- }, 8, ["loading"])
1656
- ]),
1657
- _: 1
1658
- }, 8, ["accept", "disabled"])) : P("", !0)
1659
- ]),
1660
- _("div", no, [
1661
- L.value ? (d(), A("aside", oo, [
1662
- _("div", {
1663
- class: re(["yc-image-selector__category", { "is-active": C.value === "" }]),
1664
- onClick: s[2] || (s[2] = (I) => je(""))
1665
- }, V(e.categoryAllLabel), 3),
1666
- (d(!0), A(ae, null, ge(E.value, (I) => (d(), A("div", {
1667
- key: I.id,
1668
- class: re(["yc-image-selector__category", { "is-active": C.value === I.id }]),
1669
- onClick: (Ie) => je(I.id)
1670
- }, [
1671
- _("span", null, V(I.name), 1),
1672
- I.count != null ? (d(), A("span", lo, V(I.count), 1)) : P("", !0)
1673
- ], 10, ao))), 128))
1674
- ])) : P("", !0),
1675
- ve((d(), A("div", io, [
1676
- !v.value && !W.value.length ? (d(), M(kt, {
1677
- key: 0,
1678
- description: e.emptyText
1679
- }, null, 8, ["description"])) : (d(), A("div", so, [
1680
- (d(!0), A(ae, null, ge(W.value, (I) => (d(), A("div", {
1681
- key: String(I.id),
1682
- class: re(["yc-image-selector__item", {
1683
- "is-selected": u(I),
1684
- "is-single-mode": !$.value,
1685
- "is-multi-mode": $.value
1686
- }]),
1687
- onClick: (Ie) => Ge(I)
1644
+ })
1645
+ ])
1646
+ ]),
1647
+ h("div", Mo, [
1648
+ w(o).tasks.length ? (d(), M("div", Eo, [
1649
+ (d(!0), M(ie, null, ve(w(o).tasks, (g) => (d(), M("div", {
1650
+ key: g.id,
1651
+ class: "ai-task-row"
1688
1652
  }, [
1689
- _("div", uo, [
1690
- _("img", {
1691
- src: ye(I),
1692
- alt: I.name || "image",
1693
- loading: "lazy",
1694
- class: re(se(I)),
1695
- onLoad: (Ie) => fe(Ie, I)
1696
- }, null, 42, co),
1697
- _("div", {
1698
- class: re(["yc-image-selector__indicator", {
1699
- "is-checked": u(I),
1700
- "is-radio": !$.value,
1701
- "is-checkbox": $.value
1702
- }])
1703
- }, [
1704
- u(I) && $.value ? (d(), A("span", fo, V(j(I)), 1)) : u(I) ? (d(), M(b, { key: 1 }, {
1705
- default: p(() => [
1706
- f(h(lt))
1707
- ]),
1708
- _: 1
1709
- })) : P("", !0)
1710
- ], 2)
1653
+ h("div", Po, [
1654
+ g.status === "succeeded" ? (d(), E(I, {
1655
+ key: 0,
1656
+ class: "ok"
1657
+ }, {
1658
+ default: p(() => [
1659
+ f(w(Xt))
1660
+ ]),
1661
+ _: 1
1662
+ })) : g.status === "failed" ? (d(), E(I, {
1663
+ key: 1,
1664
+ class: "err"
1665
+ }, {
1666
+ default: p(() => [
1667
+ f(w(Qt))
1668
+ ]),
1669
+ _: 1
1670
+ })) : g.status === "running" || g.status === "pending" ? (d(), E(Y, {
1671
+ key: 2,
1672
+ type: "circle",
1673
+ percentage: g.progress,
1674
+ width: 36,
1675
+ "stroke-width": 3
1676
+ }, null, 8, ["percentage"])) : (d(), E(I, {
1677
+ key: 3,
1678
+ class: "muted"
1679
+ }, {
1680
+ default: p(() => [
1681
+ f(w(Zt))
1682
+ ]),
1683
+ _: 1
1684
+ }))
1711
1685
  ]),
1712
- _("div", {
1713
- class: "yc-image-selector__meta",
1714
- title: I.name
1715
- }, V(I.name || "未命名"), 9, po)
1716
- ], 10, ro))), 128))
1717
- ]))
1718
- ])), [
1719
- [At, v.value]
1720
- ])
1721
- ]),
1722
- $.value && K.value.length ? (d(), A("div", mo, [
1723
- _("span", go, "已选 " + V(K.value.length) + " 张", 1),
1724
- _("div", vo, [
1725
- (d(!0), A(ae, null, ge(K.value, (I) => (d(), A("div", {
1726
- key: String(I.id),
1727
- class: "yc-image-selector__selected-chip",
1728
- onClick: Lt((Ie) => Ge(I), ["stop"])
1729
- }, [
1730
- _("img", {
1731
- src: ye(I),
1732
- alt: I.name
1733
- }, null, 8, ho),
1734
- s[6] || (s[6] = _("span", { class: "yc-image-selector__selected-chip-remove" }, "×", -1))
1735
- ], 8, _o))), 128))
1686
+ h("div", $o, [
1687
+ h("div", Lo, B(g.title), 1),
1688
+ h("div", Do, [
1689
+ h("span", null, B(y(g.status)), 1),
1690
+ g.runId ? (d(), M("span", Bo, " · #" + B(g.runId), 1)) : $("", !0)
1691
+ ]),
1692
+ g.summary ? (d(), M("div", Vo, B(g.summary), 1)) : $("", !0)
1693
+ ]),
1694
+ h("div", Oo, [
1695
+ g.status === "running" || g.status === "pending" ? (d(), E(U, {
1696
+ key: 0,
1697
+ link: "",
1698
+ type: "danger",
1699
+ size: "small",
1700
+ onClick: (x) => w(o).cancelTask(g.id)
1701
+ }, {
1702
+ default: p(() => [...r[6] || (r[6] = [
1703
+ W(" 取消 ", -1)
1704
+ ])]),
1705
+ _: 1
1706
+ }, 8, ["onClick"])) : $("", !0),
1707
+ g.status === "succeeded" && g.runId ? (d(), E(U, {
1708
+ key: 1,
1709
+ link: "",
1710
+ type: "primary",
1711
+ size: "small",
1712
+ loading: l.value === g.id,
1713
+ onClick: (x) => T(g)
1714
+ }, {
1715
+ default: p(() => [...r[7] || (r[7] = [
1716
+ W(" 使用 ", -1)
1717
+ ])]),
1718
+ _: 1
1719
+ }, 8, ["loading", "onClick"])) : $("", !0),
1720
+ g.status !== "running" && g.status !== "pending" ? (d(), E(U, {
1721
+ key: 2,
1722
+ link: "",
1723
+ size: "small",
1724
+ onClick: (x) => w(o).removeTask(g.id)
1725
+ }, {
1726
+ default: p(() => [...r[8] || (r[8] = [
1727
+ W(" 移除 ", -1)
1728
+ ])]),
1729
+ _: 1
1730
+ }, 8, ["onClick"])) : $("", !0)
1731
+ ])
1732
+ ]))), 128))
1733
+ ])) : (d(), E(R, {
1734
+ key: 0,
1735
+ description: "暂无 AI 任务",
1736
+ "image-size": 64
1737
+ }))
1736
1738
  ]),
1737
- f(pe, {
1738
- link: "",
1739
- type: "primary",
1740
- onClick: ke
1741
- }, {
1742
- default: p(() => [...s[7] || (s[7] = [
1743
- q("清空", -1)
1744
- ])]),
1745
- _: 1
1746
- })
1747
- ])) : P("", !0),
1748
- Y.value > 0 ? (d(), A("div", yo, [
1749
- f(xt, {
1750
- "current-page": F.value,
1751
- "onUpdate:currentPage": s[3] || (s[3] = (I) => F.value = I),
1752
- background: "",
1753
- layout: "total, prev, pager, next, jumper",
1754
- "page-size": e.pageSize,
1755
- total: Y.value,
1756
- onCurrentChange: be
1757
- }, null, 8, ["current-page", "page-size", "total"])
1758
- ])) : P("", !0)
1759
- ])
1760
- ]),
1761
- _: 1
1762
- }, 8, ["modelValue", "title", "width"]);
1739
+ w(o).tasks.some((g) => g.status !== "running" && g.status !== "pending") ? (d(), M("div", Uo, [
1740
+ f(U, {
1741
+ link: "",
1742
+ type: "info",
1743
+ onClick: r[3] || (r[3] = (g) => w(o).clearFinished())
1744
+ }, {
1745
+ default: p(() => [...r[9] || (r[9] = [
1746
+ W("清除已完成", -1)
1747
+ ])]),
1748
+ _: 1
1749
+ })
1750
+ ])) : $("", !0)
1751
+ ], 512), [
1752
+ [Le, w(o).panelVisible && !w(o).panelMinimized]
1753
+ ])
1754
+ ]),
1755
+ _: 1
1756
+ }),
1757
+ _e(h("div", {
1758
+ class: "ai-task-panel-mini",
1759
+ onClick: r[4] || (r[4] = (g) => w(o).toggleMinimize())
1760
+ }, [
1761
+ w(o).activeCount > 0 ? (d(), E(I, {
1762
+ key: 0,
1763
+ class: "spinning"
1764
+ }, {
1765
+ default: p(() => [
1766
+ f(w(Ze))
1767
+ ]),
1768
+ _: 1
1769
+ })) : $("", !0),
1770
+ h("span", null, B(w(o).panelSubtitle), 1),
1771
+ w(o).runningCount > 0 ? (d(), E(L, {
1772
+ key: 1,
1773
+ value: w(o).runningCount,
1774
+ class: "m-l-8"
1775
+ }, null, 8, ["value"])) : $("", !0)
1776
+ ], 512), [
1777
+ [Le, w(o).panelVisible && w(o).panelMinimized]
1778
+ ])
1779
+ ]);
1763
1780
  };
1764
1781
  }
1765
- }), xo = /* @__PURE__ */ Se(ko, [["__scopeId", "data-v-baf50ed2"]]);
1766
- function vt() {
1767
- const e = k(!1), n = k({});
1768
- function t(l = {}) {
1769
- n.value = { ...l }, e.value = !0;
1782
+ }), Ro = /* @__PURE__ */ xe(Fo, [["__scopeId", "data-v-812b3127"]]), Xo = /* @__PURE__ */ ce({
1783
+ __name: "AiTaskProvider",
1784
+ props: {
1785
+ title: {},
1786
+ freeText: {},
1787
+ promptId: {},
1788
+ autoMatch: { type: Boolean },
1789
+ prompts: {},
1790
+ showAutoMatch: { type: Boolean },
1791
+ showPromptSelect: { type: Boolean },
1792
+ autoMatchLabel: {},
1793
+ promptLabel: {},
1794
+ freeTextLabel: {},
1795
+ freeTextPlaceholder: {},
1796
+ submitText: {},
1797
+ showTaskListButton: { type: Boolean },
1798
+ taskListButtonText: {},
1799
+ width: {},
1800
+ modelValue: { type: Boolean },
1801
+ showDialog: { type: Boolean, default: !0 }
1802
+ },
1803
+ emits: ["finish", "use"],
1804
+ setup(e, { emit: n }) {
1805
+ const t = e, o = n, l = St();
1806
+ De(Tt, l), De(wt, ht(l));
1807
+ const m = D(() => {
1808
+ const v = {
1809
+ title: t.title,
1810
+ freeText: t.freeText,
1811
+ promptId: t.promptId,
1812
+ autoMatch: t.autoMatch,
1813
+ prompts: t.prompts,
1814
+ showAutoMatch: t.showAutoMatch,
1815
+ showPromptSelect: t.showPromptSelect,
1816
+ autoMatchLabel: t.autoMatchLabel,
1817
+ promptLabel: t.promptLabel,
1818
+ freeTextLabel: t.freeTextLabel,
1819
+ freeTextPlaceholder: t.freeTextPlaceholder,
1820
+ submitText: t.submitText,
1821
+ showTaskListButton: t.showTaskListButton,
1822
+ taskListButtonText: t.taskListButtonText,
1823
+ width: t.width
1824
+ };
1825
+ return t.modelValue !== void 0 && (v.modelValue = t.modelValue), v;
1826
+ });
1827
+ let y;
1828
+ function T(v) {
1829
+ o("use", v);
1830
+ }
1831
+ return Re(() => {
1832
+ l.hydrate(), y = l.onTaskFinish((v) => o("finish", v));
1833
+ }), Ke(() => {
1834
+ y == null || y();
1835
+ }), (v, r) => (d(), M(ie, null, [
1836
+ e.showDialog !== !1 ? (d(), E(To, Nt(st({ key: 0 }, m.value)), null, 16)) : $("", !0),
1837
+ f(Ro, { onUse: T }),
1838
+ Ce(v.$slots, "default")
1839
+ ], 64));
1770
1840
  }
1771
- function o() {
1841
+ });
1842
+ function Qo() {
1843
+ const e = Ne(wt, null);
1844
+ return e || ht(je());
1845
+ }
1846
+ function Ko() {
1847
+ const e = b(!1), n = b({});
1848
+ let t = null;
1849
+ function o(T) {
1850
+ t == null || t.resolve(T), t = null;
1851
+ }
1852
+ function l() {
1853
+ t == null || t.reject(new Se()), t = null;
1854
+ }
1855
+ function m(T = {}) {
1856
+ t && (t.reject(new Se()), t = null);
1857
+ const v = new Promise((r, I) => {
1858
+ t = { resolve: r, reject: I };
1859
+ });
1860
+ return n.value = { ...T }, e.value = !0, v;
1861
+ }
1862
+ function y() {
1772
1863
  e.value = !1;
1773
1864
  }
1774
1865
  return {
1775
1866
  dialogVisible: e,
1776
1867
  dialogOptions: n,
1777
- openImageSelector: t,
1778
- closeImageSelector: o
1868
+ openImageSelector: m,
1869
+ closeImageSelector: y,
1870
+ settlePendingConfirm: o,
1871
+ settlePendingCancel: l
1779
1872
  };
1780
1873
  }
1781
- const bo = "__YC_IMAGE_SELECTOR_CTX_KEY__";
1782
- function Ao(e) {
1874
+ const No = "__YC_IMAGE_SELECTOR_CTX_KEY__";
1875
+ function zo(e) {
1783
1876
  const n = globalThis;
1784
1877
  return n[e] || (n[e] = Symbol(e)), n[e];
1785
1878
  }
1786
- const _t = Ao(bo), Fo = /* @__PURE__ */ ue({
1879
+ const kt = zo(No), Zo = /* @__PURE__ */ ce({
1787
1880
  __name: "YcImageSelectorProvider",
1788
1881
  props: {
1789
- modelValue: { type: Boolean },
1882
+ modelValue: { type: [Boolean, null] },
1790
1883
  title: { default: "选择图片" },
1791
1884
  multiple: { type: Boolean, default: !1 },
1792
1885
  maxCount: { default: 9 },
@@ -1809,25 +1902,32 @@ const _t = Ao(bo), Fo = /* @__PURE__ */ ue({
1809
1902
  showDialog: { type: Boolean, default: !0 }
1810
1903
  },
1811
1904
  setup(e, { expose: n }) {
1812
- const t = e, o = vt(), { dialogVisible: l, dialogOptions: g, openImageSelector: w, closeImageSelector: S } = o;
1813
- $e(_t, o);
1814
- function m(E, D) {
1815
- return E in g.value ? g.value[E] : D;
1905
+ const t = e, o = Ko(), {
1906
+ dialogVisible: l,
1907
+ dialogOptions: m,
1908
+ openImageSelector: y,
1909
+ closeImageSelector: T,
1910
+ settlePendingConfirm: v,
1911
+ settlePendingCancel: r
1912
+ } = o;
1913
+ De(kt, o);
1914
+ function I(L, g) {
1915
+ return L in m.value ? m.value[L] : g;
1816
1916
  }
1817
- const r = B(() => ({
1818
- title: m("title", t.title),
1819
- multiple: m("multiple", t.multiple),
1820
- maxCount: m("maxCount", t.maxCount),
1821
- selected: m("selected", t.selected),
1917
+ const U = D(() => ({
1918
+ title: I("title", t.title),
1919
+ multiple: I("multiple", t.multiple),
1920
+ maxCount: I("maxCount", t.maxCount),
1921
+ selected: I("selected", t.selected),
1822
1922
  width: t.width,
1823
1923
  pageSize: t.pageSize,
1824
1924
  showUpload: t.showUpload,
1825
1925
  accept: t.accept,
1826
- showCategories: m("showCategories", t.showCategories),
1827
- categories: m("categories", t.categories),
1828
- categoryAllLabel: m("categoryAllLabel", t.categoryAllLabel),
1829
- showModeSwitch: m("showModeSwitch", t.showModeSwitch),
1830
- confirmOnSelect: m("confirmOnSelect", t.confirmOnSelect),
1926
+ showCategories: I("showCategories", t.showCategories),
1927
+ categories: I("categories", t.categories),
1928
+ categoryAllLabel: I("categoryAllLabel", t.categoryAllLabel),
1929
+ showModeSwitch: I("showModeSwitch", t.showModeSwitch),
1930
+ confirmOnSelect: I("confirmOnSelect", t.confirmOnSelect),
1831
1931
  confirmText: t.confirmText,
1832
1932
  cancelText: t.cancelText,
1833
1933
  emptyText: t.emptyText,
@@ -1835,103 +1935,72 @@ const _t = Ao(bo), Fo = /* @__PURE__ */ ue({
1835
1935
  upload: t.upload,
1836
1936
  urlField: t.urlField
1837
1937
  }));
1838
- function L(E) {
1839
- var D, N;
1840
- (N = (D = g.value).onConfirm) == null || N.call(D, E), S();
1938
+ function R(L) {
1939
+ var g, x;
1940
+ (x = (g = m.value).onConfirm) == null || x.call(g, L), v(L), T();
1841
1941
  }
1842
- function U() {
1843
- var E, D;
1844
- (D = (E = g.value).onCancel) == null || D.call(E), S();
1942
+ function Y() {
1943
+ var L, g;
1944
+ (g = (L = m.value).onCancel) == null || g.call(L), r(), T();
1845
1945
  }
1846
- return n({ openImageSelector: w, closeImageSelector: S }), (E, D) => (d(), A(ae, null, [
1847
- e.showDialog !== !1 ? (d(), M(xo, ot({
1946
+ return n({ openImageSelector: y, closeImageSelector: T }), (L, g) => (d(), M(ie, null, [
1947
+ e.showDialog !== !1 ? (d(), E(gt, st({
1848
1948
  key: 0,
1849
- modelValue: h(l),
1850
- "onUpdate:modelValue": D[0] || (D[0] = (N) => Dt(l) ? l.value = N : null)
1851
- }, r.value, {
1852
- onConfirm: L,
1853
- onCancel: U
1854
- }), null, 16, ["modelValue"])) : P("", !0),
1855
- Ce(E.$slots, "default")
1949
+ modelValue: w(l),
1950
+ "onUpdate:modelValue": g[0] || (g[0] = (x) => zt(l) ? l.value = x : null)
1951
+ }, U.value, {
1952
+ onConfirm: R,
1953
+ onCancel: Y
1954
+ }), null, 16, ["modelValue"])) : $("", !0),
1955
+ Ce(L.$slots, "default")
1856
1956
  ], 64));
1857
1957
  }
1858
1958
  });
1859
- function Uo() {
1860
- const e = Oe(_t, null);
1861
- if (e)
1862
- return {
1863
- openImageSelector: (t = {}) => e.openImageSelector(t),
1864
- closeImageSelector: () => e.closeImageSelector()
1865
- };
1866
- const n = vt();
1867
- return {
1868
- openImageSelector: (t = {}) => {
1869
- Zn(t), n.openImageSelector(t);
1870
- },
1871
- closeImageSelector: () => n.closeImageSelector()
1959
+ function el() {
1960
+ const e = Ne(kt, null);
1961
+ return e ? {
1962
+ openImageSelector: (n = {}) => e.openImageSelector(n),
1963
+ closeImageSelector: () => e.closeImageSelector()
1964
+ } : {
1965
+ openImageSelector: mt,
1966
+ closeImageSelector: pt
1872
1967
  };
1873
1968
  }
1874
- function ht() {
1875
- const { baseURL: e = "" } = Ke();
1876
- return Ze.create({ baseURL: e, timeout: 3e4 });
1877
- }
1878
- async function Ro(e) {
1879
- const n = Ke().fetchImages;
1880
- if (n) return n(e);
1881
- const t = ht(), { data: o } = await t.get(
1882
- "/yc-media/images",
1883
- { params: e }
1884
- );
1885
- if (o.code !== 200)
1886
- throw new Error("加载图片资源失败");
1887
- return o.data;
1888
- }
1889
- async function Ko(e) {
1890
- const n = Ke().uploadImage;
1891
- if (n) return n(e);
1892
- const t = ht(), o = new FormData();
1893
- o.append("file", e);
1894
- const { data: l } = await t.post(
1895
- "/yc-media/images/upload",
1896
- o,
1897
- { headers: { "Content-Type": "multipart/form-data" } }
1898
- );
1899
- if (l.code !== 200)
1900
- throw new Error("上传图片失败");
1901
- return l.data;
1902
- }
1903
1969
  export {
1904
- Hn as AiTaskPanel,
1905
- Vo as AiTaskProvider,
1906
- En as AiUseDialog,
1907
- _t as IMAGE_SELECTOR_INJECT_KEY,
1908
- xo as ImageSelectorDialog,
1909
- Fo as ImageSelectorProvider,
1910
- Qe as SkyPageWindow,
1911
- Hn as YcAiTaskPanel,
1912
- Vo as YcAiTaskProvider,
1913
- En as YcAiUseDialog,
1914
- Do as YcComponent,
1915
- xo as YcImageSelectorDialog,
1916
- Fo as YcImageSelectorProvider,
1917
- Qe as YcPageWindow,
1918
- vt as createImageSelectorApi,
1919
- Do as default,
1920
- Ro as fetchImages,
1921
- it as getAiTaskConfig,
1922
- Ke as getImageSelectorConfig,
1923
- rt as hideAiDialog,
1924
- Qn as hideImageSelectorDialog,
1925
- an as installYcComponent,
1926
- xn as listPrompts,
1927
- Bo as openAiUseDialog,
1928
- Zn as openImageSelector,
1929
- Gt as setAiTaskConfig,
1930
- Xt as setImageSelectorConfig,
1931
- Ne as showAiDialog,
1932
- Xn as showImageSelectorDialog,
1933
- Ko as uploadImage,
1934
- Oo as useAiTask,
1935
- gt as useAiTaskStore,
1936
- Uo as useImageSelector
1970
+ Ro as AiTaskPanel,
1971
+ Xo as AiTaskProvider,
1972
+ To as AiUseDialog,
1973
+ kt as IMAGE_SELECTOR_INJECT_KEY,
1974
+ Se as ImageSelectorCancelledError,
1975
+ gt as ImageSelectorDialog,
1976
+ Zo as ImageSelectorProvider,
1977
+ nt as SkyPageWindow,
1978
+ Ro as YcAiTaskPanel,
1979
+ Xo as YcAiTaskProvider,
1980
+ To as YcAiUseDialog,
1981
+ Ho as YcComponent,
1982
+ gt as YcImageSelectorDialog,
1983
+ Zo as YcImageSelectorProvider,
1984
+ nt as YcPageWindow,
1985
+ pt as closeImageSelector,
1986
+ Ko as createImageSelectorApi,
1987
+ Ho as default,
1988
+ On as fetchImages,
1989
+ ct as getAiTaskConfig,
1990
+ ke as getImageSelectorConfig,
1991
+ _t as hideAiDialog,
1992
+ ft as hideImageSelectorDialog,
1993
+ Kn as installImageSelector,
1994
+ qn as installYcComponent,
1995
+ _o as listPrompts,
1996
+ Jo as openAiUseDialog,
1997
+ mt as openImageSelector,
1998
+ nn as setAiTaskConfig,
1999
+ sn as setImageSelectorConfig,
2000
+ Ye as showAiDialog,
2001
+ dn as showImageSelectorDialog,
2002
+ Un as uploadImage,
2003
+ Qo as useAiTask,
2004
+ St as useAiTaskStore,
2005
+ el as useImageSelector
1937
2006
  };