yc-component 0.1.11 → 0.1.13

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