yc-component 0.1.8 → 0.1.10

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 (66) hide show
  1. package/dist/ai-task/style.css +1 -3
  2. package/dist/image-selector/api/images.d.ts +6 -0
  3. package/dist/image-selector/api/images.d.ts.map +1 -0
  4. package/dist/image-selector/components/YcImageSelectorDialog.d.ts +28 -0
  5. package/dist/image-selector/components/YcImageSelectorDialog.d.ts.map +1 -0
  6. package/dist/image-selector/components/YcImageSelectorProvider.d.ts +42 -0
  7. package/dist/image-selector/components/YcImageSelectorProvider.d.ts.map +1 -0
  8. package/dist/image-selector/composables/useImageSelector.d.ts +10 -0
  9. package/dist/image-selector/composables/useImageSelector.d.ts.map +1 -0
  10. package/dist/image-selector/config.d.ts +12 -0
  11. package/dist/image-selector/config.d.ts.map +1 -0
  12. package/dist/image-selector/context.d.ts +60 -0
  13. package/dist/image-selector/context.d.ts.map +1 -0
  14. package/dist/image-selector/dialog-state.d.ts +39 -0
  15. package/dist/image-selector/dialog-state.d.ts.map +1 -0
  16. package/dist/image-selector/index.d.ts +15 -0
  17. package/dist/image-selector/index.d.ts.map +1 -0
  18. package/dist/image-selector/inject.d.ts +59 -0
  19. package/dist/image-selector/inject.d.ts.map +1 -0
  20. package/dist/image-selector/style.css +1 -0
  21. package/dist/image-selector/types/index.d.ts +84 -0
  22. package/dist/image-selector/types/index.d.ts.map +1 -0
  23. package/dist/index.css +1 -0
  24. package/dist/index.d.ts +2 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/page-window/style.css +1 -1
  27. package/dist/plugin.d.ts +2 -0
  28. package/dist/plugin.d.ts.map +1 -1
  29. package/dist/yc-component.cjs.full.js +50 -0
  30. package/dist/yc-component.cjs.js +5 -0
  31. package/dist/yc-component.esm.full.js +12216 -0
  32. package/dist/yc-component.esm.js +1931 -0
  33. package/dist/yc-component.umd.full.js +112 -0
  34. package/dist/yc-component.umd.full.min.js +1 -0
  35. package/dist/yc-component.umd.js +6 -0
  36. package/dist/yc-component.umd.min.js +1 -0
  37. package/package.json +32 -6
  38. package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
  39. package/dist/ai-task/api/http.js +0 -47
  40. package/dist/ai-task/api/prompt.js +0 -9
  41. package/dist/ai-task/api/workflow.js +0 -15
  42. package/dist/ai-task/components/AiTaskPanel.css +0 -1
  43. package/dist/ai-task/components/AiTaskPanel.vue.js +0 -7
  44. package/dist/ai-task/components/AiTaskPanel.vue2.js +0 -248
  45. package/dist/ai-task/components/AiTaskProvider.vue.js +0 -69
  46. package/dist/ai-task/components/AiTaskProvider.vue2.js +0 -4
  47. package/dist/ai-task/components/AiUseDialog.css +0 -1
  48. package/dist/ai-task/components/AiUseDialog.vue.js +0 -7
  49. package/dist/ai-task/components/AiUseDialog.vue2.js +0 -248
  50. package/dist/ai-task/composables/useAiTask.js +0 -11
  51. package/dist/ai-task/config.js +0 -23
  52. package/dist/ai-task/context.js +0 -42
  53. package/dist/ai-task/dialog-state.js +0 -28
  54. package/dist/ai-task/index.js +0 -24
  55. package/dist/ai-task/inject.js +0 -10
  56. package/dist/ai-task/services/taskRunner.js +0 -60
  57. package/dist/ai-task/store/useAiTaskStore.js +0 -230
  58. package/dist/ai-task/useScopedStore.js +0 -10
  59. package/dist/ai-task/utils/runClientScript.js +0 -26
  60. package/dist/ai-task/utils/storage.js +0 -45
  61. package/dist/index.js +0 -31
  62. package/dist/page-window/YcPageWindow.css +0 -1
  63. package/dist/page-window/YcPageWindow.vue.js +0 -7
  64. package/dist/page-window/YcPageWindow.vue2.js +0 -230
  65. package/dist/page-window/index.js +0 -5
  66. package/dist/plugin.js +0 -19
@@ -1,24 +0,0 @@
1
- import { default as a, default as i } from "./components/AiTaskProvider.vue.js";
2
- import { default as r, default as t } from "./components/AiUseDialog.vue.js";
3
- import { default as l, default as A } from "./components/AiTaskPanel.vue.js";
4
- import { useAiTask as d } from "./composables/useAiTask.js";
5
- import { hideAiDialog as g, openAiUseDialog as k, showAiDialog as u } from "./dialog-state.js";
6
- import { listPrompts as T } from "./api/prompt.js";
7
- import { useAiTaskStore as D } from "./store/useAiTaskStore.js";
8
- import { getAiTaskConfig as c, setAiTaskConfig as U } from "./config.js";
9
- export {
10
- l as AiTaskPanel,
11
- a as AiTaskProvider,
12
- r as AiUseDialog,
13
- A as YcAiTaskPanel,
14
- i as YcAiTaskProvider,
15
- t as YcAiUseDialog,
16
- c as getAiTaskConfig,
17
- g as hideAiDialog,
18
- T as listPrompts,
19
- k as openAiUseDialog,
20
- U as setAiTaskConfig,
21
- u as showAiDialog,
22
- d as useAiTask,
23
- D as useAiTaskStore
24
- };
@@ -1,10 +0,0 @@
1
- const o = "__YC_AI_TASK_CTX_KEY__", t = "__YC_AI_TASK_STORE_KEY__";
2
- function T(_) {
3
- const K = globalThis;
4
- return K[_] || (K[_] = Symbol(_)), K[_];
5
- }
6
- const E = T(o), A = T(t);
7
- export {
8
- E as AI_TASK_INJECT_KEY,
9
- A as AI_TASK_STORE_KEY
10
- };
@@ -1,60 +0,0 @@
1
- import { getProjectId as g } from "../config.js";
2
- import { cancelWorkflowRun as w, getWorkflowRun as p, getWorkflowArtifact as o, continueClientScript as C, startWorkflowRun as D } from "../api/workflow.js";
3
- import { runClientScript as S } from "../utils/runClientScript.js";
4
- async function N(r) {
5
- return (await D({
6
- projectId: g(),
7
- freeText: r.freeText,
8
- promptId: r.promptId,
9
- autoMatch: r.autoMatch
10
- })).runId;
11
- }
12
- async function P(r, t) {
13
- var e, u, f, s;
14
- const n = await p(r);
15
- if (n.status === "WAITING_CLIENT" && n.waitingStepKey && n.waitingClientScript) {
16
- (e = t == null ? void 0 : t.onProgress) == null || e.call(t, 60, `执行脚本:${n.waitingStepKey}`);
17
- let i = {};
18
- n.waitingArtifactId && (i = await o(r, n.waitingArtifactId));
19
- const E = S(n.waitingClientScript, i);
20
- return await C(r, {
21
- stepKey: n.waitingStepKey,
22
- output: E ?? {}
23
- }), null;
24
- }
25
- if (n.status === "SUCCEEDED") {
26
- if (n.finalArtifactId) {
27
- (u = t == null ? void 0 : t.onProgress) == null || u.call(t, 95, "加载结果…");
28
- const i = await o(r, n.finalArtifactId);
29
- return (f = t == null ? void 0 : t.onProgress) == null || f.call(t, 100, "已完成"), { phase: "SUCCEEDED", runId: r, result: i };
30
- }
31
- return { phase: "SUCCEEDED", runId: r, result: {} };
32
- }
33
- return n.status === "FAILED" ? { phase: "FAILED", runId: r, errorMessage: n.errorMessage || "工作流失败" } : n.status === "CANCELLED" ? { phase: "FAILED", runId: r, errorMessage: "已取消" } : ((s = t == null ? void 0 : t.onProgress) == null || s.call(t, A(n), I(n)), null);
34
- }
35
- async function R(r) {
36
- const t = await p(r);
37
- return t.status !== "SUCCEEDED" || !t.finalArtifactId ? null : await o(r, t.finalArtifactId);
38
- }
39
- async function M(r) {
40
- await w(r);
41
- }
42
- function A(r) {
43
- if (r.status === "PENDING") return 8;
44
- const t = r.steps ?? [];
45
- if (!t.length) return 35;
46
- const n = t.filter((e) => e.status === "SUCCEEDED" || e.status === "SKIPPED").length;
47
- return Math.min(90, Math.round(20 + n / t.length * 70));
48
- }
49
- function I(r) {
50
- var n;
51
- if (r.status === "PENDING") return "排队中…";
52
- const t = (n = r.steps) == null ? void 0 : n.find((e) => e.status === "RUNNING");
53
- return t ? `执行中:${t.stepKey}` : "后端处理中…";
54
- }
55
- export {
56
- M as cancelRunOnServer,
57
- R as fetchRunResult,
58
- N as startAiWorkflowRun,
59
- P as syncWorkflowRunStatus
60
- };
@@ -1,230 +0,0 @@
1
- import { defineStore as H } from "pinia";
2
- import { ref as l, computed as g } from "vue";
3
- import { cancelRunOnServer as J, fetchRunResult as K, syncWorkflowRunStatus as Q, startAiWorkflowRun as X } from "../services/taskRunner.js";
4
- import { hideAiDialog as Y, showAiDialog as Z } from "../dialog-state.js";
5
- import { isActiveStatus as u, loadPersistedTasks as ee, toAiTaskItem as te, savePersistedTasks as ne } from "../utils/storage.js";
6
- let M = 0, c = null;
7
- const se = 5e3;
8
- function re() {
9
- return M += 1, `ai_task_${Date.now()}_${M}`;
10
- }
11
- function ie(s, o = 28) {
12
- const i = s.trim();
13
- return i.length <= o ? i : `${i.slice(0, o)}…`;
14
- }
15
- const ce = H("ycAiTask", () => {
16
- const s = l([]), o = l(!1), i = l(!1), h = l(!1), P = l({}), p = l(!1), y = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Set();
17
- function b(e, n) {
18
- return {
19
- taskId: e.id,
20
- runId: e.runId,
21
- title: e.title,
22
- freeText: e.freeText,
23
- promptId: e.promptId,
24
- result: n,
25
- finishedAt: e.finishedAt ?? Date.now()
26
- };
27
- }
28
- function E(e, n) {
29
- var m;
30
- const t = s.value.find((D) => D.id === e);
31
- if (!(t != null && t.runId)) return;
32
- const r = b(t, n);
33
- (m = f.get(e)) == null || m(r), f.delete(e), I.forEach((D) => D(r));
34
- }
35
- function L(e) {
36
- return I.add(e), () => I.delete(e);
37
- }
38
- const d = g(
39
- () => s.value.filter((e) => u(e.status)).length
40
- ), R = g(() => s.value.filter((e) => e.status === "running").length), C = g(() => d.value > 0 ? "AI 处理中" : s.value.some((e) => e.status === "failed") ? "部分任务失败" : "AI 任务"), _ = g(() => {
41
- const e = s.value.length, n = d.value;
42
- return e === 0 ? "暂无任务" : n > 0 ? `${n}/${e} 项任务进行中` : `${e} 项任务已完成`;
43
- });
44
- function v() {
45
- ne(s.value);
46
- }
47
- function a(e, n) {
48
- const t = s.value.findIndex((r) => r.id === e);
49
- t >= 0 && (s.value[t] = { ...s.value[t], ...n }, v());
50
- }
51
- function S(e, n) {
52
- const t = s.value.find((r) => r.id === e);
53
- t && (t.logs.unshift(n), t.logs.length > 20 && t.logs.pop());
54
- }
55
- function x() {
56
- o.value = !0, i.value = !1;
57
- }
58
- function k() {
59
- o.value = !1;
60
- }
61
- function O() {
62
- i.value = !i.value;
63
- }
64
- function V(e = {}) {
65
- P.value = { ...e }, h.value = !0, Z(e);
66
- }
67
- function q() {
68
- h.value = !1, Y();
69
- }
70
- function F() {
71
- c || (c = setInterval(() => {
72
- $();
73
- }, se));
74
- }
75
- function T() {
76
- d.value > 0 || c && (clearInterval(c), c = null);
77
- }
78
- async function $() {
79
- const e = s.value.filter((n) => n.runId && u(n.status));
80
- if (!e.length) {
81
- T();
82
- return;
83
- }
84
- await Promise.all(e.map((n) => w(n.id)));
85
- }
86
- async function w(e) {
87
- if (y.has(e)) return;
88
- const n = s.value.find((t) => t.id === e);
89
- if (!(!(n != null && n.runId) || !u(n.status))) {
90
- y.add(e);
91
- try {
92
- const t = await Q(n.runId, {
93
- onProgress: (r, m) => a(e, { progress: r, summary: m, status: "running" })
94
- });
95
- if (!t) return;
96
- if (t.phase === "SUCCEEDED") {
97
- const r = t.result ?? {};
98
- a(e, {
99
- status: "succeeded",
100
- progress: 100,
101
- summary: "已完成",
102
- result: r,
103
- runId: t.runId,
104
- finishedAt: Date.now()
105
- }), E(e, r);
106
- } else
107
- a(e, {
108
- status: t.errorMessage === "已取消" ? "cancelled" : "failed",
109
- progress: 100,
110
- summary: t.errorMessage || "失败",
111
- errorMessage: t.errorMessage,
112
- runId: t.runId,
113
- finishedAt: Date.now()
114
- });
115
- T();
116
- } catch (t) {
117
- const r = t instanceof Error ? t.message : "同步失败";
118
- S(e, `✗ ${r}`);
119
- } finally {
120
- y.delete(e);
121
- }
122
- }
123
- }
124
- async function z() {
125
- if (p.value) return;
126
- p.value = !0;
127
- const e = ee();
128
- e.length && (s.value = e.map(te), M = e.length);
129
- const n = s.value.filter((t) => t.runId && u(t.status));
130
- n.length && (await Promise.all(n.map((t) => w(t.id))), F());
131
- for (const t of s.value)
132
- t.status === "pending" && !t.runId && a(t.id, { status: "failed", summary: "页面刷新前未提交成功", finishedAt: Date.now() });
133
- }
134
- function B(e) {
135
- const n = re(), t = {
136
- id: n,
137
- title: e.title ?? ie(e.freeText),
138
- freeText: e.freeText.trim(),
139
- promptId: e.promptId,
140
- autoMatch: e.autoMatch,
141
- status: "pending",
142
- progress: 0,
143
- summary: "正在提交…",
144
- createdAt: Date.now(),
145
- logs: []
146
- };
147
- return s.value.unshift(t), v(), e.onFinish && f.set(n, e.onFinish), e.showPanel !== !1 && x(), W(n), n;
148
- }
149
- async function W(e) {
150
- const n = s.value.find((t) => t.id === e);
151
- if (n)
152
- try {
153
- const t = await X({
154
- freeText: n.freeText,
155
- promptId: n.promptId,
156
- autoMatch: n.autoMatch
157
- });
158
- a(e, {
159
- runId: t,
160
- status: "running",
161
- progress: 10,
162
- summary: "后端异步处理中…"
163
- }), S(e, `▶ 已提交 runId=${t}`), F(), w(e);
164
- } catch (t) {
165
- const r = t instanceof Error ? t.message : "提交失败";
166
- a(e, {
167
- status: "failed",
168
- progress: 100,
169
- summary: r,
170
- errorMessage: r,
171
- finishedAt: Date.now()
172
- });
173
- }
174
- }
175
- async function N(e) {
176
- const n = s.value.find((r) => r.id === e);
177
- if (!(n != null && n.runId)) return null;
178
- if (n.result) return n.result;
179
- const t = await K(n.runId);
180
- return t && a(e, { result: t }), t;
181
- }
182
- async function A(e) {
183
- const n = s.value.find((t) => t.id === e);
184
- if (n != null && n.runId && u(n.status))
185
- try {
186
- await J(n.runId);
187
- } catch {
188
- }
189
- n && u(n.status) && a(e, { status: "cancelled", summary: "已取消", finishedAt: Date.now() }), f.delete(e), T();
190
- }
191
- function U() {
192
- for (const e of s.value)
193
- u(e.status) && A(e.id);
194
- }
195
- function j() {
196
- s.value = s.value.filter((e) => u(e.status)), v();
197
- }
198
- function G(e) {
199
- A(e), f.delete(e), s.value = s.value.filter((n) => n.id !== e), v();
200
- }
201
- return {
202
- tasks: s,
203
- panelVisible: o,
204
- panelMinimized: i,
205
- dialogVisible: h,
206
- dialogOptions: P,
207
- hydrated: p,
208
- runningCount: d,
209
- activeCount: R,
210
- panelTitle: C,
211
- panelSubtitle: _,
212
- hydrate: z,
213
- showPanel: x,
214
- hidePanel: k,
215
- toggleMinimize: O,
216
- openDialog: V,
217
- closeDialog: q,
218
- enqueue: B,
219
- onTaskFinish: L,
220
- refreshActiveTasks: $,
221
- loadTaskResult: N,
222
- cancelTask: A,
223
- cancelAll: U,
224
- clearFinished: j,
225
- removeTask: G
226
- };
227
- });
228
- export {
229
- ce as useAiTaskStore
230
- };
@@ -1,10 +0,0 @@
1
- import { inject as o } from "vue";
2
- import { AI_TASK_STORE_KEY as t } from "./inject.js";
3
- import { useAiTaskStore as e } from "./store/useAiTaskStore.js";
4
- function u() {
5
- const r = o(t, null);
6
- return r || e();
7
- }
8
- export {
9
- u as useScopedAiTaskStore
10
- };
@@ -1,26 +0,0 @@
1
- function i(o, t) {
2
- const n = o.trim();
3
- if (!n)
4
- return t;
5
- let e;
6
- try {
7
- n.includes("function") ? e = new Function(
8
- "result",
9
- `
10
- ${n}
11
- if (typeof handler === 'function') return handler(result);
12
- throw new Error('请定义 function handler(result) { ... }');
13
- `
14
- ) : e = new Function("result", `return (${n})(result);`);
15
- } catch (r) {
16
- throw new Error(`自定义脚本语法错误: ${r instanceof Error ? r.message : String(r)}`);
17
- }
18
- try {
19
- return e(t);
20
- } catch (r) {
21
- throw new Error(`自定义脚本执行失败: ${r instanceof Error ? r.message : String(r)}`);
22
- }
23
- }
24
- export {
25
- i as runClientScript
26
- };
@@ -1,45 +0,0 @@
1
- import { getStorageKey as s } from "../config.js";
2
- const a = 80;
3
- function o() {
4
- try {
5
- const e = localStorage.getItem(s());
6
- if (!e) return [];
7
- const t = JSON.parse(e);
8
- return Array.isArray(t) ? t.filter((r) => r && r.id && r.createdAt).sort((r, i) => i.createdAt - r.createdAt).slice(0, a) : [];
9
- } catch {
10
- return [];
11
- }
12
- }
13
- function d(e) {
14
- const t = e.slice(0, a).map((r) => ({
15
- id: r.id,
16
- title: r.title,
17
- freeText: r.freeText,
18
- promptId: r.promptId,
19
- autoMatch: r.autoMatch,
20
- status: r.status,
21
- progress: r.progress,
22
- summary: r.summary,
23
- runId: r.runId,
24
- errorMessage: r.errorMessage,
25
- createdAt: r.createdAt,
26
- finishedAt: r.finishedAt
27
- }));
28
- localStorage.setItem(s(), JSON.stringify(t));
29
- }
30
- function u(e) {
31
- return {
32
- ...e,
33
- logs: e.runId ? [`ℹ 已从本地恢复,runId=${e.runId}`] : [],
34
- result: void 0
35
- };
36
- }
37
- function c(e) {
38
- return e === "pending" || e === "running";
39
- }
40
- export {
41
- c as isActiveStatus,
42
- o as loadPersistedTasks,
43
- d as savePersistedTasks,
44
- u as toAiTaskItem
45
- };
package/dist/index.js DELETED
@@ -1,31 +0,0 @@
1
- import { YcComponent as a, YcComponent as t, installYcComponent as i } from "./plugin.js";
2
- import { default as r, default as f } from "./ai-task/components/AiTaskProvider.vue.js";
3
- import { default as p, default as d } from "./ai-task/components/AiUseDialog.vue.js";
4
- import { default as n, default as A } from "./ai-task/components/AiTaskPanel.vue.js";
5
- import { useAiTask as g } from "./ai-task/composables/useAiTask.js";
6
- import { hideAiDialog as k, openAiUseDialog as T, showAiDialog as c } from "./ai-task/dialog-state.js";
7
- import { listPrompts as Y } from "./ai-task/api/prompt.js";
8
- import { useAiTaskStore as D } from "./ai-task/store/useAiTaskStore.js";
9
- import { getAiTaskConfig as U, setAiTaskConfig as h } from "./ai-task/config.js";
10
- import { default as S, default as W } from "./page-window/YcPageWindow.vue.js";
11
- export {
12
- n as AiTaskPanel,
13
- r as AiTaskProvider,
14
- p as AiUseDialog,
15
- S as SkyPageWindow,
16
- A as YcAiTaskPanel,
17
- f as YcAiTaskProvider,
18
- d as YcAiUseDialog,
19
- a as YcComponent,
20
- W as YcPageWindow,
21
- t as default,
22
- U as getAiTaskConfig,
23
- k as hideAiDialog,
24
- i as installYcComponent,
25
- Y as listPrompts,
26
- T as openAiUseDialog,
27
- h as setAiTaskConfig,
28
- c as showAiDialog,
29
- g as useAiTask,
30
- D as useAiTaskStore
31
- };
@@ -1 +0,0 @@
1
- .yc-page-window[data-v-b3e784c3]{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;overflow:hidden;background:var(--el-bg-color);box-shadow:0 0 10px #00000014;border-radius:5px}.yc-page-window__header[data-v-b3e784c3]{height:60px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--el-border-color-lighter);padding:0 16px;flex-shrink:0}.yc-page-window__title[data-v-b3e784c3]{font-size:18px;font-weight:700;display:flex;align-items:center;gap:4px;min-width:0}.yc-page-window__back[data-v-b3e784c3]{cursor:pointer;margin-right:12px;font-size:20px;flex-shrink:0}.yc-page-window__back[data-v-b3e784c3]:hover{color:var(--el-color-primary)}.yc-page-window__nav[data-v-b3e784c3]{margin-left:16px;display:flex;align-items:center;gap:4px}.yc-page-window__type-switch[data-v-b3e784c3]{margin-left:16px}.yc-page-window__opera[data-v-b3e784c3]{display:flex;align-items:center;gap:8px;flex-shrink:0}.yc-page-window__content[data-v-b3e784c3]{flex:1;overflow:hidden}.yc-page-window__scroll[data-v-b3e784c3]{height:100%}.yc-page-window__body[data-v-b3e784c3]{padding:16px;box-sizing:border-box}.m-r-4[data-v-b3e784c3]{margin-right:4px}.yc-page-window-fade-enter-active[data-v-b3e784c3],.yc-page-window-fade-leave-active[data-v-b3e784c3]{transition:all .2s ease}.yc-page-window-fade-enter-from[data-v-b3e784c3]{opacity:0;transform:translate(12px)}.yc-page-window-fade-leave-to[data-v-b3e784c3]{opacity:0;transform:translate(-12px)}
@@ -1,7 +0,0 @@
1
- import o from "./YcPageWindow.vue2.js";
2
- /* empty css */
3
- import t from "../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-b3e784c3"]]);
5
- export {
6
- m as default
7
- };
@@ -1,230 +0,0 @@
1
- import { defineComponent as M, ref as P, computed as f, watch as U, onBeforeUnmount as $, resolveComponent as v, resolveDirective as F, openBlock as c, createBlock as x, Transition as Y, withCtx as o, withDirectives as C, createElementVNode as w, normalizeStyle as T, createVNode as n, unref as s, toDisplayString as p, createElementBlock as m, createCommentVNode as y, createTextVNode as b, renderSlot as S, Fragment as j, vShow as q } from "vue";
2
- import { ArrowLeft as G, ArrowUpBold as J, ArrowDownBold as O, Switch as Q, Close as X, Check as Z } from "@element-plus/icons-vue";
3
- const ee = { class: "yc-page-window__header" }, te = { class: "yc-page-window__title" }, ne = {
4
- key: 0,
5
- class: "yc-page-window__nav"
6
- }, oe = { class: "yc-page-window__opera" }, le = { class: "yc-page-window__content" }, de = /* @__PURE__ */ M({
7
- __name: "YcPageWindow",
8
- props: {
9
- visible: { type: Boolean },
10
- title: { default: "" },
11
- type: { default: "" },
12
- showButtons: { type: Boolean, default: !0 },
13
- showConfirm: { type: Boolean, default: !0 },
14
- contentMinHeight: { default: "calc(100vh - 175px)" },
15
- cancelText: { default: "取消" },
16
- confirmText: { default: "保存" },
17
- disabled: { type: Boolean, default: !1 },
18
- loading: { type: Boolean, default: !1 },
19
- zIndex: { default: 9 },
20
- list: { default: () => [] },
21
- row: { default: null },
22
- rowKey: { default: "id" }
23
- },
24
- emits: ["update:visible", "update:type", "confirm", "close", "opened", "changeType", "prev", "next", "checkRow"],
25
- setup(l, { expose: N, emit: D }) {
26
- const t = l, a = D, _ = P(!1), g = f(() => t.loading || _.value), I = f(() => t.type === "detail" ? "详情" : t.type === "edit" ? "编辑" : t.type === "add" ? "新增" : ""), V = f(
27
- () => t.list.length > 0 && t.row != null
28
- ), z = f(
29
- () => ["detail", "edit"].includes(t.type)
30
- ), A = f(() => t.type !== "detail");
31
- function h() {
32
- if (!t.row) return -1;
33
- const e = t.rowKey, i = t.row[e];
34
- return t.list.findIndex((d) => d[e] === i);
35
- }
36
- function k(e) {
37
- const i = h();
38
- return i < 0 ? !0 : e === "prev" ? i <= 0 : i >= t.list.length - 1;
39
- }
40
- function H() {
41
- const e = h();
42
- if (e <= 0) return;
43
- const i = t.list[e - 1];
44
- a("checkRow", i), a("prev", i);
45
- }
46
- function L() {
47
- const e = h();
48
- if (e < 0 || e >= t.list.length - 1) return;
49
- const i = t.list[e + 1];
50
- a("checkRow", i), a("next", i);
51
- }
52
- function R() {
53
- const e = t.type === "detail" ? "edit" : "detail";
54
- a("update:type", e), a("changeType");
55
- }
56
- function r() {
57
- a("update:visible", !1), a("close");
58
- }
59
- function W() {
60
- _.value = !0, a("confirm", (e) => {
61
- _.value = !1, e && r();
62
- });
63
- }
64
- return U(
65
- () => t.visible,
66
- (e) => {
67
- e && a("opened");
68
- }
69
- ), $(() => {
70
- t.visible && r();
71
- }), N({ closeWindow: r }), (e, i) => {
72
- const d = v("el-icon"), u = v("el-button"), B = v("el-tooltip"), E = v("el-scrollbar"), K = F("loading");
73
- return c(), x(Y, {
74
- name: "yc-page-window-fade",
75
- mode: "out-in"
76
- }, {
77
- default: o(() => [
78
- C(w("div", {
79
- class: "yc-page-window",
80
- style: T({ zIndex: l.zIndex })
81
- }, [
82
- w("div", ee, [
83
- w("div", te, [
84
- n(d, {
85
- class: "yc-page-window__back",
86
- onClick: r
87
- }, {
88
- default: o(() => [
89
- n(s(G))
90
- ]),
91
- _: 1
92
- }),
93
- w("span", null, p(l.title) + p(I.value), 1),
94
- V.value ? (c(), m("div", ne, [
95
- n(B, {
96
- content: "上一条",
97
- placement: "top"
98
- }, {
99
- default: o(() => [
100
- n(u, {
101
- round: "",
102
- text: "",
103
- disabled: k("prev"),
104
- onClick: H
105
- }, {
106
- default: o(() => [
107
- n(d, null, {
108
- default: o(() => [
109
- n(s(J))
110
- ]),
111
- _: 1
112
- })
113
- ]),
114
- _: 1
115
- }, 8, ["disabled"])
116
- ]),
117
- _: 1
118
- }),
119
- n(B, {
120
- content: "下一条",
121
- placement: "top"
122
- }, {
123
- default: o(() => [
124
- n(u, {
125
- round: "",
126
- text: "",
127
- disabled: k("next"),
128
- onClick: L
129
- }, {
130
- default: o(() => [
131
- n(d, null, {
132
- default: o(() => [
133
- n(s(O))
134
- ]),
135
- _: 1
136
- })
137
- ]),
138
- _: 1
139
- }, 8, ["disabled"])
140
- ]),
141
- _: 1
142
- })
143
- ])) : y("", !0),
144
- z.value ? (c(), x(u, {
145
- key: 1,
146
- text: "",
147
- class: "yc-page-window__type-switch",
148
- type: l.type === "detail" ? "primary" : "success",
149
- onClick: R
150
- }, {
151
- default: o(() => [
152
- n(d, { class: "m-r-4" }, {
153
- default: o(() => [
154
- n(s(Q))
155
- ]),
156
- _: 1
157
- }),
158
- b(" " + p(l.type === "detail" ? "切换编辑" : "切换详情"), 1)
159
- ]),
160
- _: 1
161
- }, 8, ["type"])) : y("", !0)
162
- ]),
163
- w("div", oe, [
164
- S(e.$slots, "opera", {}, void 0, !0),
165
- l.showButtons && A.value ? (c(), m(j, { key: 0 }, [
166
- n(u, {
167
- text: "",
168
- disabled: g.value,
169
- onClick: r
170
- }, {
171
- default: o(() => [
172
- n(d, { class: "m-r-4" }, {
173
- default: o(() => [
174
- n(s(X))
175
- ]),
176
- _: 1
177
- }),
178
- b(" " + p(l.cancelText), 1)
179
- ]),
180
- _: 1
181
- }, 8, ["disabled"]),
182
- l.showConfirm ? (c(), x(u, {
183
- key: 0,
184
- type: "primary",
185
- loading: g.value,
186
- disabled: l.disabled,
187
- onClick: W
188
- }, {
189
- default: o(() => [
190
- n(d, { class: "m-r-4" }, {
191
- default: o(() => [
192
- n(s(Z))
193
- ]),
194
- _: 1
195
- }),
196
- b(" " + p(l.confirmText), 1)
197
- ]),
198
- _: 1
199
- }, 8, ["loading", "disabled"])) : y("", !0)
200
- ], 64)) : y("", !0)
201
- ])
202
- ]),
203
- C((c(), m("div", le, [
204
- n(E, { class: "yc-page-window__scroll" }, {
205
- default: o(() => [
206
- l.visible ? (c(), m("div", {
207
- key: 0,
208
- class: "yc-page-window__body",
209
- style: T({ minHeight: l.contentMinHeight })
210
- }, [
211
- S(e.$slots, "default", {}, void 0, !0)
212
- ], 4)) : y("", !0)
213
- ]),
214
- _: 3
215
- })
216
- ])), [
217
- [K, g.value]
218
- ])
219
- ], 4), [
220
- [q, l.visible]
221
- ])
222
- ]),
223
- _: 3
224
- });
225
- };
226
- }
227
- });
228
- export {
229
- de as default
230
- };
@@ -1,5 +0,0 @@
1
- import { default as d, default as o } from "./YcPageWindow.vue.js";
2
- export {
3
- d as SkyPageWindow,
4
- o as YcPageWindow
5
- };