dsh-knowledge-library 0.1.1 → 0.3.0
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.
- package/CHANGELOG.md +40 -0
- package/README.md +133 -14
- package/dist/client.js +1654 -304
- package/dist/core/extract.d.ts +5 -0
- package/dist/core/extract.js +78 -8
- package/dist/core/fetch.d.ts +5 -0
- package/dist/core/fetch.js +102 -25
- package/dist/core/grouping.d.ts +6 -0
- package/dist/core/grouping.js +71 -0
- package/dist/core/image-capture.d.ts +33 -0
- package/dist/core/image-capture.js +196 -0
- package/dist/core/incremental.d.ts +14 -0
- package/dist/core/incremental.js +52 -0
- package/dist/core/jobs.d.ts +21 -1
- package/dist/core/jobs.js +101 -12
- package/dist/core/knowledge.d.ts +37 -0
- package/dist/core/knowledge.js +619 -0
- package/dist/core/library.d.ts +36 -2
- package/dist/core/library.js +363 -17
- package/dist/core/page-access.d.ts +6 -0
- package/dist/core/page-access.js +38 -0
- package/dist/core/page-images.d.ts +15 -0
- package/dist/core/page-images.js +97 -0
- package/dist/core/purge.d.ts +20 -0
- package/dist/core/purge.js +106 -0
- package/dist/directory-settings.d.ts +18 -0
- package/dist/directory-settings.js +92 -0
- package/dist/http.d.ts +3 -1
- package/dist/http.js +152 -4
- package/dist/index.js +22 -7
- package/dist/knowledge-model.d.ts +30 -0
- package/dist/knowledge-model.js +194 -0
- package/dist/preview-settings.d.ts +6 -0
- package/dist/preview-settings.js +42 -0
- package/dist/public/app.css +145 -2
- package/dist/public/app.js +10 -6
- package/dist/standalone.js +12 -4
- package/dist/tools.d.ts +2 -1
- package/dist/tools.js +10 -1
- package/dist/types.d.ts +199 -1
- package/dist/ui/App.js +248 -47
- package/dist/ui/Dialog.d.ts +7 -0
- package/dist/ui/Dialog.js +32 -0
- package/dist/ui/Grouping.d.ts +12 -0
- package/dist/ui/Grouping.js +93 -0
- package/dist/ui/ImageCapture.d.ts +18 -0
- package/dist/ui/ImageCapture.js +76 -0
- package/dist/ui/Knowledge.d.ts +26 -0
- package/dist/ui/Knowledge.js +106 -0
- package/dist/ui/api.d.ts +7 -0
- package/dist/ui/api.js +16 -0
- package/dist/ui/icons.js +2 -0
- package/package.json +5 -1
package/dist/client.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(client_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(client_exports);
|
|
28
28
|
|
|
29
29
|
// src/ui/App.tsx
|
|
30
|
-
var
|
|
30
|
+
var import_react5 = require("react");
|
|
31
31
|
|
|
32
32
|
// src/ui/icons.tsx
|
|
33
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -72,15 +72,819 @@ function Icon({ name, size = 20 }) {
|
|
|
72
72
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 7h16M4 17h16" }),
|
|
73
73
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "9", cy: "7", r: "3" }),
|
|
74
74
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "15", cy: "17", r: "3" })
|
|
75
|
-
] })
|
|
75
|
+
] }),
|
|
76
|
+
trash: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7M14 10v7" }) }),
|
|
77
|
+
restore: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 10a9 9 0 1 1 2 9M3 4v6h6M12 7v5l3 2" }) })
|
|
76
78
|
};
|
|
77
79
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths[name] || paths.file });
|
|
78
80
|
}
|
|
79
81
|
var LibraryIcon = ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "library", size });
|
|
80
82
|
|
|
81
|
-
// src/ui/
|
|
82
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
83
|
+
// src/ui/api.ts
|
|
83
84
|
var API = "/knowledge-library/api";
|
|
85
|
+
var ApiError = class extends Error {
|
|
86
|
+
constructor(message, status) {
|
|
87
|
+
super(message);
|
|
88
|
+
this.status = status;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
async function api(path, options = {}) {
|
|
92
|
+
const response = await fetch(API + path, { ...options, headers: { "Content-Type": "application/json", "X-Knowledge-Library": "1", ...options.headers } });
|
|
93
|
+
const data = await response.json();
|
|
94
|
+
if (!response.ok) throw new ApiError(data.error || `\u8BF7\u6C42\u5931\u8D25\uFF1A${response.status}`, response.status);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
var post = (path, value, method = "POST", signal) => api(path, { method, body: JSON.stringify(value), signal });
|
|
98
|
+
|
|
99
|
+
// src/ui/Dialog.tsx
|
|
100
|
+
var import_react = require("react");
|
|
101
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
102
|
+
function Dialog({ title, description, onClose, children }) {
|
|
103
|
+
const ref = (0, import_react.useRef)(null);
|
|
104
|
+
const closeRef = (0, import_react.useRef)(onClose);
|
|
105
|
+
closeRef.current = onClose;
|
|
106
|
+
(0, import_react.useEffect)(() => {
|
|
107
|
+
const previous = document.activeElement;
|
|
108
|
+
const timer = setTimeout(() => ref.current?.querySelector("input,textarea,button")?.focus(), 0);
|
|
109
|
+
const key = (event) => {
|
|
110
|
+
if (event.key === "Escape") closeRef.current();
|
|
111
|
+
if (event.key === "Tab") {
|
|
112
|
+
const elements = Array.from(ref.current?.querySelectorAll("button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select,a[href]") || []);
|
|
113
|
+
const first = elements[0], last = elements[elements.length - 1];
|
|
114
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
last?.focus();
|
|
117
|
+
}
|
|
118
|
+
if (!event.shiftKey && document.activeElement === last) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
first?.focus();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
document.addEventListener("keydown", key);
|
|
125
|
+
return () => {
|
|
126
|
+
clearTimeout(timer);
|
|
127
|
+
document.removeEventListener("keydown", key);
|
|
128
|
+
previous?.focus();
|
|
129
|
+
};
|
|
130
|
+
}, []);
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-modal-backdrop", onMouseDown: (event) => {
|
|
132
|
+
if (event.target === event.currentTarget) onClose();
|
|
133
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, ref, children: [
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: title }),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-label": "\u5173\u95ED\u5F39\u7A97", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close" }) })
|
|
140
|
+
] }),
|
|
141
|
+
children
|
|
142
|
+
] }) });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/ui/Knowledge.tsx
|
|
146
|
+
var import_react3 = require("react");
|
|
147
|
+
|
|
148
|
+
// src/ui/Grouping.tsx
|
|
149
|
+
var import_react2 = require("react");
|
|
150
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
151
|
+
var splitTags = (value) => value.split(/[,,]/).map((t) => t.trim()).filter(Boolean);
|
|
152
|
+
function GroupingEditor({ root, job, model, onRefresh, onNotify, onOpenSource }) {
|
|
153
|
+
const [plan, setPlan] = (0, import_react2.useState)(job.plan);
|
|
154
|
+
const [version, setVersion] = (0, import_react2.useState)(job.planVersion);
|
|
155
|
+
const [tagText, setTagText] = (0, import_react2.useState)(Object.fromEntries(plan.groups.map((g) => [g.id, g.tags.join("\uFF0C")])));
|
|
156
|
+
const [apply2, setApply] = (0, import_react2.useState)(job.classification?.apply ?? plan.applyClassification ?? true);
|
|
157
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
158
|
+
const [error, setError] = (0, import_react2.useState)("");
|
|
159
|
+
const locked = !!job.classification;
|
|
160
|
+
const groups = plan.groups.filter((g) => g.sourceIds.length);
|
|
161
|
+
function groupValue(id, change) {
|
|
162
|
+
setPlan((p) => ({ ...p, groups: p.groups.map((g) => g.id === id ? { ...g, ...change } : g) }));
|
|
163
|
+
}
|
|
164
|
+
function newGroup(sourceId) {
|
|
165
|
+
const source = job.sources.find((s) => s.id === sourceId);
|
|
166
|
+
const analysis = job.analyses?.find((a) => a.sourceId === sourceId);
|
|
167
|
+
const id = `group_${crypto.randomUUID()}`;
|
|
168
|
+
const item = { id, title: analysis?.theme || source?.title || "\u65B0\u5206\u7EC4", reason: source ? "\u72EC\u7ACB\u6574\u7406\u8FD9\u4EFD\u8D44\u6599" : "\u8BF7\u586B\u5199\u8D44\u6599\u4E4B\u95F4\u7684\u5177\u4F53\u5173\u8054", sourceIds: sourceId ? [sourceId] : [], category: analysis?.category || "\u6536\u4EF6\u7BB1", tags: analysis?.tags || [] };
|
|
169
|
+
setTagText((values) => ({ ...values, [id]: item.tags.join("\uFF0C") }));
|
|
170
|
+
setPlan((p) => ({ ...p, groups: [...p.groups.map((g) => ({ ...g, sourceIds: g.sourceIds.filter((s) => s !== sourceId) })), item], unassigned: p.unassigned.filter((s) => s.sourceId !== sourceId) }));
|
|
171
|
+
}
|
|
172
|
+
function assign(sourceId, target) {
|
|
173
|
+
if (target === "__new__") {
|
|
174
|
+
newGroup(sourceId);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const analysis = job.analyses?.find((a) => a.sourceId === sourceId);
|
|
178
|
+
setPlan((p) => ({
|
|
179
|
+
...p,
|
|
180
|
+
groups: p.groups.map((g) => ({ ...g, sourceIds: g.id === target ? [...g.sourceIds.filter((id) => id !== sourceId), sourceId] : g.sourceIds.filter((id) => id !== sourceId) })),
|
|
181
|
+
unassigned: [...p.unassigned.filter((s) => s.sourceId !== sourceId), ...target ? [] : [{ sourceId, reason: analysis?.uncertainty || "\u6682\u7559\u5F85\u6574\u7406\uFF0C\u540E\u7EED\u518D\u5224\u65AD\u5173\u8054" }]]
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
function removeGroup(id) {
|
|
185
|
+
setPlan((p) => ({ ...p, groups: p.groups.filter((g) => g.id !== id), unassigned: [...p.unassigned, ...(p.groups.find((g) => g.id === id)?.sourceIds || []).map((sourceId) => ({ sourceId, reason: "\u5DF2\u79FB\u51FA\u5206\u7EC4\uFF0C\u4FDD\u7559\u5F85\u6574\u7406" }))] }));
|
|
186
|
+
}
|
|
187
|
+
async function save(confirm, openSource) {
|
|
188
|
+
if (busy) return;
|
|
189
|
+
setBusy(true);
|
|
190
|
+
setError("");
|
|
191
|
+
try {
|
|
192
|
+
let currentVersion = version;
|
|
193
|
+
if (!locked) {
|
|
194
|
+
const value = { ...plan, applyClassification: apply2, groups: groups.map((g) => ({ ...g, tags: splitTags(tagText[g.id] || "") })) };
|
|
195
|
+
const edited = await post(`/knowledge/jobs/${job.id}/plan`, { expectedRoot: root, version, plan: value }, "PATCH");
|
|
196
|
+
currentVersion = edited.planVersion;
|
|
197
|
+
setVersion(currentVersion);
|
|
198
|
+
}
|
|
199
|
+
if (confirm) {
|
|
200
|
+
await post(`/knowledge/jobs/${job.id}/confirm-plan`, { expectedRoot: root, version: currentVersion, applyClassification: apply2, expectedModel: model.model, confirmed: true });
|
|
201
|
+
onNotify(`${groups.length} \u7EC4\u8D44\u6599\u5DF2\u63D0\u4EA4\u751F\u6210\u8349\u7A3F\uFF1B${plan.unassigned.length} \u4EFD\u4FDD\u7559\u5F85\u6574\u7406`);
|
|
202
|
+
onRefresh();
|
|
203
|
+
} else if (openSource) onOpenSource(openSource);
|
|
204
|
+
else {
|
|
205
|
+
onNotify("\u5206\u7EC4\u65B9\u6848\u5DF2\u4FDD\u5B58\uFF0C\u6765\u6E90\u5206\u7C7B\u5C1A\u672A\u4FEE\u6539");
|
|
206
|
+
onRefresh();
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
setError(e.message);
|
|
210
|
+
if (confirm) onRefresh();
|
|
211
|
+
} finally {
|
|
212
|
+
setBusy(false);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function rollback() {
|
|
216
|
+
setBusy(true);
|
|
217
|
+
setError("");
|
|
218
|
+
try {
|
|
219
|
+
await post(`/knowledge/jobs/${job.id}/rollback-plan`, { expectedRoot: root, confirmed: true });
|
|
220
|
+
onNotify("\u672A\u5B8C\u6210\u7684\u5206\u7C7B\u4FEE\u6539\u5DF2\u56DE\u9000");
|
|
221
|
+
onRefresh();
|
|
222
|
+
} catch (e) {
|
|
223
|
+
setError(e.message);
|
|
224
|
+
onRefresh();
|
|
225
|
+
} finally {
|
|
226
|
+
setBusy(false);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-grouping-editor", children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-grouping-summary", children: [
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("b", { children: [
|
|
232
|
+
groups.length,
|
|
233
|
+
" \u4E2A\u5206\u7EC4"
|
|
234
|
+
] }),
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
236
|
+
plan.unassigned.length,
|
|
237
|
+
" \u4EFD\u5F85\u6574\u7406"
|
|
238
|
+
] })
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "kl-knowledge-model", children: "\u5148\u6838\u5BF9\u9010\u7BC7\u5206\u6790\u4E0E\u5206\u7EC4\u7406\u7531\u3002\u65E0\u5173\u8054\u7684\u8D44\u6599\u53EF\u72EC\u7ACB\u6210\u7EC4\uFF0C\u4FE1\u606F\u4E0D\u8DB3\u7684\u8D44\u6599\u53EF\u4EE5\u7559\u5F85\u6574\u7406\u3002\u4FEE\u6539\u540E\u8BF7\u4FDD\u5B58\u65B9\u6848\uFF0C\u518D\u5173\u95ED\u7A97\u53E3\u3002" }),
|
|
241
|
+
job.error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "alert", className: "kl-form-error", children: job.error }),
|
|
242
|
+
locked && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-grouping-recovery", role: "status", children: [
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "\u4E0A\u6B21\u5F52\u7C7B\u5C1A\u672A\u5B8C\u6210" }),
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
245
|
+
job.classification.steps.filter((s) => s.done).length,
|
|
246
|
+
" / ",
|
|
247
|
+
job.classification.steps.length,
|
|
248
|
+
" \u4EFD\u5DF2\u5B8C\u6210",
|
|
249
|
+
job.classification.direction === "rollback" ? "\u56DE\u9000" : "\u5F52\u7C7B",
|
|
250
|
+
"\u3002\u65B9\u6848\u5DF2\u9501\u5B9A\uFF0C\u53EF\u7EE7\u7EED\u5904\u7406\u6216\u56DE\u9000\u5DF2\u66F4\u6539\u7684\u5206\u7C7B\u3002"
|
|
251
|
+
] }),
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: () => void rollback(), children: job.classification.direction === "rollback" ? "\u7EE7\u7EED\u56DE\u9000\u5206\u7C7B" : "\u56DE\u9000\u5DF2\u66F4\u6539\u7684\u5206\u7C7B" })
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "kl-grouping-groups", children: plan.groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "kl-grouping-group", "aria-label": `\u5206\u7EC4 ${index + 1}`, children: [
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-grouping-group-title", children: [
|
|
256
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
257
|
+
"\u5206\u7EC4 ",
|
|
258
|
+
index + 1,
|
|
259
|
+
" \xB7 ",
|
|
260
|
+
group.sourceIds.length,
|
|
261
|
+
" \u4EFD\u8D44\u6599"
|
|
262
|
+
] }),
|
|
263
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "kl-icon-button kl-danger", "aria-label": `\u5220\u9664\u5206\u7EC4 ${index + 1}`, disabled: busy || locked, onClick: () => removeGroup(group.id), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "trash", size: 15 }) })
|
|
264
|
+
] }),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
266
|
+
"\u5206\u7EC4\u540D\u79F0",
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { "aria-label": `\u5206\u7EC4\u540D\u79F0 ${index + 1}`, maxLength: 200, value: group.title, disabled: busy || locked, onChange: (e) => groupValue(group.id, { title: e.target.value }) })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "kl-grouping-reason", children: group.reason }),
|
|
270
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { className: "kl-grouping-settings", children: [
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("summary", { children: [
|
|
272
|
+
"\u5206\u7C7B\u4E0E\u5206\u7EC4\u8BBE\u7F6E ",
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: group.category })
|
|
274
|
+
] }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
276
|
+
"\u5206\u7EC4\u7406\u7531",
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { "aria-label": `\u5206\u7EC4\u7406\u7531 ${index + 1}`, rows: 2, maxLength: 1200, value: group.reason, disabled: busy || locked, onChange: (e) => groupValue(group.id, { reason: e.target.value }) })
|
|
278
|
+
] }),
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-knowledge-fields", children: [
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
281
|
+
"\u6765\u6E90\u5206\u7C7B",
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { "aria-label": `\u6765\u6E90\u5206\u7C7B ${index + 1}`, value: group.category, maxLength: 180, disabled: busy || locked, onChange: (e) => groupValue(group.id, { category: e.target.value }) })
|
|
283
|
+
] }),
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
285
|
+
"\u5206\u7EC4\u6807\u7B7E",
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { "aria-label": `\u5206\u7EC4\u6807\u7B7E ${index + 1}`, value: tagText[group.id] || "", disabled: busy || locked, onChange: (e) => setTagText((v) => ({ ...v, [group.id]: e.target.value })) })
|
|
287
|
+
] })
|
|
288
|
+
] })
|
|
289
|
+
] }),
|
|
290
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { children: group.sourceIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("li", { children: job.sources.find((s) => s.id === id)?.title }, id)) }),
|
|
291
|
+
!group.sourceIds.length && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "kl-muted", children: "\u6682\u65E0\u8D44\u6599\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u5FFD\u7565\u7A7A\u5206\u7EC4\u3002" })
|
|
292
|
+
] }, group.id)) }),
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: "kl-secondary", disabled: busy || locked || plan.groups.length >= 10, onClick: () => newGroup(), children: [
|
|
294
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "plus", size: 14 }),
|
|
295
|
+
"\u65B0\u589E\u5206\u7EC4"
|
|
296
|
+
] }),
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "kl-grouping-section-title", children: "\u9010\u7BC7\u5206\u6790\u4E0E\u6210\u5458\u8C03\u6574" }),
|
|
298
|
+
job.sources.map((source) => {
|
|
299
|
+
const analysis = job.analyses?.find((a) => a.sourceId === source.id);
|
|
300
|
+
const unassigned = plan.unassigned.find((s) => s.sourceId === source.id);
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "kl-grouping-source", "aria-label": `${source.title} \u7684\u5206\u6790`, children: [
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "kl-grouping-source-title", children: [
|
|
303
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: source.title }),
|
|
304
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "kl-knowledge-badge", children: analysis?.certainty === "uncertain" ? "\u9700\u6838\u5BF9" : "\u4E3B\u9898\u5EFA\u8BAE" })
|
|
305
|
+
] }),
|
|
306
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: analysis?.theme }),
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
308
|
+
"\u6240\u5C5E\u5206\u7EC4",
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { "aria-label": `\u6240\u5C5E\u5206\u7EC4 ${source.title}`, value: plan.groups.find((g) => g.sourceIds.includes(source.id))?.id || "", disabled: busy || locked, onChange: (e) => assign(source.id, e.target.value), children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: "\u4FDD\u7559\u5F85\u6574\u7406" }),
|
|
311
|
+
plan.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: g.id, children: g.title || "\u672A\u547D\u540D\u5206\u7EC4" }, g.id)),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "__new__", children: "\u5355\u72EC\u6210\u7EC4" })
|
|
313
|
+
] })
|
|
314
|
+
] }),
|
|
315
|
+
unassigned && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
|
|
316
|
+
"\u5F85\u6574\u7406\u7406\u7531",
|
|
317
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { "aria-label": `\u5F85\u6574\u7406\u7406\u7531 ${source.title}`, maxLength: 1200, value: unassigned.reason, disabled: busy || locked, onChange: (e) => setPlan((p) => ({ ...p, unassigned: p.unassigned.map((s) => s.sourceId === source.id ? { ...s, reason: e.target.value } : s) })) })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("details", { children: [
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("summary", { children: "\u5206\u6790\u8BE6\u60C5\u4E0E\u6765\u6E90" }),
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: analysis?.summary }),
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
323
|
+
"\u7528\u9014\uFF1A",
|
|
324
|
+
analysis?.usage
|
|
325
|
+
] }),
|
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
327
|
+
"\u6982\u5FF5\uFF1A",
|
|
328
|
+
analysis?.concepts.join("\u3001")
|
|
329
|
+
] }),
|
|
330
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
331
|
+
"\u5EFA\u8BAE\u5206\u7C7B\uFF1A",
|
|
332
|
+
analysis?.category,
|
|
333
|
+
" \xB7 \u6807\u7B7E\uFF1A",
|
|
334
|
+
analysis?.tags.join("\u3001") || "\u65E0"
|
|
335
|
+
] }),
|
|
336
|
+
analysis?.uncertainty && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
|
|
337
|
+
"\u5F85\u6838\u5B9E\uFF1A",
|
|
338
|
+
analysis.uncertainty
|
|
339
|
+
] }),
|
|
340
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: "kl-secondary", disabled: busy || locked, onClick: () => void save(false, source.id), children: [
|
|
341
|
+
"\u4FDD\u5B58\u65B9\u6848\u5E76\u67E5\u770B\u6765\u6E90",
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "arrow", size: 14 })
|
|
343
|
+
] })
|
|
344
|
+
] })
|
|
345
|
+
] }, source.id);
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "kl-grouping-sync", children: [
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { type: "checkbox", "aria-label": "\u540C\u6B65\u6765\u6E90\u5206\u7C7B\u548C\u6807\u7B7E", checked: apply2, disabled: busy || locked, onChange: (e) => setApply(e.target.checked) }),
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u786E\u8BA4\u540E\u540C\u6B65\u6765\u6E90\u5206\u7C7B\u548C\u6807\u7B7E\u5230\u672C\u5730\u76EE\u5F55" })
|
|
350
|
+
] }),
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "kl-knowledge-model", children: "\u540C\u6B65\u65F6\u4F1A\u79FB\u52A8\u5DF2\u5206\u7EC4\u8D44\u6599\u7684\u76EE\u5F55\u3001\u4FDD\u7559\u539F\u6807\u7B7E\u5E76\u6DFB\u52A0\u5206\u7EC4\u6807\u7B7E\uFF1B\u672A\u5206\u7EC4\u8D44\u6599\u4FDD\u6301\u5F85\u6574\u7406\u3002\u5173\u95ED\u540C\u6B65\u53EF\u53EA\u6309\u7EC4\u751F\u6210\u8349\u7A3F\u3002\u6BCF\u7EC4\u751F\u6210\u540E\u4ECD\u9700\u5355\u72EC\u786E\u8BA4\u4FDD\u5B58\u6B63\u5F0F\u7B14\u8BB0\u3002" }),
|
|
352
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "kl-knowledge-model", children: [
|
|
353
|
+
"\u751F\u6210\u8349\u7A3F\u4F7F\u7528\u6A21\u578B\uFF1A",
|
|
354
|
+
model.model || "\u5C1A\u672A\u914D\u7F6E",
|
|
355
|
+
"\u3002",
|
|
356
|
+
model.model !== job.model && `\u9010\u7BC7\u5206\u6790\u65F6\u4F7F\u7528\u7684\u662F ${job.model || "\u672A\u8BB0\u5F55\u6A21\u578B"}\u3002`,
|
|
357
|
+
"\u786E\u8BA4\u540E\u5C06\u7EE7\u7EED\u5411\u8BE5\u6A21\u578B\u53D1\u9001\u5404\u7EC4\u6B63\u6587\u53CA\u68C0\u7D22\u5230\u7684\u76F8\u5173\u77E5\u8BC6\u7B14\u8BB0\uFF0C\u7528\u4E8E\u751F\u6210\u8349\u7A3F\u548C\u5224\u65AD\u589E\u91CF\u8865\u5145\u3002\u672C\u6B21\u667A\u80FD\u6574\u7406\u53CA\u5176\u5B50\u4EFB\u52A1\u5408\u8BA1\u6700\u591A 80 \u6B21\u6A21\u578B\u8BF7\u6C42\uFF08\u5DF2\u4F7F\u7528 ",
|
|
358
|
+
job.modelCalls || 0,
|
|
359
|
+
" \u6B21\uFF09\uFF0C\u53EF\u80FD\u4EA7\u751F\u8C03\u7528\u8D39\u7528\u3002"
|
|
360
|
+
] }),
|
|
361
|
+
!!groups.length && !model.available && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "alert", className: "kl-form-error", children: model.reason || "\u8BF7\u5148\u914D\u7F6E\u751F\u6210\u6A21\u578B" }),
|
|
362
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("footer", { children: [
|
|
364
|
+
!locked && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: () => void save(false), children: "\u4FDD\u5B58\u5206\u7EC4\u65B9\u6848" }),
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "kl-primary", disabled: busy || !!groups.length && !model.available || job.classification?.direction === "rollback", onClick: () => void save(true), children: busy ? "\u6B63\u5728\u5904\u7406\u2026" : locked ? "\u7EE7\u7EED\u5F52\u7C7B\u5E76\u751F\u6210\u8349\u7A3F" : groups.length ? `\u786E\u8BA4${apply2 ? "\u5F52\u7C7B" : "\u5206\u7EC4"}\u5E76\u751F\u6210 ${groups.length} \u4EFD\u8349\u7A3F` : "\u786E\u8BA4\u4FDD\u7559\u5168\u90E8\u5F85\u6574\u7406" })
|
|
366
|
+
] })
|
|
367
|
+
] });
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/ui/Knowledge.tsx
|
|
371
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
372
|
+
var stateLabels = { pending: "\u5F85\u6574\u7406", running: "\u6574\u7406\u4E2D", grouping: "\u5F85\u5206\u7EC4\u786E\u8BA4", draft: "\u5F85\u786E\u8BA4", completed: "\u5DF2\u6574\u7406", failed: "\u6574\u7406\u5931\u8D25" };
|
|
373
|
+
var jobLabels = { queued: "\u6392\u961F\u4E2D", running: "\u6574\u7406\u4E2D", grouping: "\u5F85\u5206\u7EC4\u786E\u8BA4", classifying: "\u5F52\u7C7B\u4E2D", grouped: "\u5DF2\u5206\u7EC4", draft: "\u5F85\u786E\u8BA4", completed: "\u5DF2\u4FDD\u5B58", failed: "\u5931\u8D25", cancelled: "\u5DF2\u53D6\u6D88", discarded: "\u5DF2\u820D\u5F03" };
|
|
374
|
+
function KnowledgeBadge({ state }) {
|
|
375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `kl-knowledge-badge ${state?.status || "pending"}`, children: stateLabels[state?.status || "pending"] });
|
|
376
|
+
}
|
|
377
|
+
function StartKnowledgeDialog({ root, sourceIds, model, initialMode, onClose, onCreated }) {
|
|
378
|
+
const [sources, setSources] = (0, import_react3.useState)();
|
|
379
|
+
const [topic, setTopic] = (0, import_react3.useState)("");
|
|
380
|
+
const [error, setError] = (0, import_react3.useState)("");
|
|
381
|
+
const [busy, setBusy] = (0, import_react3.useState)(false);
|
|
382
|
+
const [mode, setMode] = (0, import_react3.useState)(initialMode || (sourceIds.length > 1 ? "smart" : "compose"));
|
|
383
|
+
const smart = mode === "smart";
|
|
384
|
+
(0, import_react3.useEffect)(() => {
|
|
385
|
+
const abort = new AbortController();
|
|
386
|
+
void Promise.all(sourceIds.map((id) => api(`/materials/${id}`, { signal: abort.signal }))).then(setSources).catch((e) => {
|
|
387
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
388
|
+
});
|
|
389
|
+
return () => abort.abort();
|
|
390
|
+
}, [sourceIds]);
|
|
391
|
+
const characters = sources?.reduce((sum, source) => sum + source.content.length, 0) || 0;
|
|
392
|
+
const invalidSource = sources?.some((s) => s.deletedAt || s.kind === "note" || s.status !== "ready");
|
|
393
|
+
async function start(event) {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
setBusy(true);
|
|
396
|
+
setError("");
|
|
397
|
+
try {
|
|
398
|
+
onCreated(await post("/knowledge/jobs", { expectedRoot: root, sourceIds, topic, mode }));
|
|
399
|
+
} catch (e) {
|
|
400
|
+
setError(e.message);
|
|
401
|
+
} finally {
|
|
402
|
+
setBusy(false);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Dialog, { title: smart ? "\u667A\u80FD\u6574\u7406" : "\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0", description: smart ? "\u5148\u9010\u7BC7\u5206\u6790\u3001\u5EFA\u8BAE\u5206\u7EC4\uFF0C\u518D\u786E\u8BA4\u5206\u7C7B\u4E0E\u751F\u6210\u5404\u7EC4\u77E5\u8BC6\u8349\u7A3F\u3002" : "\u5148\u63D0\u70BC\u8D44\u6599\uFF0C\u518D\u7531\u4F60\u786E\u8BA4\u3002\u539F\u59CB\u8D44\u6599\u4E0E\u6765\u6E90\u5F15\u7528\u4F1A\u4FDD\u7559\u3002", onClose: () => {
|
|
406
|
+
if (!busy) onClose();
|
|
407
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { className: "kl-knowledge-form", onSubmit: (event) => void start(event), children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-knowledge-summary", children: [
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("b", { children: [
|
|
410
|
+
sourceIds.length,
|
|
411
|
+
" \u4EFD\u6765\u6E90\u8D44\u6599"
|
|
412
|
+
] }),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
414
|
+
characters.toLocaleString(),
|
|
415
|
+
" \u5B57"
|
|
416
|
+
] })
|
|
417
|
+
] }),
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "kl-knowledge-source-list", children: sources?.map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "file", size: 14 }),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: s.title })
|
|
421
|
+
] }, s.id)) }),
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "kl-knowledge-mode", children: [
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "\u6574\u7406\u65B9\u5F0F" }),
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "knowledge-mode", value: "smart", checked: smart, disabled: !model.smartSupported || busy, onChange: () => setMode("smart") }),
|
|
426
|
+
"\u667A\u80FD\u5206\u7EC4",
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u9002\u5408\u96F6\u6563\u8D44\u6599\uFF0C\u5148\u5224\u65AD\u5173\u8054" })
|
|
428
|
+
] }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "knowledge-mode", value: "compose", checked: !smart, disabled: busy, onChange: () => setMode("compose") }),
|
|
431
|
+
"\u540C\u4E3B\u9898\u76F4\u63A5\u7EFC\u5408",
|
|
432
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u5DF2\u786E\u8BA4\u56F4\u7ED5\u540C\u4E00\u95EE\u9898\u65F6\u4F7F\u7528" })
|
|
433
|
+
] })
|
|
434
|
+
] }),
|
|
435
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
436
|
+
smart ? "\u6574\u7406\u65B9\u5411\uFF08\u53EF\u9009\uFF09" : "\u6574\u7406\u4E3B\u9898",
|
|
437
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "\u6574\u7406\u4E3B\u9898", value: topic, onChange: (e) => setTopic(e.target.value), maxLength: 300, placeholder: smart ? "\u7559\u7A7A\u53EF\u6309\u8D44\u6599\u7684\u5B9E\u9645\u4E3B\u9898\u81EA\u52A8\u5206\u7EC4" : "\u4F8B\u5982\uFF1AHarness \u5982\u4F55\u63D0\u9AD8 Agent \u7684\u53EF\u9760\u6027" }),
|
|
438
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: smart ? "\u65B9\u5411\u7528\u4E8E\u8F85\u52A9\u5224\u65AD\uFF0C\u4E0D\u4F1A\u8981\u6C42\u628A\u65E0\u5173\u8054\u8D44\u6599\u5408\u5E76\u3002" : "\u7559\u7A7A\u65F6\u56F4\u7ED5\u8D44\u6599\u672C\u8EAB\u6574\u7406\uFF1B\u591A\u7BC7\u8D44\u6599\u4F1A\u6BD4\u8F83\u5171\u8BC6\u3001\u5DEE\u5F02\u548C\u77DB\u76FE\u3002" })
|
|
439
|
+
] }),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-muted", children: smart ? "\u9010\u7BC7\u63D0\u53D6\u4E3B\u9898\u3001\u6982\u5FF5\u4E0E\u7528\u9014\uFF0C\u7ED9\u51FA\u5206\u7EC4\u7406\u7531\u548C\u5206\u7C7B\u6807\u7B7E\u5EFA\u8BAE\u3002\u65E0\u5173\u8054\u8D44\u6599\u53EF\u72EC\u7ACB\u6210\u7EC4\uFF0C\u4FE1\u606F\u4E0D\u8DB3\u7684\u8D44\u6599\u4FDD\u7559\u5F85\u6574\u7406\u3002\u786E\u8BA4\u65B9\u6848\u524D\u4E0D\u79FB\u52A8\u8D44\u6599\u3002" : "\u5C06\u63D0\u70BC\u6838\u5FC3\u89C2\u70B9\u3001\u5173\u952E\u6982\u5FF5\u3001\u53EF\u590D\u7528\u65B9\u6CD5\u3001\u9002\u7528\u6761\u4EF6\u4E0E\u5C40\u9650\u3001\u5F85\u9A8C\u8BC1\u95EE\u9898\uFF0C\u5E76\u6807\u6CE8\u6765\u6E90\u6BB5\u843D\u3002" }),
|
|
441
|
+
smart && !model.smartSupported && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: "\u8BF7\u91CD\u542F\u8D44\u6599\u5E93\u670D\u52A1\u4EE5\u542F\u7528\u667A\u80FD\u5206\u7EC4\u3002" }),
|
|
442
|
+
model.available ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "kl-knowledge-model", children: [
|
|
443
|
+
"\u4F7F\u7528\u6A21\u578B\uFF1A",
|
|
444
|
+
model.model,
|
|
445
|
+
"\u3002\u70B9\u51FB\u5F00\u59CB\u540E\u4F1A\u5411\u8BE5\u6A21\u578B\u53D1\u9001\u6240\u9009\u6B63\u6587\u53CA\u68C0\u7D22\u5230\u7684\u76F8\u5173\u77E5\u8BC6\u7B14\u8BB0\uFF0C\u53EF\u80FD\u4EA7\u751F\u8C03\u7528\u8D39\u7528\u3002",
|
|
446
|
+
smart ? "\u9010\u7BC7\u5206\u6790\u548C\u5206\u7EC4\u6700\u591A 40 \u6B21\u8BF7\u6C42\uFF1B\u786E\u8BA4\u540E\u5404\u7EC4\u7EE7\u7EED\u751F\u6210\u8349\u7A3F\uFF0C\u6574\u6B21\u4EFB\u52A1\u5408\u8BA1\u6700\u591A 80 \u6B21\u3002" : "\u957F\u6587\u4F1A\u5206\u6BB5\u63D0\u70BC\uFF0C\u542B\u65E7\u7B14\u8BB0\u5BF9\u6BD4\u6700\u591A 22 \u6B21\u6A21\u578B\u8BF7\u6C42\u3002",
|
|
447
|
+
"\u5355\u6B21\u6700\u591A 10 \u4EFD\u3001\u6B63\u6587\u603B\u91CF 10 \u4E07\u5B57\u3002"
|
|
448
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: model.reason }),
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("a", { className: "kl-knowledge-help", href: "https://github.com/Alan-dong-dong/dsh-knowledge-library#\u5C06\u8D44\u6599\u6574\u7406\u4E3A\u77E5\u8BC6\u7B14\u8BB0", target: "_blank", rel: "noreferrer", children: [
|
|
451
|
+
"\u67E5\u770B\u6A21\u578B\u914D\u7F6E\u8BF4\u660E ",
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "arrow", size: 12 })
|
|
453
|
+
] })
|
|
454
|
+
] }),
|
|
455
|
+
model.available && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "kl-knowledge-model", children: [
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: "\u8F93\u51FA\u914D\u7F6E\u4E0E\u601D\u8003" }),
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "\u8F93\u51FA\u989D\u5EA6\u6CBF\u7528\u5F53\u524D\u6A21\u578B\u914D\u7F6E\uFF0C\u63D2\u4EF6\u4E0D\u53E6\u8BBE token \u4E0A\u9650\u3002Harness \u4F7F\u7528\u6A21\u578B\u9002\u914D\u5668\u7684\u9ED8\u8BA4\u8F93\u51FA\u914D\u7F6E\uFF0C\u72EC\u7ACB\u9884\u89C8\u4F7F\u7528\u6A21\u578B\u670D\u52A1\u9ED8\u8BA4\u914D\u7F6E\u3002\u4FDD\u7559\u5F53\u524D\u601D\u8003\u5F3A\u5EA6\uFF0C\u90E8\u5206\u6A21\u578B\u5C06\u601D\u8003\u4E0E\u6B63\u6587\u4E00\u8D77\u8BA1\u5165\u989D\u5EA6\uFF0C\u8D39\u7528\u6309\u6A21\u578B\u670D\u52A1\u89C4\u5219\u8BA1\u7B97\u3002\u63D0\u70BC/\u5206\u6790\u6BCF\u6B21\u6700\u591A\u7B49\u5F85 5 \u5206\u949F\uFF0C\u5206\u7EC4/\u7EFC\u5408/\u5BF9\u6BD4\u6700\u591A 10 \u5206\u949F\uFF0C\u53EF\u968F\u65F6\u53D6\u6D88\uFF1B\u622A\u65AD\u4E0D\u4F1A\u81EA\u52A8\u91CD\u8BD5\u3002" })
|
|
458
|
+
] }),
|
|
459
|
+
characters > 1e5 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: "\u6B63\u6587\u8D85\u8FC7 10 \u4E07\u5B57\uFF0C\u8BF7\u51CF\u5C11\u9009\u62E9\u540E\u5206\u6279\u6574\u7406\u3002" }),
|
|
460
|
+
invalidSource && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: "\u90E8\u5206\u8D44\u6599\u5DF2\u5220\u9664\u3001\u4EC5\u5F52\u6863\u6216\u5C5E\u4E8E\u77E5\u8BC6\u7B14\u8BB0\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002" }),
|
|
461
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("footer", { children: [
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
464
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-primary", disabled: busy || !sources || !model.available || smart && !model.smartSupported || characters > 1e5 || invalidSource, children: busy ? "\u6B63\u5728\u63D0\u4EA4\u2026" : smart ? "\u5F00\u59CB\u5206\u6790\u5206\u7EC4" : "\u5F00\u59CB\u6574\u7406" })
|
|
465
|
+
] })
|
|
466
|
+
] }) });
|
|
467
|
+
}
|
|
468
|
+
function KnowledgeJobsDialog(props) {
|
|
469
|
+
const { root, overview, onClose, onRefresh, onRegenerate, onOpenSource, onSaved, onNotify } = props;
|
|
470
|
+
const [selected, setSelected] = (0, import_react3.useState)(props.jobId);
|
|
471
|
+
const [error, setError] = (0, import_react3.useState)("");
|
|
472
|
+
const [busy, setBusy] = (0, import_react3.useState)(false);
|
|
473
|
+
const job = overview.jobs.find((j) => j.id === selected);
|
|
474
|
+
async function action(name) {
|
|
475
|
+
if (!job) return;
|
|
476
|
+
setBusy(true);
|
|
477
|
+
setError("");
|
|
478
|
+
try {
|
|
479
|
+
await post(`/knowledge/jobs/${job.id}/${name}`, { expectedRoot: root });
|
|
480
|
+
onRefresh();
|
|
481
|
+
} catch (e) {
|
|
482
|
+
setError(e.message);
|
|
483
|
+
} finally {
|
|
484
|
+
setBusy(false);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Dialog, { title: job?.status === "draft" ? "\u786E\u8BA4\u77E5\u8BC6\u7B14\u8BB0" : job?.status === "grouping" ? "\u786E\u8BA4\u667A\u80FD\u5206\u7EC4" : "\u77E5\u8BC6\u6574\u7406", description: "\u5206\u6790\u3001\u5206\u7EC4\u65B9\u6848\u4E0E\u8349\u7A3F\u4FDD\u5B58\u5728\u672C\u5730\u3002\u6B63\u5F0F\u77E5\u8BC6\u7B14\u8BB0\u4ECD\u9700\u9010\u4EFD\u786E\u8BA4\u4FDD\u5B58\u3002", onClose: () => {
|
|
488
|
+
if (!busy) onClose();
|
|
489
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-knowledge-jobs", children: [
|
|
490
|
+
!!selected && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-knowledge-back", onClick: () => {
|
|
491
|
+
setSelected(void 0);
|
|
492
|
+
setError("");
|
|
493
|
+
}, children: "\u2190 \u5168\u90E8\u6574\u7406\u4EFB\u52A1" }),
|
|
494
|
+
!overview.supported && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: overview.reason }),
|
|
495
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
496
|
+
!selected ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: !overview.jobs.length ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-knowledge-empty", children: [
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "note", size: 26 }),
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "\u8FD8\u6CA1\u6709\u6574\u7406\u4EFB\u52A1" }),
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u6253\u5F00\u4E00\u4EFD\u8D44\u6599\u70B9\u51FB\u201C\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0\u201D\uFF0C\u6216\u5728\u5217\u8868\u4E2D\u9009\u62E9\u201C\u667A\u80FD\u6574\u7406\u201D\u3002" })
|
|
500
|
+
] }) : overview.jobs.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { className: "kl-knowledge-job", onClick: () => {
|
|
501
|
+
setSelected(item.id);
|
|
502
|
+
setError("");
|
|
503
|
+
}, children: [
|
|
504
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
505
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: item.topic || item.sources.map((s) => s.title).join("\u3001") }),
|
|
506
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `kl-knowledge-badge ${item.status}`, children: jobLabels[item.status] })
|
|
507
|
+
] }),
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
|
|
509
|
+
item.mode === "smart" ? "\u667A\u80FD\u5206\u7EC4 \xB7 " : item.parentId ? "\u5206\u7EC4\u5B50\u4EFB\u52A1 \xB7 " : "",
|
|
510
|
+
item.sourceIds.length,
|
|
511
|
+
" \u4EFD\u6765\u6E90 \xB7 ",
|
|
512
|
+
new Date(item.updatedAt).toLocaleString("zh-CN")
|
|
513
|
+
] }),
|
|
514
|
+
item.error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: item.error })
|
|
515
|
+
] }, item.id)) }) : !job ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-muted", children: "\u6B63\u5728\u8BFB\u53D6\u6574\u7406\u4EFB\u52A1\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-knowledge-job-heading", children: [
|
|
517
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: job.topic || job.sources.map((s) => s.title).join("\u3001") }),
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: `kl-knowledge-badge ${job.status}`, children: jobLabels[job.status] })
|
|
519
|
+
] }),
|
|
520
|
+
job.status === "grouping" && job.plan ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GroupingEditor, { root, job, model: overview, onRefresh, onOpenSource, onNotify }, `${job.id}:${job.planVersion}`) : job.status === "draft" && job.draft ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DraftEditor, { root, job, onRefresh, onOpenSource, onSaved, onNotify }, `${job.id}:${job.draftVersion}`) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
521
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "kl-knowledge-progress", role: "status", children: [
|
|
522
|
+
["queued", "running"].includes(job.status) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "kl-spinner" }),
|
|
523
|
+
job.progress
|
|
524
|
+
] }),
|
|
525
|
+
job.error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: job.error }),
|
|
526
|
+
job.model && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "kl-muted", children: [
|
|
527
|
+
"\u6A21\u578B\uFF1A",
|
|
528
|
+
job.model
|
|
529
|
+
] }),
|
|
530
|
+
job.status === "completed" && job.noteId && (job.sourceIds.some((id) => overview.states[id]?.noteIds.includes(job.noteId)) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-primary", onClick: () => onOpenSource(job.noteId), children: "\u6253\u5F00\u77E5\u8BC6\u7B14\u8BB0" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-muted", children: "\u5173\u8054\u7B14\u8BB0\u5DF2\u79FB\u5165\u56DE\u6536\u7AD9\u6216\u6C38\u4E45\u5220\u9664\uFF0C\u53EF\u6062\u590D\u7B14\u8BB0\u6216\u91CD\u65B0\u6574\u7406\u3002" })),
|
|
531
|
+
job.status === "grouped" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-grouping-children", children: [
|
|
532
|
+
job.children?.map((child) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { className: "kl-knowledge-job", onClick: () => setSelected(child.jobId), children: [
|
|
533
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
534
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: job.plan?.groups.find((g) => g.id === child.groupId)?.title || "\u5206\u7EC4\u8349\u7A3F" }),
|
|
535
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "kl-knowledge-badge", children: jobLabels[overview.jobs.find((j) => j.id === child.jobId)?.status || "queued"] })
|
|
536
|
+
] }),
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "\u6253\u5F00\u672C\u7EC4\u4EFB\u52A1\uFF0C\u5355\u72EC\u6838\u5BF9\u5E76\u4FDD\u5B58\u77E5\u8BC6\u7B14\u8BB0" })
|
|
538
|
+
] }, child.jobId)),
|
|
539
|
+
!!job.plan?.unassigned.length && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-grouping-pending", children: [
|
|
540
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "\u4FDD\u7559\u5F85\u6574\u7406" }),
|
|
541
|
+
job.plan.unassigned.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { children: [
|
|
542
|
+
job.sources.find((s) => s.id === item.sourceId)?.title,
|
|
543
|
+
"\uFF1A",
|
|
544
|
+
item.reason
|
|
545
|
+
] }, item.sourceId))
|
|
546
|
+
] })
|
|
547
|
+
] })
|
|
548
|
+
] }),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-knowledge-actions", children: [
|
|
550
|
+
["queued", "running"].includes(job.status) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: () => void action("cancel"), children: "\u53D6\u6D88\u6574\u7406" }),
|
|
551
|
+
["draft", "failed", "grouping"].includes(job.status) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { className: "kl-secondary kl-danger", disabled: busy || !!job.classification, onClick: () => void action("discard"), children: [
|
|
552
|
+
"\u820D\u5F03",
|
|
553
|
+
job.status === "draft" ? "\u8349\u7A3F" : job.status === "grouping" ? "\u65B9\u6848" : "\u4EFB\u52A1"
|
|
554
|
+
] }),
|
|
555
|
+
["failed", "cancelled", "discarded", "completed"].includes(job.status) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-secondary", onClick: () => onRegenerate(job.sourceIds, job.mode), children: "\u91CD\u65B0\u6574\u7406" })
|
|
556
|
+
] })
|
|
557
|
+
] })
|
|
558
|
+
] }) });
|
|
559
|
+
}
|
|
560
|
+
function DraftEditor({ root, job, onRefresh, onOpenSource, onSaved, onNotify }) {
|
|
561
|
+
const [draft, setDraft] = (0, import_react3.useState)(job.draft);
|
|
562
|
+
const [integration, setIntegration] = (0, import_react3.useState)(job.integration);
|
|
563
|
+
const [version, setVersion] = (0, import_react3.useState)(job.draftVersion);
|
|
564
|
+
const [tags, setTags] = (0, import_react3.useState)(draft.tags.join("\uFF0C"));
|
|
565
|
+
const [category, setCategory] = (0, import_react3.useState)(draft.category || "\u77E5\u8BC6\u7B14\u8BB0");
|
|
566
|
+
const [busy, setBusy] = (0, import_react3.useState)(false);
|
|
567
|
+
const [error, setError] = (0, import_react3.useState)("");
|
|
568
|
+
async function save(confirm, source) {
|
|
569
|
+
if (busy) return;
|
|
570
|
+
setBusy(true);
|
|
571
|
+
setError("");
|
|
572
|
+
try {
|
|
573
|
+
const edited = await post(`/knowledge/jobs/${job.id}`, { expectedRoot: root, version, draft: { ...draft, category, tags: tags.split(/[,,]/).map((t) => t.trim()).filter(Boolean) }, ...integration ? { integration: { choice: integration.choice, content: integration.content } } : {} }, "PATCH");
|
|
574
|
+
setVersion(edited.draftVersion);
|
|
575
|
+
if (confirm) {
|
|
576
|
+
const result = await post(`/knowledge/jobs/${job.id}/confirm`, { expectedRoot: root, version: edited.draftVersion, category, confirmed: true, integrationChoice: integration?.choice });
|
|
577
|
+
onSaved(result.material.id);
|
|
578
|
+
} else if (source) onOpenSource(source.id, source.segment);
|
|
579
|
+
else {
|
|
580
|
+
onNotify("\u8349\u7A3F\u5DF2\u4FDD\u5B58\uFF0C\u6B63\u5F0F\u77E5\u8BC6\u7B14\u8BB0\u5C1A\u672A\u4FEE\u6539");
|
|
581
|
+
onRefresh();
|
|
582
|
+
}
|
|
583
|
+
} catch (e) {
|
|
584
|
+
setError(e.message);
|
|
585
|
+
} finally {
|
|
586
|
+
setBusy(false);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
const updating = integration?.choice === "append" || integration?.choice === "duplicate";
|
|
590
|
+
const confirmText = integration?.choice === "append" ? "\u786E\u8BA4\u8865\u5145\u5DF2\u6709\u7B14\u8BB0" : integration?.choice === "duplicate" ? "\u786E\u8BA4\u4EC5\u5173\u8054\u6765\u6E90" : "\u786E\u8BA4\u4FDD\u5B58\u7B14\u8BB0";
|
|
591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { className: "kl-knowledge-draft", onSubmit: (e) => {
|
|
592
|
+
e.preventDefault();
|
|
593
|
+
void save(true);
|
|
594
|
+
}, children: [
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-knowledge-model", children: "\u8FD9\u662F\u6A21\u578B\u751F\u6210\u7684\u8349\u7A3F\uFF0C\u8BF7\u6838\u5BF9\u7406\u89E3\u4E0E\u8BC1\u636E\u3002\u4FEE\u6539\u540E\u8BF7\u4FDD\u5B58\u8349\u7A3F\uFF0C\u518D\u5173\u95ED\u7A97\u53E3\u3002" }),
|
|
596
|
+
integration && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "kl-note-integration", "aria-label": "\u5DF2\u6709\u77E5\u8BC6\u5BF9\u6BD4", children: [
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { children: [
|
|
598
|
+
"\u5EFA\u8BAE",
|
|
599
|
+
integration.recommendation === "append" ? "\u8865\u5145\u5DF2\u6709\u7B14\u8BB0" : integration.recommendation === "duplicate" ? "\u4EC5\u5173\u8054\u5DF2\u6709\u7B14\u8BB0" : "\u65B0\u5EFA\u7B14\u8BB0"
|
|
600
|
+
] }),
|
|
601
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: integration.reason }),
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "kl-knowledge-model", children: [
|
|
603
|
+
"\u68C0\u7D22\u4E86 ",
|
|
604
|
+
integration.search.scanned,
|
|
605
|
+
" \u4EFD\u6709\u6548\u7B14\u8BB0\uFF0C\u627E\u5230 ",
|
|
606
|
+
integration.search.matched,
|
|
607
|
+
" \u4EFD\u8BCD\u9762\u76F8\u5173\u7B14\u8BB0\uFF0C\u672C\u6B21\u5B8C\u6574\u5BF9\u6BD4 ",
|
|
608
|
+
integration.search.compared,
|
|
609
|
+
" \u4EFD\uFF08\u6700\u591A 5 \u4EFD\uFF09\u3002",
|
|
610
|
+
integration.search.oversized > 0 && `${integration.search.oversized} \u4EFD\u8D85\u8FC7\u5BF9\u6BD4\u957F\u5EA6\u4E0A\u9650\u3002`,
|
|
611
|
+
"\u672A\u5339\u914D\u4E0D\u4EE3\u8868\u6574\u5E93\u6CA1\u6709\u76F8\u5173\u77E5\u8BC6\u3002"
|
|
612
|
+
] }),
|
|
613
|
+
[["overlaps", "\u91CD\u590D\u5185\u5BB9"], ["additions", "\u65B0\u589E\u77E5\u8BC6"], ["conflicts", "\u5DEE\u5F02\u4E0E\u5F85\u6838\u5B9E"]].map(([key, title]) => !!integration[key].length && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "kl-integration-findings", children: [
|
|
614
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: title }),
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { children: integration[key].map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: item }, index)) })
|
|
616
|
+
] }, key)),
|
|
617
|
+
integration.target && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
618
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "kl-integration-target", children: [
|
|
619
|
+
integration.target.title,
|
|
620
|
+
" \xB7 ",
|
|
621
|
+
integration.target.category,
|
|
622
|
+
" \xB7 \u7248\u672C ",
|
|
623
|
+
integration.target.revision
|
|
624
|
+
] }),
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "kl-knowledge-mode", children: [
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "\u672C\u6B21\u5982\u4F55\u4FDD\u5B58" }),
|
|
627
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
628
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "integration-choice", "aria-label": integration.recommendation === "duplicate" ? "\u4EC5\u5173\u8054\u5DF2\u6709\u7B14\u8BB0" : "\u8865\u5145\u5DF2\u6709\u7B14\u8BB0", checked: updating, onChange: () => setIntegration({ ...integration, choice: integration.recommendation }) }),
|
|
629
|
+
integration.recommendation === "duplicate" ? "\u4EC5\u5173\u8054\u6765\u6E90\uFF0C\u4E0D\u91CD\u590D\u6B63\u6587" : "\u8FFD\u52A0\u8865\u5145\u5230\u5DF2\u6709\u7B14\u8BB0"
|
|
630
|
+
] }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "integration-choice", "aria-label": "\u53E6\u5B58\u4E3A\u65B0\u7B14\u8BB0", checked: !updating, onChange: () => setIntegration({ ...integration, choice: "new" }) }),
|
|
633
|
+
"\u53E6\u5B58\u4E3A\u65B0\u7B14\u8BB0"
|
|
634
|
+
] })
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { children: [
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: "\u67E5\u770B\u5DF2\u6709\u7B14\u8BB0\u539F\u6587" }),
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", { className: "kl-integration-preview", children: integration.target.content }),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: () => void save(false, { id: integration.target.id }), children: [
|
|
640
|
+
"\u4FDD\u5B58\u8349\u7A3F\u5E76\u6253\u5F00\u5DF2\u6709\u7B14\u8BB0",
|
|
641
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "arrow", size: 14 })
|
|
642
|
+
] })
|
|
643
|
+
] })
|
|
644
|
+
] })
|
|
645
|
+
] }),
|
|
646
|
+
updating ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
647
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-knowledge-model", children: "\u786E\u8BA4\u540E\u4FDD\u7559\u5DF2\u6709\u6807\u9898\u3001\u5206\u7C7B\u3001\u6B63\u6587\u4E0E\u65E7\u6BB5\u843D\u5F15\u7528\uFF0C\u5408\u5E76\u65B0\u6765\u6E90\u548C\u6807\u7B7E\u3002\u66F4\u65B0\u524D\u540E\u5FEB\u7167\u4FDD\u5B58\u5728\u672C\u5730\uFF1B\u5BA1\u6838\u671F\u95F4\u7B14\u8BB0\u53D8\u5316\u4F1A\u8981\u6C42\u91CD\u65B0\u6838\u5BF9\u3002" }),
|
|
648
|
+
integration?.choice === "append" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
649
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
650
|
+
"\u672C\u6B21\u65B0\u589E\u6B63\u6587",
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { "aria-label": "\u672C\u6B21\u65B0\u589E\u6B63\u6587", required: true, rows: 12, maxLength: 5e4, value: integration.content, onChange: (e) => setIntegration({ ...integration, content: e.target.value }) })
|
|
652
|
+
] }),
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { children: [
|
|
654
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: "\u66F4\u65B0\u540E\u6B63\u6587\u9884\u89C8" }),
|
|
655
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("pre", { className: "kl-integration-preview", children: [
|
|
656
|
+
integration.target.content,
|
|
657
|
+
"\n\n## \u77E5\u8BC6\u8865\u5145 \xB7 " + (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) + "\n\n" + integration.content
|
|
658
|
+
] })
|
|
659
|
+
] })
|
|
660
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "kl-muted", children: "\u672C\u6B21\u6CA1\u6709\u9700\u8981\u65B0\u589E\u7684\u6B63\u6587\u3002\u786E\u8BA4\u540E\u53EA\u628A\u8FD9\u4E9B\u6765\u6E90\u5173\u8054\u5230\u5DF2\u6709\u7B14\u8BB0\uFF0C\u4ECD\u4FDD\u7559\u5BF9\u6BD4\u7406\u7531\u4F9B\u6838\u67E5\u3002" })
|
|
661
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
663
|
+
"\u7B14\u8BB0\u6807\u9898",
|
|
664
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "\u7B14\u8BB0\u6807\u9898", required: true, maxLength: 300, value: draft.title, onChange: (e) => setDraft({ ...draft, title: e.target.value }) })
|
|
665
|
+
] }),
|
|
666
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
667
|
+
"\u7B14\u8BB0\u6B63\u6587",
|
|
668
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { "aria-label": "\u7B14\u8BB0\u6B63\u6587", required: true, rows: 14, maxLength: 5e4, value: draft.content, onChange: (e) => setDraft({ ...draft, content: e.target.value }) })
|
|
669
|
+
] }),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
671
|
+
"\u7B14\u8BB0\u5206\u7C7B",
|
|
672
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "\u7B14\u8BB0\u5206\u7C7B", value: category, onChange: (e) => setCategory(e.target.value), maxLength: 180 })
|
|
673
|
+
] })
|
|
674
|
+
] }),
|
|
675
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { children: [
|
|
676
|
+
updating ? "\u65B0\u589E\u6807\u7B7E" : "\u6807\u7B7E",
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { "aria-label": "\u7B14\u8BB0\u6807\u7B7E", value: tags, onChange: (e) => setTags(e.target.value), placeholder: "\u9017\u53F7\u5206\u9694" })
|
|
678
|
+
] }),
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "kl-knowledge-citations", children: [
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
|
|
681
|
+
draft.citations.length,
|
|
682
|
+
" \u6761\u6765\u6E90\u5F15\u7528"
|
|
683
|
+
] }),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "\u67E5\u770B\u6765\u6E90\u524D\u4F1A\u5148\u4FDD\u5B58\u5F53\u524D\u8349\u7A3F\u3002" }),
|
|
685
|
+
draft.citations.map((citation, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", disabled: busy, onClick: () => void save(false, { id: citation.materialId, segment: citation.segmentId }), children: [
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "file", size: 14 }),
|
|
687
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
688
|
+
job.sources.find((s) => s.id === citation.materialId)?.title,
|
|
689
|
+
" / ",
|
|
690
|
+
citation.segmentId
|
|
691
|
+
] }),
|
|
692
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "arrow", size: 14 })
|
|
693
|
+
] }, index))
|
|
694
|
+
] }),
|
|
695
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
696
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("footer", { children: [
|
|
697
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: () => void save(false), children: "\u4FDD\u5B58\u8349\u7A3F" }),
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "kl-primary", disabled: busy, children: busy ? "\u6B63\u5728\u4FDD\u5B58\u2026" : confirmText })
|
|
699
|
+
] })
|
|
700
|
+
] });
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// src/ui/ImageCapture.tsx
|
|
704
|
+
var import_react4 = require("react");
|
|
705
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
706
|
+
function ImageSettings({ root }) {
|
|
707
|
+
const [status, setStatus] = (0, import_react4.useState)();
|
|
708
|
+
const [enabled, setEnabled] = (0, import_react4.useState)(false);
|
|
709
|
+
const [limit, setLimit] = (0, import_react4.useState)(6);
|
|
710
|
+
const [confirmed, setConfirmed] = (0, import_react4.useState)(false);
|
|
711
|
+
const [busy, setBusy] = (0, import_react4.useState)(false);
|
|
712
|
+
const [error, setError] = (0, import_react4.useState)("");
|
|
713
|
+
const [saved, setSaved] = (0, import_react4.useState)(false);
|
|
714
|
+
(0, import_react4.useEffect)(() => {
|
|
715
|
+
const abort = new AbortController();
|
|
716
|
+
void api("/settings/images", { signal: abort.signal }).then((value) => {
|
|
717
|
+
setStatus(value);
|
|
718
|
+
setEnabled(value.enabled);
|
|
719
|
+
setLimit(value.maxImages);
|
|
720
|
+
}).catch((e) => {
|
|
721
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
722
|
+
});
|
|
723
|
+
return () => abort.abort();
|
|
724
|
+
}, [root]);
|
|
725
|
+
async function save() {
|
|
726
|
+
if (!status || busy) return;
|
|
727
|
+
setBusy(true);
|
|
728
|
+
setError("");
|
|
729
|
+
setSaved(false);
|
|
730
|
+
try {
|
|
731
|
+
const value = await post("/settings/images", { settings: { enabled, maxImages: limit }, version: status.version, expectedRoot: root, expectedModel: status.currentModel, confirmed });
|
|
732
|
+
setStatus(value);
|
|
733
|
+
setEnabled(value.enabled);
|
|
734
|
+
setLimit(value.maxImages);
|
|
735
|
+
setConfirmed(false);
|
|
736
|
+
setSaved(true);
|
|
737
|
+
} catch (e) {
|
|
738
|
+
setError(e.message);
|
|
739
|
+
} finally {
|
|
740
|
+
setBusy(false);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
const mismatch = status?.enabled && status.model !== status.currentModel;
|
|
744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "kl-image-settings", "aria-label": "\u7F51\u9875\u56FE\u7247\u8BC6\u522B\u8BBE\u7F6E", children: [
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: "\u6B63\u6587\u56FE\u7247\u8BC6\u522B" }),
|
|
746
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "kl-proxy-option", children: [
|
|
747
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "checkbox", checked: enabled, disabled: !status?.supported || busy, onChange: (e) => {
|
|
748
|
+
setEnabled(e.target.checked);
|
|
749
|
+
setConfirmed(false);
|
|
750
|
+
setSaved(false);
|
|
751
|
+
} }),
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "\u91C7\u96C6\u7F51\u9875\u65F6\u81EA\u52A8\u8BC6\u522B\u6B63\u6587\u56FE\u7247" })
|
|
753
|
+
] }),
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "\u5F00\u542F\u540E\uFF0C\u540E\u7EED\u7F51\u9875\u7684\u6B63\u6587\u56FE\u7247\u4F1A\u81EA\u52A8\u53D1\u9001\u7ED9\u5F53\u524D\u89C6\u89C9\u6A21\u578B\uFF0C\u53EF\u80FD\u4EA7\u751F\u6A21\u578B\u8D39\u7528\u3002\u539F\u56FE\u4E0E\u8BC6\u522B\u6587\u5B57\u4FDD\u5B58\u5728\u672C\u5730\uFF0C\u53EF\u641C\u7D22\u3001\u5F15\u7528\u548C\u6574\u7406\u4E3A\u77E5\u8BC6\u7B14\u8BB0\u3002" }),
|
|
755
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "kl-image-model", children: [
|
|
756
|
+
"\u5F53\u524D\u6A21\u578B\uFF1A",
|
|
757
|
+
status?.currentModel || "\u672A\u914D\u7F6E",
|
|
758
|
+
status?.model && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
759
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
|
|
760
|
+
"\u5DF2\u7ED1\u5B9A\u6A21\u578B\uFF1A",
|
|
761
|
+
status.model
|
|
762
|
+
] })
|
|
763
|
+
] }),
|
|
764
|
+
status?.reason && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "kl-muted", children: status.reason }),
|
|
765
|
+
mismatch && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", children: "\u6A21\u578B\u5DF2\u6539\u53D8\uFF0C\u539F\u56FE\u7247\u4EFB\u52A1\u4E0D\u4F1A\u81EA\u52A8\u5207\u6362\u6A21\u578B\u3002\u8BF7\u5207\u56DE\u539F\u6A21\u578B\uFF0C\u6216\u786E\u8BA4\u65B0\u8BBE\u7F6E\u7528\u4E8E\u540E\u7EED\u7F51\u9875\u3002" }),
|
|
766
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "kl-image-limit", children: [
|
|
767
|
+
"\u6BCF\u9875\u6700\u591A\u8BC6\u522B\u56FE\u7247\u6570",
|
|
768
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { "aria-label": "\u6BCF\u9875\u6700\u591A\u8BC6\u522B\u56FE\u7247\u6570", type: "number", min: "1", max: "10", value: limit, disabled: busy || !status?.supported, onChange: (e) => {
|
|
769
|
+
setLimit(Number(e.target.value));
|
|
770
|
+
setConfirmed(false);
|
|
771
|
+
setSaved(false);
|
|
772
|
+
} })
|
|
773
|
+
] }),
|
|
774
|
+
enabled && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "kl-proxy-option", children: [
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "checkbox", checked: confirmed, disabled: busy || !status?.available, onChange: (e) => setConfirmed(e.target.checked) }),
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
777
|
+
"\u786E\u8BA4\u4F7F\u7528 ",
|
|
778
|
+
status?.currentModel || "\u5F53\u524D\u6A21\u578B",
|
|
779
|
+
"\uFF0C\u6BCF\u9875\u6700\u591A ",
|
|
780
|
+
limit,
|
|
781
|
+
" \u5F20\uFF0C\u5141\u8BB8\u540E\u7EED\u91C7\u96C6\u81EA\u52A8\u53D1\u9001\u56FE\u7247\u5E76\u4EA7\u751F\u6A21\u578B\u8D39\u7528"
|
|
782
|
+
] })
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { className: "kl-secondary", disabled: busy || !status?.supported || !Number.isInteger(limit) || limit < 1 || limit > 10 || enabled && (!status?.available || !confirmed), onClick: () => void save(), children: busy ? "\u6B63\u5728\u4FDD\u5B58\u2026" : "\u4FDD\u5B58\u56FE\u7247\u8BC6\u522B\u8BBE\u7F6E" }),
|
|
785
|
+
saved && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "status", children: "\u5DF2\u4FDD\u5B58\uFF0C\u5BF9\u540E\u7EED\u7F51\u9875\u91C7\u96C6\u751F\u6548\uFF1B\u5DF2\u6709\u8D44\u6599\u53EF\u4FDD\u7559\u539F\u6837\u3002" }),
|
|
786
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "kl-form-error", role: "alert", children: error })
|
|
787
|
+
] });
|
|
788
|
+
}
|
|
789
|
+
function ImageCapturePolicy() {
|
|
790
|
+
const [status, setStatus] = (0, import_react4.useState)();
|
|
791
|
+
(0, import_react4.useEffect)(() => {
|
|
792
|
+
const abort = new AbortController();
|
|
793
|
+
void api("/settings/images", { signal: abort.signal }).then(setStatus).catch(() => {
|
|
794
|
+
});
|
|
795
|
+
return () => abort.abort();
|
|
796
|
+
}, []);
|
|
797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "kl-image-policy", children: !status ? "\u6B63\u5728\u8BFB\u53D6\u56FE\u7247\u91C7\u96C6\u8BBE\u7F6E\u2026" : status.enabled ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
798
|
+
"\u56FE\u7247\u8BC6\u522B\u5DF2\u5F00\u542F\uFF1A",
|
|
799
|
+
status.model,
|
|
800
|
+
"\uFF0C\u6BCF\u9875\u6700\u591A ",
|
|
801
|
+
status.maxImages,
|
|
802
|
+
" \u5F20\u3002\u6B63\u6587\u56FE\u7247\u5C06\u53D1\u9001\u7ED9\u6A21\u578B\uFF0C\u53EF\u80FD\u4EA7\u751F\u8D39\u7528\u3002",
|
|
803
|
+
(!status.available || status.model !== status.currentModel) && " \u5F53\u524D\u6A21\u578B\u4E0D\u53EF\u7528\u6216\u4E0E\u7ED1\u5B9A\u6A21\u578B\u4E0D\u540C\uFF0C\u56FE\u7247\u5C06\u4FDD\u7559\u4E3A\u5931\u8D25\u4EFB\u52A1\u4F9B\u6838\u5BF9\u3002"
|
|
804
|
+
] }) : "\u56FE\u7247\u8BC6\u522B\u672A\u5F00\u542F\u3002\u53EF\u5728\u8D44\u6599\u5E93\u8BBE\u7F6E\u4E2D\u542F\u7528\uFF0C\u81EA\u52A8\u4FDD\u5B58\u539F\u56FE\u5E76\u63D0\u53D6\u56FE\u4E2D\u6587\u5B57\u4E0E\u56FE\u793A\u542B\u4E49\u3002" });
|
|
805
|
+
}
|
|
806
|
+
var imageStates = { pending: "\u7B49\u5F85\u5904\u7406", downloading: "\u4E0B\u8F7D\u4E2D", recognizing: "\u8BC6\u522B\u4E2D", completed: "\u5DF2\u8BC6\u522B", failed: "\u672A\u5B8C\u6210", skipped: "\u5DF2\u8DF3\u8FC7" };
|
|
807
|
+
var imagesPending = (detail) => detail.images?.some((image) => ["pending", "downloading", "recognizing"].includes(image.status));
|
|
808
|
+
function PageImages({ detail, onRetry, onJump }) {
|
|
809
|
+
if (!detail.images?.length) return null;
|
|
810
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "kl-page-images", "aria-label": "\u6B63\u6587\u56FE\u7247", children: [
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "kl-image-heading", children: [
|
|
812
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h3", { children: [
|
|
813
|
+
"\u6B63\u6587\u56FE\u7247 \xB7 ",
|
|
814
|
+
detail.images.length
|
|
815
|
+
] }),
|
|
816
|
+
!detail.deletedAt && !imagesPending(detail) && detail.images.some((image) => image.status === "failed" && image.attempts < 3) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { className: "kl-secondary", onClick: onRetry, children: "\u91CD\u8BD5\u5931\u8D25\u56FE\u7247" })
|
|
817
|
+
] }),
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "kl-muted", children: "\u56FE\u7247\u6587\u5B57\u548C\u56FE\u793A\u89E3\u8BFB\u5DF2\u6807\u6CE8\u4E3A\u6A21\u578B\u8F93\u51FA\uFF0C\u8BF7\u7ED3\u5408\u539F\u56FE\u6838\u5BF9\u3002" }),
|
|
819
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "kl-image-grid", children: detail.images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "kl-image-record", children: [
|
|
820
|
+
image.originalAvailable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: `${API}/materials/${detail.id}/images/${image.id}`, target: "_blank", rel: "noreferrer", "aria-label": `\u67E5\u770B\u539F\u56FE ${index + 1}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { loading: "lazy", src: `${API}/materials/${detail.id}/images/${image.id}`, alt: image.alt || `\u6B63\u6587\u56FE\u7247 ${index + 1}` }) }),
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("strong", { children: [
|
|
822
|
+
"\u56FE\u7247 ",
|
|
823
|
+
index + 1,
|
|
824
|
+
" \xB7 ",
|
|
825
|
+
imageStates[image.status]
|
|
826
|
+
] }),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("small", { children: image.model }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: image.url, target: "_blank", rel: "noreferrer", children: "\u6765\u6E90\u56FE\u7247" }),
|
|
829
|
+
image.error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: image.error }),
|
|
830
|
+
image.uncertainty && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { children: [
|
|
831
|
+
"\u5F85\u6838\u5B9E\uFF1A",
|
|
832
|
+
image.uncertainty
|
|
833
|
+
] }),
|
|
834
|
+
image.segmentId && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { className: "kl-secondary", onClick: () => onJump(image.segmentId), children: "\u67E5\u770B\u8BC6\u522B\u6587\u5B57" })
|
|
835
|
+
] }, image.id)) })
|
|
836
|
+
] });
|
|
837
|
+
}
|
|
838
|
+
function ImageRetryDialog({ id, root, onClose, onStarted }) {
|
|
839
|
+
const [detail, setDetail] = (0, import_react4.useState)();
|
|
840
|
+
const [busy, setBusy] = (0, import_react4.useState)(false);
|
|
841
|
+
const [error, setError] = (0, import_react4.useState)("");
|
|
842
|
+
(0, import_react4.useEffect)(() => {
|
|
843
|
+
const abort = new AbortController();
|
|
844
|
+
void api(`/materials/${id}`, { signal: abort.signal }).then(setDetail).catch((e) => {
|
|
845
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
846
|
+
});
|
|
847
|
+
return () => abort.abort();
|
|
848
|
+
}, [id]);
|
|
849
|
+
const eligible = detail?.images?.filter((image) => image.status === "failed" && image.attempts < 3) || [];
|
|
850
|
+
async function retry() {
|
|
851
|
+
if (!eligible.length || busy) return;
|
|
852
|
+
setBusy(true);
|
|
853
|
+
setError("");
|
|
854
|
+
try {
|
|
855
|
+
await post(`/materials/${id}/images/retry`, { expectedRoot: root, expectedModel: eligible[0].model, imageIds: eligible.map((image) => image.id), confirmed: true });
|
|
856
|
+
onStarted();
|
|
857
|
+
} catch (e) {
|
|
858
|
+
setError(e.message);
|
|
859
|
+
} finally {
|
|
860
|
+
setBusy(false);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Dialog, { title: "\u91CD\u8BD5\u5931\u8D25\u56FE\u7247", description: "\u5C06\u518D\u6B21\u53D1\u9001\u4E0B\u5217\u5931\u8D25\u56FE\u7247\u5230\u539F\u4EFB\u52A1\u6A21\u578B\uFF0C\u53EF\u80FD\u4EA7\u751F\u8D39\u7528\u3002\u5DF2\u6210\u529F\u56FE\u7247\u4E0D\u4F1A\u91CD\u590D\u8BC6\u522B\u3002", onClose: () => {
|
|
864
|
+
if (!busy) onClose();
|
|
865
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "kl-delete-dialog", children: [
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: detail ? `${detail.title} \xB7 ${eligible.length} \u5F20\u53EF\u91CD\u8BD5\u56FE\u7247` : "\u6B63\u5728\u6838\u5BF9\u56FE\u7247\u2026" }),
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { children: [
|
|
868
|
+
"\u6A21\u578B\uFF1A",
|
|
869
|
+
eligible[0]?.model || "\u2014",
|
|
870
|
+
"\u3002\u6BCF\u5F20\u56FE\u7247\u6700\u591A\u53D1\u8D77 3 \u6B21\u6A21\u578B\u8BF7\u6C42\u3002"
|
|
871
|
+
] }),
|
|
872
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: eligible.map((image) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { children: [
|
|
873
|
+
image.alt || image.url,
|
|
874
|
+
"\uFF08\u5DF2\u8BF7\u6C42 ",
|
|
875
|
+
image.attempts,
|
|
876
|
+
" \u6B21\uFF09"
|
|
877
|
+
] }, image.id)) }),
|
|
878
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("footer", { children: [
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { className: "kl-primary", disabled: busy || !eligible.length || !!detail && (!!detail.deletedAt || !!imagesPending(detail)), onClick: () => void retry(), children: busy ? "\u6B63\u5728\u63D0\u4EA4\u2026" : `\u786E\u8BA4\u91CD\u8BD5 ${eligible.length} \u5F20\u56FE\u7247` })
|
|
882
|
+
] })
|
|
883
|
+
] }) });
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// src/ui/App.tsx
|
|
887
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
84
888
|
var kinds = {
|
|
85
889
|
web: { label: "\u7F51\u9875", icon: "web" },
|
|
86
890
|
text: { label: "\u6587\u672C", icon: "file" },
|
|
@@ -91,39 +895,42 @@ var kinds = {
|
|
|
91
895
|
};
|
|
92
896
|
var time = (v) => `${String(Math.floor(v / 3600)).padStart(2, "0")}:${String(Math.floor(v / 60) % 60).padStart(2, "0")}:${String(Math.floor(v) % 60).padStart(2, "0")}`;
|
|
93
897
|
var date = (value) => new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit" }).format(new Date(value));
|
|
94
|
-
|
|
95
|
-
const response = await fetch(API + path, { ...options, headers: { "Content-Type": "application/json", "X-Knowledge-Library": "1", ...options.headers } });
|
|
96
|
-
const data = await response.json();
|
|
97
|
-
if (!response.ok) throw new Error(data.error || `\u8BF7\u6C42\u5931\u8D25\uFF1A${response.status}`);
|
|
98
|
-
return data;
|
|
99
|
-
}
|
|
100
|
-
var post = (path, value, method = "POST") => api(path, { method, body: JSON.stringify(value) });
|
|
101
|
-
function splitTags(value) {
|
|
898
|
+
function splitTags2(value) {
|
|
102
899
|
return value.split(/[,,]/).map((v) => v.trim()).filter(Boolean);
|
|
103
900
|
}
|
|
104
901
|
function App() {
|
|
105
|
-
const [stats, setStats] = (0,
|
|
106
|
-
const [items, setItems] = (0,
|
|
107
|
-
const [total, setTotal] = (0,
|
|
108
|
-
const [query, setQuery] = (0,
|
|
109
|
-
const [filter, setFilter] = (0,
|
|
110
|
-
const [selected, setSelected] = (0,
|
|
111
|
-
const [detail, setDetail] = (0,
|
|
112
|
-
const [anchor, setAnchor] = (0,
|
|
113
|
-
const [editor, setEditor] = (0,
|
|
114
|
-
const [
|
|
115
|
-
const [
|
|
116
|
-
const [
|
|
117
|
-
const [
|
|
118
|
-
const [
|
|
119
|
-
const [
|
|
120
|
-
const [
|
|
121
|
-
const [
|
|
122
|
-
const [
|
|
123
|
-
const [
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
902
|
+
const [stats, setStats] = (0, import_react5.useState)();
|
|
903
|
+
const [items, setItems] = (0, import_react5.useState)([]);
|
|
904
|
+
const [total, setTotal] = (0, import_react5.useState)(0);
|
|
905
|
+
const [query, setQuery] = (0, import_react5.useState)("");
|
|
906
|
+
const [filter, setFilter] = (0, import_react5.useState)({});
|
|
907
|
+
const [selected, setSelected] = (0, import_react5.useState)();
|
|
908
|
+
const [detail, setDetail] = (0, import_react5.useState)();
|
|
909
|
+
const [anchor, setAnchor] = (0, import_react5.useState)();
|
|
910
|
+
const [editor, setEditor] = (0, import_react5.useState)();
|
|
911
|
+
const [deletion, setDeletion] = (0, import_react5.useState)();
|
|
912
|
+
const [restoring, setRestoring] = (0, import_react5.useState)();
|
|
913
|
+
const [emptyRoot, setEmptyRoot] = (0, import_react5.useState)();
|
|
914
|
+
const [jobs, setJobs] = (0, import_react5.useState)([]);
|
|
915
|
+
const [knowledge, setKnowledge] = (0, import_react5.useState)();
|
|
916
|
+
const [batchMode, setBatchMode] = (0, import_react5.useState)(false);
|
|
917
|
+
const [checkedIds, setCheckedIds] = (0, import_react5.useState)([]);
|
|
918
|
+
const [generation, setGeneration] = (0, import_react5.useState)();
|
|
919
|
+
const [knowledgeOpen, setKnowledgeOpen] = (0, import_react5.useState)();
|
|
920
|
+
const [showJobs, setShowJobs] = (0, import_react5.useState)(false);
|
|
921
|
+
const [imageRetry, setImageRetry] = (0, import_react5.useState)();
|
|
922
|
+
const [showInfo, setShowInfo] = (0, import_react5.useState)(false);
|
|
923
|
+
const [settingsFromJobs, setSettingsFromJobs] = (0, import_react5.useState)(false);
|
|
924
|
+
const [showNavigation, setShowNavigation] = (0, import_react5.useState)(false);
|
|
925
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
926
|
+
const [toast, setToast] = (0, import_react5.useState)("");
|
|
927
|
+
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
928
|
+
const [detailLoading, setDetailLoading] = (0, import_react5.useState)(false);
|
|
929
|
+
const [revision, setRevision] = (0, import_react5.useState)(0);
|
|
930
|
+
const [limit, setLimit] = (0, import_react5.useState)(40);
|
|
931
|
+
const searchRef = (0, import_react5.useRef)(null);
|
|
932
|
+
const detailRef = (0, import_react5.useRef)(null);
|
|
933
|
+
const refresh = (0, import_react5.useCallback)(() => setRevision((v) => v + 1), []);
|
|
127
934
|
const notify = (message) => setToast(message);
|
|
128
935
|
const chooseFilter = (next) => {
|
|
129
936
|
setFilter(next);
|
|
@@ -132,16 +939,25 @@ function App() {
|
|
|
132
939
|
setAnchor(void 0);
|
|
133
940
|
setDetail(void 0);
|
|
134
941
|
setShowNavigation(false);
|
|
942
|
+
setBatchMode(false);
|
|
943
|
+
setCheckedIds([]);
|
|
135
944
|
};
|
|
136
|
-
const refreshMeta = (0,
|
|
137
|
-
const [s, j] = await Promise.all([api("/stats"), api("/jobs")
|
|
945
|
+
const refreshMeta = (0, import_react5.useCallback)(async () => {
|
|
946
|
+
const [s, j, k] = await Promise.all([api("/stats"), api("/jobs"), api("/knowledge").catch((e) => {
|
|
947
|
+
if (e instanceof ApiError && e.status === 404) return { supported: false, available: false, reason: "\u8BF7\u91CD\u542F\u8D44\u6599\u5E93\u670D\u52A1\u4EE5\u542F\u7528\u77E5\u8BC6\u6574\u7406\u3002", jobs: [], states: {} };
|
|
948
|
+
throw e;
|
|
949
|
+
})]);
|
|
138
950
|
setStats(s);
|
|
139
951
|
setJobs(j);
|
|
952
|
+
setKnowledge(k);
|
|
140
953
|
}, []);
|
|
141
|
-
(0,
|
|
954
|
+
(0, import_react5.useEffect)(() => {
|
|
955
|
+
setCheckedIds([]);
|
|
956
|
+
}, [query]);
|
|
957
|
+
(0, import_react5.useEffect)(() => {
|
|
142
958
|
void refreshMeta().catch((e) => setError(e.message));
|
|
143
959
|
}, [revision, refreshMeta]);
|
|
144
|
-
(0,
|
|
960
|
+
(0, import_react5.useEffect)(() => {
|
|
145
961
|
const controller = new AbortController();
|
|
146
962
|
const timer = setTimeout(() => {
|
|
147
963
|
setLoading(true);
|
|
@@ -161,7 +977,7 @@ function App() {
|
|
|
161
977
|
controller.abort();
|
|
162
978
|
};
|
|
163
979
|
}, [query, filter, revision, limit]);
|
|
164
|
-
(0,
|
|
980
|
+
(0, import_react5.useEffect)(() => {
|
|
165
981
|
if (!selected) {
|
|
166
982
|
setDetail(void 0);
|
|
167
983
|
return;
|
|
@@ -176,23 +992,25 @@ function App() {
|
|
|
176
992
|
});
|
|
177
993
|
return () => controller.abort();
|
|
178
994
|
}, [selected, revision]);
|
|
179
|
-
(0,
|
|
995
|
+
(0, import_react5.useEffect)(() => {
|
|
180
996
|
if (!detail || !anchor) return;
|
|
181
997
|
const element = Array.from(detailRef.current?.querySelectorAll("[data-segment-id]") || []).find((el) => el.dataset.segmentId === anchor);
|
|
182
998
|
element?.scrollIntoView({ block: "center" });
|
|
183
999
|
}, [detail, anchor]);
|
|
184
1000
|
const pending = jobs.filter((j) => ["queued", "running"].includes(j.status)).length;
|
|
185
|
-
|
|
186
|
-
|
|
1001
|
+
const knowledgePending = knowledge?.jobs.filter((j) => ["queued", "running"].includes(j.status)).length || 0;
|
|
1002
|
+
const draftCount = knowledge?.jobs.filter((j) => ["draft", "grouping"].includes(j.status)).length || 0;
|
|
1003
|
+
(0, import_react5.useEffect)(() => {
|
|
1004
|
+
if (!pending && !knowledgePending) return;
|
|
187
1005
|
const interval = setInterval(refresh, 2500);
|
|
188
1006
|
return () => clearInterval(interval);
|
|
189
|
-
}, [pending, refresh]);
|
|
190
|
-
(0,
|
|
1007
|
+
}, [pending, knowledgePending, refresh]);
|
|
1008
|
+
(0, import_react5.useEffect)(() => {
|
|
191
1009
|
if (!toast) return;
|
|
192
1010
|
const timer = setTimeout(() => setToast(""), 3500);
|
|
193
1011
|
return () => clearTimeout(timer);
|
|
194
1012
|
}, [toast]);
|
|
195
|
-
(0,
|
|
1013
|
+
(0, import_react5.useEffect)(() => {
|
|
196
1014
|
const listener = (event) => {
|
|
197
1015
|
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
198
1016
|
event.preventDefault();
|
|
@@ -210,223 +1028,332 @@ function App() {
|
|
|
210
1028
|
setError("\u526A\u8D34\u677F\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4ECE\u8D44\u6599\u8BE6\u60C5\u624B\u52A8\u590D\u5236\u8D44\u6599 ID");
|
|
211
1029
|
}
|
|
212
1030
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
1031
|
+
function askDelete(item) {
|
|
1032
|
+
if (stats) setDeletion({ id: item.id, title: item.title, root: stats.root });
|
|
1033
|
+
}
|
|
1034
|
+
function afterRemoval(id, message) {
|
|
1035
|
+
if (selected === id) {
|
|
1036
|
+
setSelected(void 0);
|
|
1037
|
+
setDetail(void 0);
|
|
1038
|
+
setAnchor(void 0);
|
|
1039
|
+
}
|
|
1040
|
+
refresh();
|
|
1041
|
+
notify(message);
|
|
1042
|
+
searchRef.current?.focus();
|
|
1043
|
+
}
|
|
1044
|
+
async function restoreItem(id) {
|
|
1045
|
+
if (!stats || restoring) return;
|
|
1046
|
+
setRestoring(id);
|
|
1047
|
+
try {
|
|
1048
|
+
await post(`/materials/${id}/restore`, { expectedRoot: stats.root });
|
|
1049
|
+
afterRemoval(id, "\u8D44\u6599\u5DF2\u6062\u590D\u5230\u539F\u5206\u7C7B");
|
|
1050
|
+
} catch (e) {
|
|
1051
|
+
setError(e.message);
|
|
1052
|
+
} finally {
|
|
1053
|
+
setRestoring(void 0);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function openKnowledgeSource(id, segmentId) {
|
|
1057
|
+
setKnowledgeOpen(void 0);
|
|
1058
|
+
chooseFilter({});
|
|
1059
|
+
setQuery("");
|
|
1060
|
+
setSelected(id);
|
|
1061
|
+
setAnchor(segmentId);
|
|
1062
|
+
refresh();
|
|
1063
|
+
}
|
|
1064
|
+
function generateFor(ids, mode) {
|
|
1065
|
+
if (stats) setGeneration({ root: stats.root, sourceIds: ids, mode });
|
|
1066
|
+
}
|
|
1067
|
+
const currentTitle = filter.trashed ? "\u56DE\u6536\u7AD9" : filter.category || filter.collection || (filter.tag ? `\u6807\u7B7E \xB7 ${filter.tag}` : filter.kind === "note" ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u5168\u90E8\u8D44\u6599");
|
|
1068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-app", children: [
|
|
1069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("main", { className: "kl-workspace", children: [
|
|
1070
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { className: "kl-header", children: [
|
|
1071
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: currentTitle }),
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-header-actions", children: [
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-secondary", onClick: () => setEditor({ mode: "note" }), children: [
|
|
1074
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "note", size: 16 }),
|
|
221
1075
|
"\u5199\u7B14\u8BB0"
|
|
222
1076
|
] }),
|
|
223
|
-
/* @__PURE__ */ (0,
|
|
224
|
-
/* @__PURE__ */ (0,
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-primary", onClick: () => setEditor({ mode: "capture" }), children: [
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "plus", size: 16 }),
|
|
225
1079
|
"\u6536\u96C6\u8D44\u6599"
|
|
226
1080
|
] })
|
|
227
1081
|
] })
|
|
228
1082
|
] }),
|
|
229
|
-
/* @__PURE__ */ (0,
|
|
230
|
-
/* @__PURE__ */ (0,
|
|
231
|
-
/* @__PURE__ */ (0,
|
|
232
|
-
/* @__PURE__ */ (0,
|
|
233
|
-
/* @__PURE__ */ (0,
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-navigation", children: [
|
|
1084
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { "aria-label": "\u8D44\u6599\u5BFC\u822A", children: [
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { "aria-pressed": !Object.values(filter).some(Boolean), onClick: () => chooseFilter({}), children: "\u5168\u90E8\u8D44\u6599" }),
|
|
1086
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { "aria-pressed": filter.category === "\u6536\u4EF6\u7BB1", onClick: () => chooseFilter({ category: "\u6536\u4EF6\u7BB1" }), children: "\u6536\u4EF6\u7BB1" }),
|
|
1087
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { "aria-pressed": filter.kind === "note", onClick: () => chooseFilter({ kind: "note" }), children: "\u77E5\u8BC6\u7B14\u8BB0" }),
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { "aria-pressed": filter.trashed === "1", onClick: () => chooseFilter({ trashed: "1" }), children: "\u56DE\u6536\u7AD9" })
|
|
234
1089
|
] }),
|
|
235
|
-
/* @__PURE__ */ (0,
|
|
236
|
-
/* @__PURE__ */ (0,
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-directory-toggle", "aria-expanded": showNavigation, "aria-controls": "kl-directory", onClick: () => setShowNavigation((v) => !v), children: [
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "folder", size: 16 }),
|
|
237
1092
|
"\u5206\u7C7B\u4E0E\u4E13\u9898"
|
|
238
1093
|
] })
|
|
239
1094
|
] }),
|
|
240
|
-
/* @__PURE__ */ (0,
|
|
241
|
-
/* @__PURE__ */ (0,
|
|
242
|
-
/* @__PURE__ */ (0,
|
|
243
|
-
/* @__PURE__ */ (0,
|
|
1095
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-toolbar", children: [
|
|
1096
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "kl-search", children: [
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search", size: 19 }),
|
|
1098
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ref: searchRef, "aria-label": "\u641C\u7D22\u8D44\u6599", placeholder: "\u641C\u7D22\u6B63\u6587\u3001\u6807\u9898\u3001\u6807\u7B7E\u2026", value: query, onChange: (e) => {
|
|
244
1099
|
setQuery(e.target.value);
|
|
245
1100
|
setLimit(40);
|
|
246
1101
|
} }),
|
|
247
|
-
/* @__PURE__ */ (0,
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("kbd", { children: "Ctrl K" })
|
|
1103
|
+
] }),
|
|
1104
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { "aria-label": pending ? `\u91C7\u96C6\u4EFB\u52A1\uFF0C${pending} \u9879\u5904\u7406\u4E2D` : "\u91C7\u96C6\u4EFB\u52A1", className: `kl-job-button ${pending ? "has-jobs" : ""}`, onClick: () => setShowJobs(true), children: [
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "clock", size: 17 }),
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: pending ? `${pending} \u9879\u5904\u7406\u4E2D` : "\u91C7\u96C6\u4EFB\u52A1" }),
|
|
1107
|
+
jobs.some((j) => j.status === "failed") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", {})
|
|
248
1108
|
] }),
|
|
249
|
-
/* @__PURE__ */ (0,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
1109
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { "aria-label": "\u77E5\u8BC6\u6574\u7406", title: "\u77E5\u8BC6\u6574\u7406", className: `kl-job-button ${knowledgePending || draftCount ? "has-jobs" : ""}`, onClick: () => {
|
|
1110
|
+
refresh();
|
|
1111
|
+
if (stats) setKnowledgeOpen({ root: stats.root });
|
|
1112
|
+
}, children: [
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "note", size: 17 }),
|
|
1114
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: draftCount ? `${draftCount} \u4EFD\u5F85\u786E\u8BA4` : "\u77E5\u8BC6\u6574\u7406" }),
|
|
1115
|
+
!!knowledgePending && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-spinner" })
|
|
253
1116
|
] }),
|
|
254
|
-
/* @__PURE__ */ (0,
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-icon-button", "aria-label": "\u8D44\u6599\u5E93\u8BBE\u7F6E", title: "\u8D44\u6599\u5E93\u8BBE\u7F6E", onClick: () => {
|
|
1118
|
+
setSettingsFromJobs(false);
|
|
1119
|
+
setShowInfo(true);
|
|
1120
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "settings", size: 18 }) })
|
|
255
1121
|
] }),
|
|
256
|
-
!!error && /* @__PURE__ */ (0,
|
|
257
|
-
/* @__PURE__ */ (0,
|
|
258
|
-
/* @__PURE__ */ (0,
|
|
1122
|
+
!!error && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-error", role: "alert", children: [
|
|
1123
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: error }),
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { "aria-label": "\u5173\u95ED\u9519\u8BEF", onClick: () => setError(""), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "close", size: 16 }) })
|
|
259
1125
|
] }),
|
|
260
|
-
/* @__PURE__ */ (0,
|
|
261
|
-
/* @__PURE__ */ (0,
|
|
262
|
-
/* @__PURE__ */ (0,
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-filterbar", children: [
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: total }),
|
|
263
1129
|
" \u4EFD\u8D44\u6599",
|
|
264
1130
|
query && ` \xB7 \u201C${query}\u201D`
|
|
265
1131
|
] }),
|
|
266
|
-
/* @__PURE__ */ (0,
|
|
267
|
-
/* @__PURE__ */ (0,
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1133
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "aria-label": "\u6309\u7C7B\u578B\u7B5B\u9009", value: filter.kind || "", onChange: (e) => {
|
|
268
1134
|
setFilter({ ...filter, kind: e.target.value || void 0 });
|
|
269
1135
|
setLimit(40);
|
|
270
1136
|
}, children: [
|
|
271
|
-
/* @__PURE__ */ (0,
|
|
272
|
-
Object.entries(kinds).map(([value, kind]) => /* @__PURE__ */ (0,
|
|
1137
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: "\u6240\u6709\u7C7B\u578B" }),
|
|
1138
|
+
Object.entries(kinds).map(([value, kind]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value, children: kind.label }, value))
|
|
273
1139
|
] }),
|
|
274
|
-
/* @__PURE__ */ (0,
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-sort-label", children: "\u6700\u8FD1\u66F4\u65B0 \u2193" })
|
|
1141
|
+
] })
|
|
1142
|
+
] }),
|
|
1143
|
+
filter.trashed && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-trash-toolbar", children: [
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: stats?.canEmptyTrash ? stats.purgePending ? `${stats.purgePending} \u4EFD\u8D44\u6599\u7684\u6587\u4EF6\u6E05\u7406\u672A\u5B8C\u6210\uFF0C\u53EF\u518D\u6B21\u6E05\u7A7A\u4EE5\u91CD\u8BD5\u3002` : "\u6E05\u7A7A\u5C06\u6C38\u4E45\u5220\u9664\u6574\u4E2A\u56DE\u6536\u7AD9\uFF0C\u4E0D\u53D7\u5F53\u524D\u641C\u7D22\u548C\u7C7B\u578B\u7B5B\u9009\u9650\u5236\u3002" : "\u8BF7\u91CD\u542F\u8D44\u6599\u5E93\u670D\u52A1\u4EE5\u542F\u7528\u6E05\u7A7A\u56DE\u6536\u7AD9\u3002" }),
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-secondary kl-danger", disabled: !stats?.canEmptyTrash || !(stats.trashed || stats.purgePending) || !!restoring, onClick: () => stats && setEmptyRoot(stats.root), children: [
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "trash", size: 15 }),
|
|
1147
|
+
"\u6E05\u7A7A\u56DE\u6536\u7AD9"
|
|
1148
|
+
] })
|
|
1149
|
+
] }),
|
|
1150
|
+
!filter.trashed && filter.kind !== "note" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-knowledge-toolbar", children: [
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: batchMode ? `\u5DF2\u9009\u62E9 ${checkedIds.length} / 10 \u4EFD\u8D44\u6599\uFF1B\u5207\u6362\u641C\u7D22\u6216\u5206\u7C7B\u4F1A\u6E05\u9664\u9009\u62E9\u3002` : knowledge?.smartSupported ? "\u96F6\u6563\u8D44\u6599\u5148\u667A\u80FD\u5206\u7EC4\uFF0C\u518D\u6309\u7EC4\u5F62\u6210\u77E5\u8BC6\u7B14\u8BB0\u3002" : "\u8BF7\u91CD\u542F\u8D44\u6599\u5E93\u670D\u52A1\u4EE5\u542F\u7528\u667A\u80FD\u5206\u7EC4\u3002" }),
|
|
1152
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1153
|
+
batchMode && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-primary", disabled: !checkedIds.length || !knowledge?.smartSupported, onClick: () => generateFor(checkedIds, "smart"), children: "\u667A\u80FD\u5206\u6790\u5206\u7EC4" }),
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: !knowledge?.smartSupported, onClick: () => {
|
|
1155
|
+
setBatchMode(!batchMode);
|
|
1156
|
+
setCheckedIds([]);
|
|
1157
|
+
}, children: batchMode ? "\u53D6\u6D88\u9009\u62E9" : "\u667A\u80FD\u6574\u7406" })
|
|
275
1158
|
] })
|
|
276
1159
|
] }),
|
|
277
|
-
/* @__PURE__ */ (0,
|
|
278
|
-
showNavigation && /* @__PURE__ */ (0,
|
|
279
|
-
/* @__PURE__ */ (0,
|
|
280
|
-
/* @__PURE__ */ (0,
|
|
281
|
-
/* @__PURE__ */ (0,
|
|
1160
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `kl-body ${detail || detailLoading ? "with-detail" : ""}`, children: [
|
|
1161
|
+
showNavigation && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("aside", { className: "kl-nav", id: "kl-directory", "aria-label": "\u5206\u7C7B\u4E0E\u4E13\u9898", children: [
|
|
1162
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-directory-title", children: [
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u5206\u7C7B\u4E0E\u4E13\u9898" }),
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-icon-button", "aria-label": "\u5173\u95ED\u5206\u7C7B\u5BFC\u822A", onClick: () => setShowNavigation(false), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "close", size: 16 }) })
|
|
282
1165
|
] }),
|
|
283
|
-
/* @__PURE__ */ (0,
|
|
284
|
-
/* @__PURE__ */ (0,
|
|
285
|
-
stats?.categories.filter((c) => c.name !== "\u6536\u4EF6\u7BB1").map((c) => /* @__PURE__ */ (0,
|
|
286
|
-
/* @__PURE__ */ (0,
|
|
287
|
-
/* @__PURE__ */ (0,
|
|
288
|
-
/* @__PURE__ */ (0,
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-nav-section", children: [
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-nav-label", children: "\u5206\u7C7B" }),
|
|
1168
|
+
stats?.categories.filter((c) => c.name !== "\u6536\u4EF6\u7BB1").map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { "aria-pressed": filter.category === c.name, className: "kl-nav-row", onClick: () => chooseFilter({ category: c.name }), children: [
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "folder", size: 16 }),
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { title: c.name, children: c.name }),
|
|
1171
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: c.count })
|
|
289
1172
|
] }, c.name)),
|
|
290
|
-
!stats?.categories.some((c) => c.name !== "\u6536\u4EF6\u7BB1") && /* @__PURE__ */ (0,
|
|
1173
|
+
!stats?.categories.some((c) => c.name !== "\u6536\u4EF6\u7BB1") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-nav-hint", children: "\u6536\u96C6\u8D44\u6599\u65F6\u6DFB\u52A0\u5206\u7C7B" })
|
|
291
1174
|
] }),
|
|
292
|
-
/* @__PURE__ */ (0,
|
|
293
|
-
/* @__PURE__ */ (0,
|
|
294
|
-
stats?.collections.map((c) => /* @__PURE__ */ (0,
|
|
295
|
-
/* @__PURE__ */ (0,
|
|
296
|
-
/* @__PURE__ */ (0,
|
|
297
|
-
/* @__PURE__ */ (0,
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-nav-section", children: [
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-nav-label", children: "\u4E13\u9898" }),
|
|
1177
|
+
stats?.collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { "aria-pressed": filter.collection === c.name, className: "kl-nav-row", onClick: () => chooseFilter({ collection: c.name }), children: [
|
|
1178
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-collection-dot" }),
|
|
1179
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { title: c.name, children: c.name }),
|
|
1180
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: c.count })
|
|
298
1181
|
] }, c.name)),
|
|
299
|
-
!stats?.collections.length && /* @__PURE__ */ (0,
|
|
1182
|
+
!stats?.collections.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-nav-hint", children: "\u6536\u96C6\u8D44\u6599\u65F6\u6DFB\u52A0\u4E13\u9898" })
|
|
300
1183
|
] }),
|
|
301
|
-
!!stats?.tags.length && /* @__PURE__ */ (0,
|
|
302
|
-
/* @__PURE__ */ (0,
|
|
303
|
-
/* @__PURE__ */ (0,
|
|
1184
|
+
!!stats?.tags.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-nav-section", children: [
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-nav-label", children: "\u6807\u7B7E" }),
|
|
1186
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-tag-cloud", children: stats.tags.slice(0, 15).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { "aria-pressed": filter.tag === tag.name, onClick: () => chooseFilter({ tag: tag.name }), children: [
|
|
304
1187
|
"#",
|
|
305
1188
|
tag.name
|
|
306
1189
|
] }, tag.name)) })
|
|
307
1190
|
] }),
|
|
308
|
-
/* @__PURE__ */ (0,
|
|
309
|
-
/* @__PURE__ */ (0,
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-nav-bottom", children: [
|
|
1192
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-live-dot" }),
|
|
310
1193
|
"\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111"
|
|
311
1194
|
] })
|
|
312
1195
|
] }),
|
|
313
|
-
/* @__PURE__ */ (0,
|
|
314
|
-
loading && !items.length ? /* @__PURE__ */ (0,
|
|
315
|
-
/* @__PURE__ */ (0,
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "kl-list", "aria-label": "\u8D44\u6599\u5217\u8868", "aria-busy": loading, children: [
|
|
1197
|
+
loading && !items.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-empty", children: [
|
|
1198
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-spinner" }),
|
|
316
1199
|
"\u6B63\u5728\u8BFB\u53D6\u8D44\u6599\u5E93\u2026"
|
|
317
|
-
] }) : !items.length ? /* @__PURE__ */ (0,
|
|
318
|
-
/* @__PURE__ */ (0,
|
|
319
|
-
/* @__PURE__ */ (0,
|
|
320
|
-
query && /* @__PURE__ */ (0,
|
|
321
|
-
/* @__PURE__ */ (0,
|
|
322
|
-
] }) : items.map((item) => /* @__PURE__ */ (0,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
1200
|
+
] }) : !items.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-empty", children: [
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: filter.trashed ? "trash" : "inbox", size: 28 }),
|
|
1202
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: filter.trashed ? "\u56DE\u6536\u7AD9\u4E2D\u6CA1\u6709\u5339\u914D\u7684\u8D44\u6599" : query || Object.values(filter).some(Boolean) ? "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8D44\u6599" : "\u8FD8\u6CA1\u6709\u8D44\u6599\uFF0C\u6536\u96C6\u7684\u5185\u5BB9\u4F1A\u663E\u793A\u5728\u8FD9\u91CC" }),
|
|
1203
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "\u8BD5\u8BD5\u5176\u4ED6\u5173\u952E\u8BCD\uFF0C\u6216\u5207\u6362\u5206\u7C7B\u3002" }),
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", onClick: () => query || Object.values(filter).some(Boolean) ? (setQuery(""), chooseFilter({})) : setEditor({ mode: "capture" }), children: query || Object.values(filter).some(Boolean) ? "\u67E5\u770B\u5168\u90E8\u8D44\u6599" : "\u6536\u96C6\u7B2C\u4E00\u4EFD\u8D44\u6599" })
|
|
1205
|
+
] }) : items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `kl-item-row ${batchMode ? "kl-selectable" : ""}`, children: [
|
|
1206
|
+
batchMode && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "checkbox", className: "kl-material-checkbox", "aria-label": `\u9009\u62E9 ${item.title}`, checked: checkedIds.includes(item.id), disabled: item.kind === "note" || item.status !== "ready" || !!checkedIds.length && checkedIds.length >= 10 && !checkedIds.includes(item.id), onChange: (e) => setCheckedIds((ids) => e.target.checked ? [...ids, item.id] : ids.filter((id) => id !== item.id)) }),
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: `kl-item ${selected === item.id ? "selected" : ""}`, onClick: () => {
|
|
1208
|
+
setAnchor(void 0);
|
|
1209
|
+
setSelected(item.id);
|
|
1210
|
+
}, children: [
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-item-top", children: [
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: `kl-type kl-type-${item.kind}`, children: [
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: kinds[item.kind].icon, size: 15 }),
|
|
1214
|
+
kinds[item.kind].label
|
|
1215
|
+
] }),
|
|
1216
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { children: date(item.createdAt) })
|
|
330
1217
|
] }),
|
|
331
|
-
/* @__PURE__ */ (0,
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: item.title }),
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: item.excerpt || item.extraction }),
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-item-bottom", children: [
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "kl-category", children: [
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "folder", size: 13 }),
|
|
1223
|
+
item.category
|
|
1224
|
+
] }),
|
|
1225
|
+
item.tags.slice(0, 2).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-chip", children: tag }, tag)),
|
|
1226
|
+
item.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-stored", children: "\u4EC5\u5F52\u6863" }),
|
|
1227
|
+
!item.deletedAt && item.kind !== "note" && item.status === "ready" && knowledge?.supported && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KnowledgeBadge, { state: knowledge.states[item.id] }),
|
|
1228
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 15 })
|
|
1229
|
+
] })
|
|
332
1230
|
] }),
|
|
333
|
-
/* @__PURE__ */ (0,
|
|
334
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: item.excerpt || item.extraction }),
|
|
335
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-item-bottom", children: [
|
|
336
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "kl-category", children: [
|
|
337
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "folder", size: 13 }),
|
|
338
|
-
item.category
|
|
339
|
-
] }),
|
|
340
|
-
item.tags.slice(0, 2).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-chip", children: tag }, tag)),
|
|
341
|
-
item.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-stored", children: "\u4EC5\u5F52\u6863" }),
|
|
342
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 15 })
|
|
343
|
-
] })
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: `kl-icon-button kl-row-action ${item.deletedAt ? "" : "kl-danger"}`, title: item.deletedAt ? "\u6062\u590D\u8D44\u6599" : "\u5220\u9664\u8D44\u6599", "aria-label": `${item.deletedAt ? "\u6062\u590D" : "\u5220\u9664"} ${item.title}`, disabled: !stats || !!restoring, onClick: () => item.deletedAt ? void restoreItem(item.id) : askDelete(item), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: item.deletedAt ? "restore" : "trash", size: 16 }) })
|
|
344
1232
|
] }, item.id)),
|
|
345
|
-
items.length < total && /* @__PURE__ */ (0,
|
|
1233
|
+
items.length < total && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-load-more", onClick: () => setLimit((v) => Math.min(100, v + 40)), disabled: limit >= 100, children: limit >= 100 ? "\u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4\uFF08\u6700\u591A\u663E\u793A 100 \u6761\uFF09" : "\u52A0\u8F7D\u66F4\u591A" })
|
|
346
1234
|
] }),
|
|
347
|
-
selected && /* @__PURE__ */ (0,
|
|
348
|
-
/* @__PURE__ */ (0,
|
|
349
|
-
/* @__PURE__ */ (0,
|
|
1235
|
+
selected && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "kl-detail", "aria-label": "\u8D44\u6599\u8BE6\u60C5", ref: detailRef, children: [
|
|
1236
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-detail-toolbar", children: [
|
|
1237
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-back", onClick: () => {
|
|
350
1238
|
setSelected(void 0);
|
|
351
1239
|
setDetail(void 0);
|
|
352
1240
|
}, children: [
|
|
353
|
-
/* @__PURE__ */ (0,
|
|
354
|
-
/* @__PURE__ */ (0,
|
|
1241
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "close", size: 18 }),
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u5173\u95ED\u9605\u8BFB" })
|
|
355
1243
|
] }),
|
|
356
|
-
detail && /* @__PURE__ */ (0,
|
|
357
|
-
/* @__PURE__ */ (0,
|
|
358
|
-
/* @__PURE__ */ (0,
|
|
359
|
-
/* @__PURE__ */ (0,
|
|
1244
|
+
detail && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { title: "\u590D\u5236\u8D44\u6599\u5F15\u7528", "aria-label": "\u590D\u5236\u8D44\u6599\u5F15\u7528", onClick: () => void copy(`library://${detail.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "copy", size: 17 }) }),
|
|
1246
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { title: "\u5BFC\u51FA Markdown", "aria-label": "\u5BFC\u51FA Markdown", href: `${API}/materials/${detail.id}/export`, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "download", size: 17 }) }),
|
|
1247
|
+
detail.deletedAt ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { disabled: !stats || !!restoring, onClick: () => void restoreItem(detail.id), children: [
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "restore", size: 16 }),
|
|
1249
|
+
"\u6062\u590D\u8D44\u6599"
|
|
1250
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1251
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => setEditor({ mode: "edit", source: detail }), children: "\u7F16\u8F91\u4FE1\u606F" }),
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-danger", title: "\u5220\u9664\u8D44\u6599", "aria-label": "\u5220\u9664\u8D44\u6599", disabled: !stats || !!restoring, onClick: () => askDelete(detail), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "trash", size: 17 }) })
|
|
1253
|
+
] })
|
|
360
1254
|
] })
|
|
361
1255
|
] }),
|
|
362
|
-
detailLoading ? /* @__PURE__ */ (0,
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
1256
|
+
detailLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-empty", children: [
|
|
1257
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-spinner" }),
|
|
364
1258
|
"\u8BFB\u53D6\u4E2D\u2026"
|
|
365
|
-
] }) : detail && /* @__PURE__ */ (0,
|
|
366
|
-
/* @__PURE__ */ (0,
|
|
367
|
-
/* @__PURE__ */ (0,
|
|
368
|
-
/* @__PURE__ */ (0,
|
|
1259
|
+
] }) : detail && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { children: [
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-detail-kicker", children: [
|
|
1261
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: kinds[detail.kind].label }),
|
|
1262
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: detail.category })
|
|
369
1263
|
] }),
|
|
370
|
-
/* @__PURE__ */ (0,
|
|
371
|
-
/* @__PURE__ */ (0,
|
|
372
|
-
detail.sourceUrl ? /* @__PURE__ */ (0,
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: detail.title }),
|
|
1265
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-source", children: [
|
|
1266
|
+
detail.sourceUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { href: detail.sourceUrl, target: "_blank", rel: "noreferrer", children: [
|
|
373
1267
|
new URL(detail.sourceUrl).hostname,
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
375
|
-
] }) : /* @__PURE__ */ (0,
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
377
|
-
detail.author && /* @__PURE__ */ (0,
|
|
1268
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 12 })
|
|
1269
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: detail.originalName || "\u672C\u5730\u6536\u96C6" }),
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: new Date(detail.createdAt).toLocaleDateString("zh-CN") }),
|
|
1271
|
+
detail.author && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: detail.author })
|
|
378
1272
|
] }),
|
|
379
|
-
!!detail.tags.length && /* @__PURE__ */ (0,
|
|
1273
|
+
!!detail.tags.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-detail-tags", children: detail.tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "kl-chip", children: [
|
|
380
1274
|
"#",
|
|
381
1275
|
t
|
|
382
1276
|
] }, t)) }),
|
|
383
|
-
detail.sourceNote && /* @__PURE__ */ (0,
|
|
384
|
-
detail.
|
|
385
|
-
/* @__PURE__ */ (0,
|
|
386
|
-
/* @__PURE__ */ (0,
|
|
387
|
-
/* @__PURE__ */ (0,
|
|
388
|
-
/* @__PURE__ */ (0,
|
|
1277
|
+
detail.sourceNote && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("aside", { className: "kl-source-note", children: detail.sourceNote }),
|
|
1278
|
+
detail.deletedAt && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-notice", children: [
|
|
1279
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "trash" }),
|
|
1280
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1281
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "\u8FD9\u4EFD\u8D44\u6599\u5728\u56DE\u6536\u7AD9" }),
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "\u539F\u6587\u4E0E\u6765\u6E90\u5F15\u7528\u4ECD\u53EF\u67E5\u770B\uFF0C\u6062\u590D\u540E\u56DE\u5230\u539F\u5206\u7C7B\u3002" })
|
|
1283
|
+
] })
|
|
1284
|
+
] }),
|
|
1285
|
+
detail.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-notice", children: [
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "file" }),
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "\u539F\u6587\u4EF6\u5DF2\u5B89\u5168\u5F52\u6863" }),
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: detail.extraction })
|
|
389
1290
|
] })
|
|
390
1291
|
] }),
|
|
391
|
-
|
|
392
|
-
/* @__PURE__ */ (0,
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
394
|
-
/* @__PURE__ */ (0,
|
|
395
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { title: "\u590D\u5236\u6BB5\u843D\u5F15\u7528", "aria-label": `\u590D\u5236 ${segment.id} \u5F15\u7528`, onClick: () => void copy(`library://${detail.id}/${segment.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "copy", size: 14 }) })
|
|
1292
|
+
!detail.deletedAt && detail.kind !== "note" && detail.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-knowledge-source", children: [
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1294
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KnowledgeBadge, { state: knowledge?.states[detail.id] }),
|
|
1295
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4ECE\u8FD9\u4EFD\u8D44\u6599\u5F62\u6210\u7406\u89E3\u3001\u65B9\u6CD5\u4E0E\u5F85\u9A8C\u8BC1\u7684\u95EE\u9898\u3002" })
|
|
396
1296
|
] }),
|
|
397
|
-
|
|
1297
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-knowledge-actions", children: [
|
|
1298
|
+
["running", "draft", "grouping"].includes(knowledge?.states[detail.id]?.status || "") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", onClick: () => stats && setKnowledgeOpen({ root: stats.root, jobId: knowledge?.states[detail.id]?.jobId }), children: knowledge?.states[detail.id]?.status === "grouping" ? "\u67E5\u770B\u5206\u7EC4\u65B9\u6848" : "\u67E5\u770B\u6574\u7406\u4EFB\u52A1" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: !knowledge?.supported || imagesPending(detail), onClick: () => generateFor([detail.id]), children: "\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0" }),
|
|
1299
|
+
knowledge?.states[detail.id]?.noteIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-secondary", onClick: () => openKnowledgeSource(id), children: [
|
|
1300
|
+
"\u67E5\u770B\u77E5\u8BC6\u7B14\u8BB0",
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 14 })
|
|
1302
|
+
] }, id))
|
|
1303
|
+
] }),
|
|
1304
|
+
!knowledge?.supported && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u8BF7\u91CD\u542F\u8D44\u6599\u5E93\u670D\u52A1\u4EE5\u542F\u7528\u77E5\u8BC6\u6574\u7406\u3002" })
|
|
1305
|
+
] }),
|
|
1306
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PageImages, { detail, onRetry: () => stats && setImageRetry({ id: detail.id, root: stats.root }), onJump: setAnchor }),
|
|
1307
|
+
imagesPending(detail) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-image-policy", children: "\u6B63\u6587\u5DF2\u4FDD\u5B58\uFF0C\u56FE\u7247\u4ECD\u5728\u5904\u7406\u4E2D\u3002\u56FE\u7247\u5904\u7406\u7ED3\u675F\u6216\u505C\u6B62\u540E\u53EF\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0\u3002" }),
|
|
1308
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-content", children: detail.segments.map((segment) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `kl-segment ${anchor === segment.id ? "kl-cited" : ""}`, id: segment.id, "data-segment-id": segment.id, children: [
|
|
1309
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-segment-line", children: [
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: segment.startSeconds !== void 0 ? time(segment.startSeconds) : segment.id }),
|
|
1311
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { title: "\u6458\u5F55\u4E3A\u7B14\u8BB0", "aria-label": `\u6458\u5F55 ${segment.id} \u4E3A\u7B14\u8BB0`, onClick: () => setEditor({ mode: "note", source: detail, segment }), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "note", size: 14 }) }),
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { title: "\u590D\u5236\u6BB5\u843D\u5F15\u7528", "aria-label": `\u590D\u5236 ${segment.id} \u5F15\u7528`, onClick: () => void copy(`library://${detail.id}/${segment.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "copy", size: 14 }) })
|
|
1313
|
+
] }),
|
|
1314
|
+
/^#{1,6}\s/.test(segment.text) ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: segment.text.replace(/^#{1,6}\s+/, "") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: segment.text })
|
|
398
1315
|
] }, segment.id)) }),
|
|
399
|
-
!!detail.citations.length && /* @__PURE__ */ (0,
|
|
400
|
-
/* @__PURE__ */ (0,
|
|
401
|
-
detail.citations.map((c, i) => /* @__PURE__ */ (0,
|
|
1316
|
+
!!detail.citations.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-references", children: [
|
|
1317
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: "\u6765\u6E90\u5F15\u7528" }),
|
|
1318
|
+
detail.citations.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { disabled: detail.missingSources?.includes(c.materialId), "aria-label": `\u67E5\u770B\u5F15\u7528 ${i + 1}`, onClick: () => {
|
|
402
1319
|
setAnchor(c.segmentId);
|
|
403
1320
|
setSelected(c.materialId);
|
|
404
1321
|
}, children: [
|
|
405
|
-
/* @__PURE__ */ (0,
|
|
406
|
-
/* @__PURE__ */ (0,
|
|
407
|
-
|
|
408
|
-
"\u2026",
|
|
409
|
-
c.segmentId ? ` / ${c.segmentId}` : ""
|
|
410
|
-
] }),
|
|
411
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 14 })
|
|
1322
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "file", size: 15 }),
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: detail.missingSources?.includes(c.materialId) ? "\u6765\u6E90\u5DF2\u6C38\u4E45\u5220\u9664" : `${c.materialId.slice(0, 15)}\u2026${c.segmentId ? ` / ${c.segmentId}` : ""}` }),
|
|
1324
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 14 })
|
|
412
1325
|
] }, i))
|
|
413
1326
|
] }),
|
|
414
|
-
/* @__PURE__ */ (0,
|
|
415
|
-
/* @__PURE__ */ (0,
|
|
416
|
-
/* @__PURE__ */ (0,
|
|
1327
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { className: "kl-detail-footer", children: [
|
|
1328
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1329
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-live-dot" }),
|
|
417
1330
|
detail.extraction
|
|
418
1331
|
] }),
|
|
419
|
-
detail.originalFile && /* @__PURE__ */ (0,
|
|
1332
|
+
detail.originalFile && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { href: `${API}/materials/${detail.id}/original`, children: [
|
|
420
1333
|
"\u4E0B\u8F7D\u539F\u59CB\u6587\u4EF6",
|
|
421
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "download", size: 14 })
|
|
422
1335
|
] }),
|
|
423
|
-
/* @__PURE__ */ (0,
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("code", { children: detail.id })
|
|
424
1337
|
] })
|
|
425
1338
|
] })
|
|
426
1339
|
] })
|
|
427
1340
|
] })
|
|
428
1341
|
] }),
|
|
429
|
-
|
|
1342
|
+
generation && knowledge && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StartKnowledgeDialog, { root: generation.root, sourceIds: generation.sourceIds, model: knowledge, initialMode: generation.mode, onClose: () => setGeneration(void 0), onCreated: (job) => {
|
|
1343
|
+
setGeneration(void 0);
|
|
1344
|
+
setCheckedIds([]);
|
|
1345
|
+
setBatchMode(false);
|
|
1346
|
+
setKnowledgeOpen({ root: generation.root, jobId: job.id });
|
|
1347
|
+
refresh();
|
|
1348
|
+
} }),
|
|
1349
|
+
knowledgeOpen && knowledge && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(KnowledgeJobsDialog, { root: knowledgeOpen.root, jobId: knowledgeOpen.jobId, overview: knowledge, onClose: () => setKnowledgeOpen(void 0), onRefresh: refresh, onRegenerate: (ids, mode) => {
|
|
1350
|
+
setKnowledgeOpen(void 0);
|
|
1351
|
+
generateFor(ids, mode);
|
|
1352
|
+
}, onOpenSource: openKnowledgeSource, onSaved: (id) => {
|
|
1353
|
+
openKnowledgeSource(id);
|
|
1354
|
+
notify("\u77E5\u8BC6\u7B14\u8BB0\u5DF2\u4FDD\u5B58\uFF0C\u539F\u59CB\u8D44\u6599\u5DF2\u4FDD\u7559");
|
|
1355
|
+
}, onNotify: notify }),
|
|
1356
|
+
editor && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EditorDialog, { editor, categories: stats?.categories.map((c) => c.name) || [], onClose: () => setEditor(void 0), onSaved: (result) => {
|
|
430
1357
|
setEditor(void 0);
|
|
431
1358
|
refresh();
|
|
432
1359
|
if (result.material) {
|
|
@@ -442,107 +1369,380 @@ function App() {
|
|
|
442
1369
|
notify("\u7F51\u9875\u5DF2\u52A0\u5165\u91C7\u96C6\u961F\u5217");
|
|
443
1370
|
}
|
|
444
1371
|
} }),
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
1372
|
+
deletion && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DeleteDialog, { item: deletion, onClose: () => setDeletion(void 0), onDeleted: () => {
|
|
1373
|
+
setDeletion(void 0);
|
|
1374
|
+
afterRemoval(deletion.id, "\u8D44\u6599\u5DF2\u79FB\u5165\u56DE\u6536\u7AD9\uFF0C\u53EF\u968F\u65F6\u6062\u590D");
|
|
1375
|
+
} }),
|
|
1376
|
+
emptyRoot && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyTrashDialog, { root: emptyRoot, onClose: () => setEmptyRoot(void 0), onEmptied: (result) => {
|
|
1377
|
+
setEmptyRoot(void 0);
|
|
1378
|
+
setSelected(void 0);
|
|
1379
|
+
setDetail(void 0);
|
|
1380
|
+
setAnchor(void 0);
|
|
1381
|
+
setError("");
|
|
1382
|
+
refresh();
|
|
1383
|
+
if (result.errors.length || result.pending) setError(`\u5DF2\u6C38\u4E45\u5220\u9664 ${result.deleted} \u4EFD\u8D44\u6599\uFF1B${result.pending} \u4EFD\u6587\u4EF6\u5F85\u6E05\u7406\u3002${result.errors.join("\uFF1B")}`);
|
|
1384
|
+
else notify(`\u56DE\u6536\u7AD9\u5DF2\u6E05\u7A7A\uFF0C\u6C38\u4E45\u5220\u9664 ${result.deleted} \u4EFD\u8D44\u6599`);
|
|
1385
|
+
searchRef.current?.focus();
|
|
1386
|
+
} }),
|
|
1387
|
+
imageRetry && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ImageRetryDialog, { ...imageRetry, onClose: () => setImageRetry(void 0), onStarted: () => {
|
|
1388
|
+
setImageRetry(void 0);
|
|
1389
|
+
refresh();
|
|
1390
|
+
notify("\u5931\u8D25\u56FE\u7247\u5DF2\u52A0\u5165\u91CD\u8BD5\u961F\u5217");
|
|
1391
|
+
} }),
|
|
1392
|
+
showJobs && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog, { title: "\u91C7\u96C6\u4EFB\u52A1", description: "\u7F51\u9875\u5728\u540E\u53F0\u63D0\u53D6\u6B63\u6587\u548C\u5DF2\u542F\u7528\u7684\u56FE\u7247\u3002\u56FE\u7247\u8BC6\u522B\u4E2D\u65AD\u540E\u9700\u4E3B\u52A8\u91CD\u8BD5\uFF0C\u4E0D\u4F1A\u5728\u91CD\u542F\u65F6\u81EA\u52A8\u91CD\u590D\u6A21\u578B\u8BF7\u6C42\u3002", onClose: () => setShowJobs(false), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-jobs", children: !jobs.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u8FD8\u6CA1\u6709\u91C7\u96C6\u4EFB\u52A1\u3002\u6DFB\u52A0\u4E00\u4E2A\u7F51\u9875\u94FE\u63A5\u5F00\u59CB\u3002" }) : jobs.map((job) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-job", children: [
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `kl-job-status ${job.status}`, children: job.status === "failed" && job.errorCode === "PAGE_REQUIRES_BROWSER" ? "\u9700\u6D4F\u89C8\u5668\u9A8C\u8BC1" : { queued: "\u6392\u961F\u4E2D", running: "\u63D0\u53D6\u4E2D", completed: "\u5DF2\u5B8C\u6210", failed: "\u5931\u8D25" }[job.status] }),
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { children: date(job.createdAt) })
|
|
449
1396
|
] }),
|
|
450
|
-
/* @__PURE__ */ (0,
|
|
451
|
-
job.
|
|
452
|
-
/* @__PURE__ */ (0,
|
|
453
|
-
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: job.url }),
|
|
1398
|
+
job.progress && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: job.progress }),
|
|
1399
|
+
job.imageSummary && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { children: [
|
|
1400
|
+
"\u56FE\u7247\uFF1A",
|
|
1401
|
+
job.imageSummary.completed,
|
|
1402
|
+
" \u5F20\u5DF2\u8BC6\u522B \xB7 ",
|
|
1403
|
+
job.imageSummary.failed,
|
|
1404
|
+
" \u5F20\u672A\u5B8C\u6210 \xB7 ",
|
|
1405
|
+
job.imageSummary.skipped,
|
|
1406
|
+
" \u5F20\u8DF3\u8FC7"
|
|
1407
|
+
] }),
|
|
1408
|
+
job.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: job.status === "failed" ? "alert" : void 0, children: job.error }),
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-job-actions", children: [
|
|
1410
|
+
job.materialId && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { onClick: () => {
|
|
454
1411
|
setSelected(job.materialId);
|
|
455
1412
|
setShowJobs(false);
|
|
456
1413
|
refresh();
|
|
457
1414
|
}, children: [
|
|
458
1415
|
"\u67E5\u770B\u8D44\u6599 ",
|
|
459
|
-
/* @__PURE__ */ (0,
|
|
1416
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 14 })
|
|
460
1417
|
] }),
|
|
461
|
-
job.
|
|
1418
|
+
job.materialId && job.imageCapture && ["queued", "running"].includes(job.status) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => void post(`/jobs/${job.id}/images/cancel`, { expectedRoot: stats?.root }).then(refresh).catch((e) => setError(e.message)), children: "\u505C\u6B62\u56FE\u7247\u5904\u7406" }),
|
|
1419
|
+
job.materialId && job.status === "completed" && !!job.imageSummary?.failed && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => {
|
|
1420
|
+
if (stats) {
|
|
1421
|
+
setShowJobs(false);
|
|
1422
|
+
setImageRetry({ id: job.materialId, root: stats.root });
|
|
1423
|
+
}
|
|
1424
|
+
}, children: "\u91CD\u8BD5\u5931\u8D25\u56FE\u7247" }),
|
|
1425
|
+
job.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1426
|
+
/^https?:\/\//i.test(job.url) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { href: job.url, target: "_blank", rel: "noopener noreferrer", children: [
|
|
1427
|
+
"\u6253\u5F00\u539F\u7F51\u9875",
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 14 })
|
|
1429
|
+
] }),
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => {
|
|
1431
|
+
setShowJobs(false);
|
|
1432
|
+
setEditor({ mode: "capture", initialType: "text", sourceUrl: job.url });
|
|
1433
|
+
}, children: "\u7C98\u8D34\u6B63\u6587" }),
|
|
1434
|
+
/fake-ip/i.test(job.error || "") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => {
|
|
1435
|
+
setShowJobs(false);
|
|
1436
|
+
setSettingsFromJobs(true);
|
|
1437
|
+
setShowInfo(true);
|
|
1438
|
+
}, children: "\u4EE3\u7406\u517C\u5BB9\u8BBE\u7F6E" }),
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: () => void post(`/jobs/${job.id}/retry`, {}).then(refresh).catch((e) => setError(e.message)), children: "\u91CD\u65B0\u91C7\u96C6" })
|
|
1440
|
+
] })
|
|
462
1441
|
] })
|
|
463
1442
|
] }, job.id)) }) }),
|
|
464
|
-
showInfo && /* @__PURE__ */ (0,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
1443
|
+
showInfo && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SettingsDialog, { root: stats?.root || "", warnings: stats?.warnings || [], onClose: () => {
|
|
1444
|
+
setShowInfo(false);
|
|
1445
|
+
if (settingsFromJobs) setShowJobs(true);
|
|
1446
|
+
setSettingsFromJobs(false);
|
|
1447
|
+
}, onChanged: () => {
|
|
1448
|
+
setSelected(void 0);
|
|
1449
|
+
setDetail(void 0);
|
|
1450
|
+
setAnchor(void 0);
|
|
1451
|
+
setItems([]);
|
|
1452
|
+
setQuery("");
|
|
1453
|
+
chooseFilter({});
|
|
1454
|
+
refresh();
|
|
1455
|
+
notify("\u8D44\u6599\u5E93\u76EE\u5F55\u5DF2\u5207\u6362");
|
|
1456
|
+
}, onRebuilt: () => {
|
|
1457
|
+
refresh();
|
|
1458
|
+
notify("\u7D22\u5F15\u5DF2\u91CD\u5EFA");
|
|
1459
|
+
}, onProxySaved: (enabled) => {
|
|
1460
|
+
refresh();
|
|
1461
|
+
notify(enabled ? "\u4EE3\u7406\u517C\u5BB9\u5DF2\u5F00\u542F\uFF0C\u53EF\u91CD\u65B0\u91C7\u96C6\u5931\u8D25\u4EFB\u52A1" : "\u4EE3\u7406\u517C\u5BB9\u5DF2\u5173\u95ED");
|
|
1462
|
+
if (settingsFromJobs) {
|
|
1463
|
+
setShowInfo(false);
|
|
1464
|
+
setShowJobs(true);
|
|
1465
|
+
setSettingsFromJobs(false);
|
|
1466
|
+
}
|
|
1467
|
+
} }),
|
|
1468
|
+
toast && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-toast", role: "status", children: [
|
|
1469
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "check", size: 17 }),
|
|
477
1470
|
toast
|
|
478
1471
|
] })
|
|
479
1472
|
] });
|
|
480
1473
|
}
|
|
481
|
-
function
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
1474
|
+
function DeleteDialog({ item, onClose, onDeleted }) {
|
|
1475
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
1476
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1477
|
+
async function remove() {
|
|
1478
|
+
setBusy(true);
|
|
1479
|
+
setError("");
|
|
1480
|
+
try {
|
|
1481
|
+
await post(`/materials/${item.id}`, { expectedRoot: item.root }, "DELETE");
|
|
1482
|
+
onDeleted();
|
|
1483
|
+
} catch (e) {
|
|
1484
|
+
setError(e.message);
|
|
1485
|
+
} finally {
|
|
1486
|
+
setBusy(false);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog, { title: "\u5220\u9664\u8D44\u6599", description: "\u8D44\u6599\u5C06\u79FB\u5165\u56DE\u6536\u7AD9\uFF0C\u539F\u6587\u4EF6\u4FDD\u7559\uFF0C\u53EF\u968F\u65F6\u6062\u590D\u3002", onClose: () => {
|
|
1490
|
+
if (!busy) onClose();
|
|
1491
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-delete-dialog", children: [
|
|
1492
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-delete-title", children: item.title }),
|
|
1493
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u5DF2\u6709\u7B14\u8BB0\u4ECD\u80FD\u67E5\u770B\u8FD9\u4EFD\u8D44\u6599\u7684\u6765\u6E90\u5F15\u7528\u3002" }),
|
|
1494
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-form-error", role: "alert", children: error }),
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { children: [
|
|
1496
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
1497
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary kl-danger", disabled: busy, onClick: () => void remove(), children: busy ? "\u6B63\u5728\u5220\u9664\u2026" : "\u79FB\u5165\u56DE\u6536\u7AD9" })
|
|
1498
|
+
] })
|
|
1499
|
+
] }) });
|
|
1500
|
+
}
|
|
1501
|
+
function EmptyTrashDialog({ root, onClose, onEmptied }) {
|
|
1502
|
+
const [snapshot, setSnapshot] = (0, import_react5.useState)();
|
|
1503
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
1504
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1505
|
+
(0, import_react5.useEffect)(() => {
|
|
1506
|
+
const abort = new AbortController();
|
|
1507
|
+
void api("/trash", { signal: abort.signal }).then(setSnapshot).catch((e) => {
|
|
1508
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
1509
|
+
});
|
|
1510
|
+
return () => abort.abort();
|
|
1511
|
+
}, []);
|
|
1512
|
+
async function empty() {
|
|
1513
|
+
if (!snapshot || busy) return;
|
|
1514
|
+
setBusy(true);
|
|
1515
|
+
setError("");
|
|
1516
|
+
try {
|
|
1517
|
+
onEmptied(await post("/trash/empty", { expectedRoot: root, confirmed: true, token: snapshot.token }));
|
|
1518
|
+
} catch (e) {
|
|
1519
|
+
setError(e.message);
|
|
1520
|
+
setSnapshot(void 0);
|
|
1521
|
+
} finally {
|
|
1522
|
+
setBusy(false);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog, { title: "\u6E05\u7A7A\u56DE\u6536\u7AD9", description: "\u6C38\u4E45\u5220\u9664\u540E\u65E0\u6CD5\u6062\u590D\uFF0C\u8BF7\u786E\u8BA4\u6574\u4E2A\u56DE\u6536\u7AD9\u5185\u7684\u8D44\u6599\u90FD\u4E0D\u518D\u9700\u8981\u3002", onClose: () => {
|
|
1526
|
+
if (!busy) onClose();
|
|
1527
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-delete-dialog", children: [
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-delete-title", children: snapshot ? `\u5C06\u6C38\u4E45\u5220\u9664\u56DE\u6536\u7AD9\u4E2D\u7684\u5168\u90E8 ${snapshot.count} \u4EFD\u8D44\u6599\u3002` : error ? "\u8BF7\u5173\u95ED\u7A97\u53E3\u540E\u91CD\u65B0\u786E\u8BA4\u3002" : "\u6B63\u5728\u6838\u5BF9\u56DE\u6536\u7AD9\u2026" }),
|
|
1529
|
+
!!snapshot?.pending && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { children: [
|
|
1530
|
+
"\u53E6\u6709 ",
|
|
1531
|
+
snapshot.pending,
|
|
1532
|
+
" \u4EFD\u5DF2\u786E\u8BA4\u5220\u9664\u7684\u6587\u4EF6\u5C06\u7EE7\u7EED\u6E05\u7406\u3002"
|
|
1533
|
+
] }),
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u6B63\u6587\u3001\u539F\u59CB\u9644\u4EF6\u548C\u7D22\u5F15\u5C06\u88AB\u79FB\u9664\u3002\u76F8\u5173\u7B14\u8BB0\u7684\u6B63\u6587\u4F1A\u4FDD\u7559\uFF0C\u5F15\u7528\u8FD9\u4E9B\u8D44\u6599\u7684\u4F4D\u7F6E\u5C06\u6807\u8BB0\u4E3A\u201C\u6765\u6E90\u5DF2\u6C38\u4E45\u5220\u9664\u201D\u3002" }),
|
|
1535
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", className: "kl-form-error", children: error }),
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { children: [
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
1538
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary kl-danger", disabled: busy || !snapshot || !(snapshot.count || snapshot.pending), onClick: () => void empty(), children: busy ? "\u6B63\u5728\u6C38\u4E45\u5220\u9664\u2026" : "\u6C38\u4E45\u6E05\u7A7A" })
|
|
1539
|
+
] })
|
|
1540
|
+
] }) });
|
|
1541
|
+
}
|
|
1542
|
+
function SettingsDialog({ root, warnings, onClose, onChanged, onRebuilt, onProxySaved }) {
|
|
1543
|
+
const [settings, setSettings] = (0, import_react5.useState)();
|
|
1544
|
+
const [proxyMode, setProxyMode] = (0, import_react5.useState)(false);
|
|
1545
|
+
const [target, setTarget] = (0, import_react5.useState)(root);
|
|
1546
|
+
const [listing, setListing] = (0, import_react5.useState)();
|
|
1547
|
+
const [browsePath, setBrowsePath] = (0, import_react5.useState)("");
|
|
1548
|
+
const [browsing, setBrowsing] = (0, import_react5.useState)(false);
|
|
1549
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
1550
|
+
const [saving, setSaving] = (0, import_react5.useState)(false);
|
|
1551
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1552
|
+
const request = (0, import_react5.useRef)();
|
|
1553
|
+
(0, import_react5.useEffect)(() => {
|
|
1554
|
+
const abort = new AbortController();
|
|
1555
|
+
void api("/settings", { signal: abort.signal }).then((data) => {
|
|
1556
|
+
setSettings(data);
|
|
1557
|
+
setProxyMode(data.allowProxyFakeIp === true);
|
|
1558
|
+
}).catch((e) => {
|
|
1559
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
1560
|
+
});
|
|
504
1561
|
return () => {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
previous?.focus();
|
|
1562
|
+
abort.abort();
|
|
1563
|
+
request.current?.abort();
|
|
508
1564
|
};
|
|
509
1565
|
}, []);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
},
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
1566
|
+
(0, import_react5.useEffect)(() => {
|
|
1567
|
+
setTarget(root);
|
|
1568
|
+
}, [root]);
|
|
1569
|
+
async function browse(path) {
|
|
1570
|
+
request.current?.abort();
|
|
1571
|
+
const abort = new AbortController();
|
|
1572
|
+
request.current = abort;
|
|
1573
|
+
setBusy(true);
|
|
1574
|
+
setError("");
|
|
1575
|
+
setListing(void 0);
|
|
1576
|
+
try {
|
|
1577
|
+
const result = await post("/directory/list", { path }, "POST", abort.signal);
|
|
1578
|
+
setListing(result);
|
|
1579
|
+
setBrowsePath(result.path);
|
|
1580
|
+
} catch (e) {
|
|
1581
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
1582
|
+
} finally {
|
|
1583
|
+
if (!abort.signal.aborted) setBusy(false);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
async function pick() {
|
|
1587
|
+
if (settings?.picker === "browse") {
|
|
1588
|
+
setBrowsing(true);
|
|
1589
|
+
setListing(void 0);
|
|
1590
|
+
setBrowsePath(target);
|
|
1591
|
+
await browse(target || void 0);
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
setBusy(true);
|
|
1595
|
+
setError("");
|
|
1596
|
+
const abort = new AbortController();
|
|
1597
|
+
request.current = abort;
|
|
1598
|
+
try {
|
|
1599
|
+
const result = await post("/directory/pick", {}, "POST", abort.signal);
|
|
1600
|
+
if (result.path) setTarget(result.path);
|
|
1601
|
+
} catch (e) {
|
|
1602
|
+
if (!abort.signal.aborted) setError(e.message);
|
|
1603
|
+
} finally {
|
|
1604
|
+
if (!abort.signal.aborted) setBusy(false);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
async function change() {
|
|
1608
|
+
setSaving(true);
|
|
1609
|
+
setError("");
|
|
1610
|
+
try {
|
|
1611
|
+
const result = await post("/settings/root", { root: target.trim(), expectedRoot: root });
|
|
1612
|
+
setTarget(result.root);
|
|
1613
|
+
onChanged();
|
|
1614
|
+
} catch (e) {
|
|
1615
|
+
setError(e.message);
|
|
1616
|
+
} finally {
|
|
1617
|
+
setSaving(false);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
async function saveProxyMode() {
|
|
1621
|
+
if (!settings) return;
|
|
1622
|
+
setSaving(true);
|
|
1623
|
+
setError("");
|
|
1624
|
+
try {
|
|
1625
|
+
const result = await post("/settings/network", { allowProxyFakeIp: proxyMode, expected: settings.allowProxyFakeIp, expectedRoot: root });
|
|
1626
|
+
setSettings({ ...settings, allowProxyFakeIp: result.allowProxyFakeIp });
|
|
1627
|
+
setProxyMode(result.allowProxyFakeIp);
|
|
1628
|
+
onProxySaved(result.allowProxyFakeIp);
|
|
1629
|
+
} catch (e) {
|
|
1630
|
+
setError(e.message);
|
|
1631
|
+
} finally {
|
|
1632
|
+
setSaving(false);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
const changed = target.trim() && target.trim() !== root;
|
|
1636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog, { title: "\u4F60\u7684\u8D44\u6599\uFF0C\u7531\u4F60\u4FDD\u7BA1", description: "\u5185\u5BB9\u4EE5\u666E\u901A\u6587\u4EF6\u4FDD\u5B58\uFF0C\u7D22\u5F15\u53EF\u4EE5\u91CD\u5EFA\u3002", onClose: () => {
|
|
1637
|
+
if (!saving) onClose();
|
|
1638
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-info", children: [
|
|
1639
|
+
browsing ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-folder-browser", "aria-label": "\u9009\u62E9\u8D44\u6599\u5E93\u76EE\u5F55", children: [
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-folder-heading", children: [
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "\u9009\u62E9\u8D44\u6599\u5E93\u76EE\u5F55" }),
|
|
1642
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: busy, onClick: () => void browse(), children: "\u4E3B\u76EE\u5F55" })
|
|
517
1643
|
] }),
|
|
518
|
-
/* @__PURE__ */ (0,
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "kl-folder-path", onSubmit: (e) => {
|
|
1645
|
+
e.preventDefault();
|
|
1646
|
+
void browse(browsePath);
|
|
1647
|
+
}, children: [
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "\u6D4F\u89C8\u76EE\u5F55\u8DEF\u5F84", value: browsePath, onChange: (e) => setBrowsePath(e.target.value) }),
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: busy || !browsePath.trim(), children: "\u524D\u5F80" })
|
|
1650
|
+
] }),
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("nav", { className: "kl-folder-crumbs", "aria-label": "\u76EE\u5F55\u5C42\u7EA7", children: listing?.crumbs.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { disabled: busy, onClick: () => void browse(c.path), children: [
|
|
1652
|
+
c.name,
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "/" })
|
|
1654
|
+
] }, c.path)) }),
|
|
1655
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-folder-entries", "aria-busy": busy, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026" }) : listing && !listing.entries.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u6B64\u76EE\u5F55\u6CA1\u6709\u5B50\u6587\u4EF6\u5939" }) : listing?.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { onClick: () => void browse(entry.path), children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "folder", size: 17 }),
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: entry.name }),
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 15 })
|
|
1659
|
+
] }, entry.path)) }),
|
|
1660
|
+
listing?.truncated && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u5B50\u76EE\u5F55\u8F83\u591A\uFF0C\u4EC5\u663E\u793A\u90E8\u5206\u3002\u53EF\u586B\u5199\u5B8C\u6574\u8DEF\u5F84\u524D\u5F80\u3002" }),
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-folder-actions", children: [
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", onClick: () => {
|
|
1663
|
+
request.current?.abort();
|
|
1664
|
+
setBusy(false);
|
|
1665
|
+
setBrowsing(false);
|
|
1666
|
+
setError("");
|
|
1667
|
+
}, children: "\u53D6\u6D88\u9009\u62E9" }),
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-primary", disabled: busy || !listing, onClick: () => {
|
|
1669
|
+
setTarget(listing.path);
|
|
1670
|
+
setBrowsing(false);
|
|
1671
|
+
setError("");
|
|
1672
|
+
}, children: "\u9009\u62E9\u6B64\u76EE\u5F55" })
|
|
1673
|
+
] })
|
|
1674
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "kl-library-root", children: "\u8D44\u6599\u5E93\u76EE\u5F55" }),
|
|
1676
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-root-field", children: [
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { id: "kl-library-root", value: target, title: target, spellCheck: false, readOnly: !settings?.canChange, disabled: saving || busy, onChange: (e) => setTarget(e.target.value) }),
|
|
1678
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-secondary", disabled: !settings?.canChange || !settings.picker || busy || saving, onClick: () => void pick(), children: [
|
|
1679
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "folder", size: 16 }),
|
|
1680
|
+
busy ? "\u9009\u62E9\u4E2D\u2026" : "\u9009\u62E9\u76EE\u5F55"
|
|
1681
|
+
] })
|
|
1682
|
+
] }),
|
|
1683
|
+
settings && !settings.canChange && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u8BF7\u5728 Harness \u4E2D\u9009\u62E9\u548C\u5207\u6362\u76EE\u5F55\uFF1B\u72EC\u7ACB\u9884\u89C8\u53EF\u901A\u8FC7\u542F\u52A8\u914D\u7F6E\u6307\u5B9A\u76EE\u5F55\u3002" }),
|
|
1684
|
+
!!changed && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-root-confirm", children: [
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "\u5207\u6362\u540E\u5C06\u8BFB\u53D6\u65B0\u76EE\u5F55\uFF0C\u5E76\u5C06\u540E\u7EED\u8D44\u6599\u4FDD\u5B58\u5230\u90A3\u91CC\u3002\u539F\u76EE\u5F55\u7684\u8D44\u6599\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u642C\u8FC1\u3002" }),
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: saving || busy, onClick: () => {
|
|
1688
|
+
setTarget(root);
|
|
1689
|
+
setError("");
|
|
1690
|
+
}, children: "\u53D6\u6D88\u4FEE\u6539" }),
|
|
1691
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-primary", disabled: saving || busy, onClick: () => void change(), children: saving ? "\u6B63\u5728\u5207\u6362\u2026" : "\u5207\u6362\u8D44\u6599\u5E93" })
|
|
1692
|
+
] })
|
|
1693
|
+
] }),
|
|
1694
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "kl-network-settings", "aria-label": "\u7F51\u9875\u91C7\u96C6\u8BBE\u7F6E", children: [
|
|
1695
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: "\u7F51\u9875\u91C7\u96C6" }),
|
|
1696
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "kl-proxy-option", children: [
|
|
1697
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "checkbox", "aria-describedby": "kl-proxy-help", checked: proxyMode, disabled: !settings?.canChangeNetwork || saving || busy, onChange: (e) => {
|
|
1698
|
+
setProxyMode(e.target.checked);
|
|
1699
|
+
setError("");
|
|
1700
|
+
} }),
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Clash/Mihomo \u4EE3\u7406\u517C\u5BB9\uFF08fake-IP\uFF09" })
|
|
1702
|
+
] }),
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { id: "kl-proxy-help", children: "\u672C\u673A\u4F7F\u7528 Clash/Mihomo TUN \u7684 fake-IP DNS \u65F6\u5F00\u542F\uFF0C\u5141\u8BB8\u901A\u8FC7\u4EE3\u7406\u91C7\u96C6\u89E3\u6790\u5230 198.18.* \u6216 198.19.* \u7684\u7F51\u7AD9\u3002\u672C\u673A\u53CA\u5176\u4ED6\u5185\u7F51\u5730\u5740\u4ECD\u4E0D\u5141\u8BB8\u8BBF\u95EE\u3002" }),
|
|
1704
|
+
settings?.canChangeNetwork && !settings.canChange && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u6B64\u8BBE\u7F6E\u7528\u4E8E\u5F53\u524D\u8D44\u6599\u5E93\u7684\u72EC\u7ACB\u9884\u89C8\uFF0C\u4FDD\u5B58\u540E\u5BF9\u540E\u7EED\u91C7\u96C6\u751F\u6548\u3002" }),
|
|
1705
|
+
settings && !settings.canChangeNetwork && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-muted", children: "\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u4FDD\u5B58\u91C7\u96C6\u8BBE\u7F6E\u3002" }),
|
|
1706
|
+
settings?.canChangeNetwork && proxyMode !== settings.allowProxyFakeIp && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: saving || busy, onClick: () => void saveProxyMode(), children: saving ? "\u6B63\u5728\u4FDD\u5B58\u2026" : "\u4FDD\u5B58\u91C7\u96C6\u8BBE\u7F6E" })
|
|
1707
|
+
] }),
|
|
1708
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ImageSettings, { root }, root),
|
|
1709
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "\u6BCF\u4EFD\u8D44\u6599\u4FDD\u7559\u539F\u59CB\u6587\u4EF6\u3001\u6B63\u6587\u3001\u5143\u6570\u636E\u548C\u5F15\u7528\u6BB5\u843D\u3002\u5206\u7C7B\u5BF9\u5E94\u672C\u5730\u6587\u4EF6\u5939\uFF0C\u63D2\u4EF6\u5378\u8F7D\u4E0D\u4F1A\u5220\u9664\u8FD9\u4E9B\u6587\u4EF6\u3002" }),
|
|
1710
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "\u652F\u6301\u7F51\u9875\u6B63\u6587\u56FE\u7247\u8BC6\u522B\uFF1B\u97F3\u89C6\u9891\u3001PDF \u7B49\u683C\u5F0F\u53EF\u4EE5\u5F52\u6863\uFF0C\u81EA\u52A8\u8F6C\u5199\u548C\u6587\u4EF6 OCR \u5C1A\u672A\u63A5\u5165\u3002" }),
|
|
1711
|
+
warnings.map((w) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", children: w }, w)),
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "kl-secondary", disabled: busy || saving, onClick: () => {
|
|
1713
|
+
setSaving(true);
|
|
1714
|
+
setError("");
|
|
1715
|
+
void post("/rebuild", {}).then(onRebuilt).catch((e) => setError(e.message)).finally(() => setSaving(false));
|
|
1716
|
+
}, children: "\u4ECE\u8D44\u6599\u6587\u4EF6\u91CD\u5EFA\u7D22\u5F15" })
|
|
519
1717
|
] }),
|
|
520
|
-
children
|
|
1718
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "kl-settings-error", role: "alert", children: error })
|
|
521
1719
|
] }) });
|
|
522
1720
|
}
|
|
523
1721
|
function EditorDialog({ editor, categories, onClose, onSaved }) {
|
|
524
1722
|
const editing = editor.mode === "edit";
|
|
525
1723
|
const note = editor.mode === "note";
|
|
526
1724
|
const source = editor.source;
|
|
527
|
-
const [type, setType] = (0,
|
|
528
|
-
const [
|
|
529
|
-
const [
|
|
1725
|
+
const [type, setType] = (0, import_react5.useState)(editor.initialType || "url");
|
|
1726
|
+
const [sourceUrl, setSourceUrl] = (0, import_react5.useState)(editor.sourceUrl || "");
|
|
1727
|
+
const [title, setTitle] = (0, import_react5.useState)(editing ? source?.title || "" : note && source ? `${source.title} \xB7 \u6458\u5F55` : "");
|
|
1728
|
+
const [content, setContent] = (0, import_react5.useState)(editor.segment ? `> ${editor.segment.text}
|
|
530
1729
|
|
|
531
1730
|
` : "");
|
|
532
|
-
const [category, setCategory] = (0,
|
|
533
|
-
const [tags, setTags] = (0,
|
|
534
|
-
const [collection, setCollection] = (0,
|
|
535
|
-
const [sourceNote, setSourceNote] = (0,
|
|
536
|
-
const [file, setFile] = (0,
|
|
537
|
-
const [busy, setBusy] = (0,
|
|
538
|
-
const [error, setError] = (0,
|
|
1731
|
+
const [category, setCategory] = (0, import_react5.useState)(editing ? source?.category || "\u6536\u4EF6\u7BB1" : note ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u6536\u4EF6\u7BB1");
|
|
1732
|
+
const [tags, setTags] = (0, import_react5.useState)(editing ? source?.tags.join("\uFF0C") || "" : "");
|
|
1733
|
+
const [collection, setCollection] = (0, import_react5.useState)(source?.collection || "");
|
|
1734
|
+
const [sourceNote, setSourceNote] = (0, import_react5.useState)(editing ? source?.sourceNote || "" : "");
|
|
1735
|
+
const [file, setFile] = (0, import_react5.useState)();
|
|
1736
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
1737
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
539
1738
|
const citations = source && note ? [{ materialId: source.id, ...editor.segment ? { segmentId: editor.segment.id } : {} }] : [];
|
|
540
1739
|
async function submit(event) {
|
|
541
1740
|
event.preventDefault();
|
|
542
1741
|
setError("");
|
|
543
1742
|
setBusy(true);
|
|
544
1743
|
try {
|
|
545
|
-
const data = { title, category, tags:
|
|
1744
|
+
const data = { title, category, tags: splitTags2(tags), collection, sourceNote };
|
|
1745
|
+
if (!editing && !note && type === "text" && sourceUrl.trim()) data.sourceUrl = sourceUrl.trim();
|
|
546
1746
|
let result;
|
|
547
1747
|
if (editing) result = await post(`/materials/${source.id}`, data, "PATCH");
|
|
548
1748
|
else if (note) result = await post("/notes", { ...data, content, citations });
|
|
@@ -569,74 +1769,81 @@ function EditorDialog({ editor, categories, onClose, onSaved }) {
|
|
|
569
1769
|
setContent("");
|
|
570
1770
|
setError("");
|
|
571
1771
|
};
|
|
572
|
-
return /* @__PURE__ */ (0,
|
|
1772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog, { title: editing ? "\u6574\u7406\u8D44\u6599" : note ? "\u5199\u4E00\u4EFD\u77E5\u8BC6\u7B14\u8BB0" : "\u6536\u96C6\u4E00\u4EFD\u8D44\u6599", description: editing ? "\u5206\u7C7B\u4F1A\u540C\u6B65\u5230\u672C\u5730\u6587\u4EF6\u5939\uFF0C\u539F\u6587\u548C\u5F15\u7528\u4FDD\u6301\u4E0D\u53D8\u3002" : note ? "\u5199\u4E0B\u7406\u89E3\uFF0C\u4E5F\u7559\u4E0B\u5B83\u7684\u6765\u6E90\u3002" : "\u5148\u6536\u96C6\uFF0C\u518D\u6162\u6162\u6574\u7406\u3002\u6240\u6709\u5185\u5BB9\u4FDD\u5B58\u5728\u4F60\u7684\u7535\u8111\u3002", onClose: () => {
|
|
573
1773
|
if (!busy) onClose();
|
|
574
|
-
}, children: /* @__PURE__ */ (0,
|
|
575
|
-
!editing && !note && /* @__PURE__ */ (0,
|
|
576
|
-
/* @__PURE__ */ (0,
|
|
1774
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: submit, className: "kl-editor", children: [
|
|
1775
|
+
!editing && !note && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-tabs", role: "tablist", "aria-label": "\u91C7\u96C6\u65B9\u5F0F", children: ["url", "text", "file"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", role: "tab", "aria-selected": type === value, className: type === value ? "active" : "", onClick: () => changeType(value), children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: value === "url" ? "web" : value === "file" ? "upload" : "file", size: 17 }),
|
|
577
1777
|
value === "url" ? "\u7F51\u9875\u94FE\u63A5" : value === "file" ? "\u672C\u5730\u6587\u4EF6" : "\u6587\u672C\u6458\u5F55"
|
|
578
1778
|
] }, value)) }),
|
|
579
|
-
!editing && !note && type === "url" && /* @__PURE__ */ (0,
|
|
1779
|
+
!editing && !note && type === "url" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
580
1780
|
"\u7F51\u9875\u5730\u5740",
|
|
581
|
-
/* @__PURE__ */ (0,
|
|
582
|
-
/* @__PURE__ */ (0,
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "url", required: true, placeholder: "https://\u2026", value: content, onChange: (e) => setContent(e.target.value) }),
|
|
1782
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: "\u652F\u6301\u53EF\u76F4\u63A5\u8BBF\u95EE\u7684\u6587\u7AE0\u7F51\u9875\u3002\u767B\u5F55\u9875\u6216\u52A8\u6001\u9875\u9762\u53EF\u590D\u5236\u6B63\u6587\u5BFC\u5165\u3002" })
|
|
583
1783
|
] }),
|
|
584
|
-
!editing && !note && type === "
|
|
585
|
-
|
|
586
|
-
/* @__PURE__ */ (0,
|
|
587
|
-
/* @__PURE__ */ (0,
|
|
588
|
-
/* @__PURE__ */ (0,
|
|
589
|
-
/* @__PURE__ */ (0,
|
|
1784
|
+
!editing && !note && type === "url" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ImageCapturePolicy, {}),
|
|
1785
|
+
!editing && !note && type === "file" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "kl-upload", children: [
|
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "upload", size: 27 }),
|
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: file?.name || "\u9009\u62E9\u6216\u62D6\u5165\u6587\u4EF6" }),
|
|
1788
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6587\u672C\u3001HTML\u3001SRT / VTT \u5B57\u5E55\u53CA\u5176\u4ED6\u6587\u4EF6 \xB7 \u6700\u5927 64 MB" }),
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { "aria-label": "\u9009\u62E9\u672C\u5730\u6587\u4EF6", type: "file", onChange: (e) => setFile(e.target.files?.[0]) }),
|
|
1790
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: "\u89C6\u9891\u548C PDF \u53EF\u5F52\u6863\uFF0C\u5F53\u524D\u7248\u672C\u4E0D\u4F1A\u81EA\u52A8\u8F6C\u5199\u6216 OCR\u3002" })
|
|
590
1791
|
] }),
|
|
591
|
-
/* @__PURE__ */ (0,
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
592
1793
|
"\u6807\u9898",
|
|
593
|
-
!editing && !note && /* @__PURE__ */ (0,
|
|
594
|
-
/* @__PURE__ */ (0,
|
|
1794
|
+
!editing && !note && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: "\u53EF\u9009" }),
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { required: editing || note, value: title, onChange: (e) => setTitle(e.target.value), placeholder: type === "url" && !note ? "\u81EA\u52A8\u63D0\u53D6\u7F51\u9875\u6807\u9898\uFF0C\u4E5F\u53EF\u4EE5\u81EA\u5DF1\u586B\u5199" : "\u7ED9\u8FD9\u4EFD\u5185\u5BB9\u8D77\u4E2A\u540D\u5B57", maxLength: 300 })
|
|
595
1796
|
] }),
|
|
596
|
-
!editing && (note || type === "text") && /* @__PURE__ */ (0,
|
|
1797
|
+
!editing && (note || type === "text") && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
597
1798
|
note ? "\u7B14\u8BB0\u5185\u5BB9" : "\u6B63\u6587",
|
|
598
|
-
/* @__PURE__ */ (0,
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("textarea", { required: true, rows: 7, value: content, onChange: (e) => setContent(e.target.value), placeholder: note ? "\u8BB0\u5F55\u4F60\u7684\u7406\u89E3\u3001\u7ED3\u8BBA\u4E0E\u5C1A\u5F85\u9A8C\u8BC1\u7684\u95EE\u9898\u2026" : "\u7C98\u8D34\u60F3\u4FDD\u7559\u7684\u6587\u5B57\uFF0C\u652F\u6301 Markdown\u2026" })
|
|
1800
|
+
] }),
|
|
1801
|
+
!editing && !note && type === "text" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
1802
|
+
"\u6765\u6E90\u7F51\u9875",
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: "\u53EF\u9009" }),
|
|
1804
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "url", "aria-label": "\u6765\u6E90\u7F51\u9875", placeholder: "https://\u2026", value: sourceUrl, onChange: (e) => setSourceUrl(e.target.value) }),
|
|
1805
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { children: "\u4FDD\u7559\u539F\u7F51\u9875\u5730\u5740\uFF0C\u65B9\u4FBF\u56DE\u6EAF\u6765\u6E90\u3002" })
|
|
599
1806
|
] }),
|
|
600
|
-
!!citations.length && /* @__PURE__ */ (0,
|
|
601
|
-
/* @__PURE__ */ (0,
|
|
602
|
-
/* @__PURE__ */ (0,
|
|
1807
|
+
!!citations.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-citation-preview", children: [
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "file", size: 16 }),
|
|
1809
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
603
1810
|
"\u5F15\u7528\uFF1A",
|
|
604
1811
|
source.title,
|
|
605
1812
|
editor.segment ? ` / ${editor.segment.id}` : ""
|
|
606
1813
|
] })
|
|
607
1814
|
] }),
|
|
608
|
-
/* @__PURE__ */ (0,
|
|
609
|
-
/* @__PURE__ */ (0,
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "kl-form-grid", children: [
|
|
1816
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
610
1817
|
"\u5206\u7C7B",
|
|
611
|
-
/* @__PURE__ */ (0,
|
|
612
|
-
/* @__PURE__ */ (0,
|
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { list: "kl-categories", value: category, onChange: (e) => setCategory(e.target.value), placeholder: "\u4F8B\u5982 \u6280\u672F/AI" }),
|
|
1819
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("datalist", { id: "kl-categories", children: categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: c }, c)) })
|
|
613
1820
|
] }),
|
|
614
|
-
/* @__PURE__ */ (0,
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
615
1822
|
"\u4E13\u9898",
|
|
616
|
-
/* @__PURE__ */ (0,
|
|
617
|
-
/* @__PURE__ */ (0,
|
|
1823
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: "\u53EF\u9009" }),
|
|
1824
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: collection, onChange: (e) => setCollection(e.target.value), placeholder: "\u56F4\u7ED5\u4E00\u4E2A\u95EE\u9898\u7EC4\u7EC7\u8D44\u6599" })
|
|
618
1825
|
] })
|
|
619
1826
|
] }),
|
|
620
|
-
/* @__PURE__ */ (0,
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
621
1828
|
"\u6807\u7B7E",
|
|
622
|
-
/* @__PURE__ */ (0,
|
|
623
|
-
/* @__PURE__ */ (0,
|
|
1829
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: "\u53EF\u9009" }),
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: tags, onChange: (e) => setTags(e.target.value), placeholder: "\u7528\u9017\u53F7\u5206\u9694\uFF0C\u4F8B\u5982\uFF1A\u5F85\u8BFB\uFF0CRAG\uFF0C\u5B9E\u8DF5" })
|
|
624
1831
|
] }),
|
|
625
|
-
/* @__PURE__ */ (0,
|
|
1832
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
|
|
626
1833
|
"\u6765\u6E90\u5907\u6CE8",
|
|
627
|
-
/* @__PURE__ */ (0,
|
|
628
|
-
/* @__PURE__ */ (0,
|
|
1834
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("em", { children: "\u53EF\u9009" }),
|
|
1835
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: sourceNote, onChange: (e) => setSourceNote(e.target.value), placeholder: "\u4E3A\u4EC0\u4E48\u503C\u5F97\u4FDD\u5B58\uFF0C\u6216\u8005\u5B83\u6765\u81EA\u54EA\u91CC" })
|
|
629
1836
|
] }),
|
|
630
|
-
error && /* @__PURE__ */ (0,
|
|
631
|
-
/* @__PURE__ */ (0,
|
|
632
|
-
/* @__PURE__ */ (0,
|
|
633
|
-
/* @__PURE__ */ (0,
|
|
634
|
-
"\u4EC5\u4FDD\u5B58\u5728\u672C\u5730"
|
|
1837
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "kl-form-error", role: "alert", children: error }),
|
|
1838
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { children: [
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "kl-live-dot" }),
|
|
1841
|
+
!editing && !note && type === "url" ? "\u91C7\u96C6\u7ED3\u679C\u4FDD\u5B58\u5728\u672C\u5730" : "\u4EC5\u4FDD\u5B58\u5728\u672C\u5730"
|
|
635
1842
|
] }),
|
|
636
|
-
/* @__PURE__ */ (0,
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
1843
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
1844
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "kl-primary", type: "submit", disabled: busy, children: [
|
|
638
1845
|
busy ? "\u4FDD\u5B58\u4E2D\u2026" : editing ? "\u4FDD\u5B58\u4FEE\u6539" : note ? "\u4FDD\u5B58\u7B14\u8BB0" : type === "url" ? "\u5F00\u59CB\u91C7\u96C6" : "\u4FDD\u5B58\u8D44\u6599",
|
|
639
|
-
!busy && /* @__PURE__ */ (0,
|
|
1846
|
+
!busy && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "arrow", size: 16 })
|
|
640
1847
|
] })
|
|
641
1848
|
] })
|
|
642
1849
|
] }) });
|
|
@@ -736,11 +1943,100 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
736
1943
|
.kl-filterbar b { font-weight: 400; }
|
|
737
1944
|
.kl-filterbar > div { display: flex; align-items: center; gap: 16px; flex: none; }
|
|
738
1945
|
.kl-filterbar select { background: var(--kl-bg); color: var(--kl-muted); border: 0; border-radius: 6px; padding: 3px; max-width: 110px; font-size: 12px; }
|
|
1946
|
+
.kl-trash-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 var(--kl-gutter) 12px; }
|
|
1947
|
+
.kl-trash-toolbar p { color: var(--kl-muted); font-size: 12px; margin: 0; min-width: 0; }
|
|
1948
|
+
.kl-trash-toolbar button { flex: none; }
|
|
1949
|
+
.kl-knowledge-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 var(--kl-gutter) 12px; }
|
|
1950
|
+
.kl-knowledge-toolbar p { margin: 0; font-size: 12px; color: var(--kl-muted); }
|
|
1951
|
+
.kl-knowledge-toolbar > div, .kl-knowledge-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
|
1952
|
+
.kl-knowledge-toolbar > div { flex: none; }
|
|
1953
|
+
.kl-knowledge-badge { display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 5px; background: var(--kl-hover); color: var(--kl-muted); font-size: 11px; line-height: 18px; white-space: nowrap; font-weight: 400; }
|
|
1954
|
+
.kl-knowledge-badge:is(.draft, .running, .queued, .grouping, .classifying) { color: var(--kl-link); }
|
|
1955
|
+
.kl-knowledge-badge.failed { color: var(--kl-error); }
|
|
1956
|
+
.kl-knowledge-badge.completed { color: var(--kl-ink); }
|
|
1957
|
+
.kl-item-bottom { flex-wrap: wrap; }
|
|
1958
|
+
.kl-item-row.kl-selectable { padding-left: 30px; }
|
|
1959
|
+
.kl-material-checkbox { position: absolute; left: 9px; top: 17px; width: 15px; height: 15px; accent-color: var(--kl-primary); cursor: pointer; }
|
|
1960
|
+
.kl-knowledge-source { border-block: .5px solid var(--kl-line); padding-block: 16px; margin: 20px 0; }
|
|
1961
|
+
.kl-knowledge-source > div:first-child { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--kl-muted); margin-bottom: 12px; }
|
|
1962
|
+
.kl-knowledge-form, .kl-knowledge-jobs { padding: 0 24px 24px; }
|
|
1963
|
+
.kl-knowledge-form label, .kl-knowledge-draft label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; margin: 16px 0; }
|
|
1964
|
+
.kl-knowledge-form input, .kl-knowledge-draft input, .kl-knowledge-draft textarea { width: 100%; border: .5px solid var(--kl-line); border-radius: 8px; padding: 10px 12px; color: var(--kl-ink); background: var(--kl-bg); min-width: 0; font: inherit; }
|
|
1965
|
+
.kl-knowledge-draft textarea { line-height: 1.8; resize: vertical; font-size: 13px; }
|
|
1966
|
+
.kl-knowledge-form small, .kl-knowledge-jobs small { font-size: 12px; color: var(--kl-muted); line-height: 1.7; }
|
|
1967
|
+
.kl-knowledge-summary { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
|
|
1968
|
+
.kl-knowledge-summary b { font-weight: 500; }
|
|
1969
|
+
.kl-knowledge-summary span { color: var(--kl-muted); }
|
|
1970
|
+
.kl-knowledge-source-list { padding: 0; list-style: none; max-height: 150px; overflow: auto; }
|
|
1971
|
+
.kl-knowledge-source-list li { display: flex; align-items: center; gap: 8px; margin-block: 8px; font-size: 13px; overflow-wrap: anywhere; }
|
|
1972
|
+
.kl-knowledge-model { color: var(--kl-muted); font-size: 12px; line-height: 1.8; }
|
|
1973
|
+
.kl-knowledge-help { font-size: 12px; color: var(--kl-link); display: inline-flex; align-items: center; gap: 4px; }
|
|
1974
|
+
.kl-knowledge-form > .kl-muted { font-size: 13px; line-height: 1.8; }
|
|
1975
|
+
.kl-knowledge-form footer, .kl-knowledge-draft footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 20px; }
|
|
1976
|
+
.kl-knowledge-back { background: transparent; border: 0; padding: 0; color: var(--kl-muted); font-size: 12px; margin-bottom: 18px; }
|
|
1977
|
+
.kl-knowledge-empty { display: flex; align-items: center; flex-direction: column; text-align: center; padding: 24px 0; color: var(--kl-muted); }
|
|
1978
|
+
.kl-knowledge-empty p { color: var(--kl-ink); }
|
|
1979
|
+
.kl-knowledge-job { display: block; width: 100%; border: 0; border-top: .5px solid var(--kl-line); background: transparent; text-align: left; padding: 16px 0; }
|
|
1980
|
+
.kl-knowledge-job:hover { background: var(--kl-hover); }
|
|
1981
|
+
.kl-knowledge-job > div, .kl-knowledge-job-heading { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
|
|
1982
|
+
.kl-knowledge-job strong, .kl-knowledge-job-heading strong { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
|
|
1983
|
+
.kl-knowledge-job p { color: var(--kl-muted); font-size: 12px; margin: 8px 0 0; }
|
|
1984
|
+
.kl-knowledge-job small { display: block; margin-top: 8px; }
|
|
1985
|
+
.kl-knowledge-progress { display: flex; align-items: center; gap: 8px; color: var(--kl-muted); font-size: 13px; margin: 20px 0; }
|
|
1986
|
+
.kl-knowledge-jobs > .kl-knowledge-actions { margin-top: 18px; }
|
|
1987
|
+
.kl-knowledge-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
|
1988
|
+
.kl-knowledge-citations { font-size: 12px; color: var(--kl-muted); border-block: .5px solid var(--kl-line); padding-block: 12px; }
|
|
1989
|
+
.kl-knowledge-citations summary { cursor: pointer; }
|
|
1990
|
+
.kl-knowledge-citations button { border: 0; background: transparent; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 0; }
|
|
1991
|
+
.kl-knowledge-citations button span { min-width: 0; overflow-wrap: anywhere; }
|
|
1992
|
+
.kl-knowledge-mode { margin: 16px 0; padding: 12px; border: .5px solid var(--kl-line); border-radius: 8px; }
|
|
1993
|
+
.kl-knowledge-mode legend { padding: 0 4px; font-size: 12px; color: var(--kl-muted); }
|
|
1994
|
+
.kl-knowledge-mode label { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
|
|
1995
|
+
.kl-knowledge-mode input { width: 15px; padding: 0; accent-color: var(--kl-primary); }
|
|
1996
|
+
.kl-knowledge-mode small { margin-left: auto; }
|
|
1997
|
+
.kl-grouping-editor { margin-top: 18px; }
|
|
1998
|
+
.kl-grouping-summary { display: flex; align-items: center; gap: 14px; font-size: 13px; }
|
|
1999
|
+
.kl-grouping-summary b { font-weight: 500; }
|
|
2000
|
+
.kl-grouping-summary span { color: var(--kl-muted); }
|
|
2001
|
+
.kl-grouping-group { border: .5px solid var(--kl-line); border-radius: 8px; padding: 12px 14px; margin: 12px 0; }
|
|
2002
|
+
.kl-grouping-group-title, .kl-grouping-source-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
|
|
2003
|
+
.kl-grouping-group-title { font-size: 12px; color: var(--kl-muted); }
|
|
2004
|
+
.kl-grouping-group ul { margin: 10px 0 0; padding-left: 18px; color: var(--kl-muted); font-size: 12px; line-height: 1.8; }
|
|
2005
|
+
.kl-grouping-group li { overflow-wrap: anywhere; }
|
|
2006
|
+
.kl-grouping-editor label { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; font-size: 12px; }
|
|
2007
|
+
.kl-grouping-editor :is(input,textarea,select) { width: 100%; min-width: 0; border: .5px solid var(--kl-line); border-radius: 8px; padding: 9px 10px; background: var(--kl-bg); color: var(--kl-ink); font: inherit; }
|
|
2008
|
+
.kl-grouping-editor textarea { line-height: 1.7; resize: vertical; }
|
|
2009
|
+
.kl-grouping-reason { margin: 8px 0; font-size: 12px; line-height: 1.8; color: var(--kl-muted); overflow-wrap: anywhere; }
|
|
2010
|
+
.kl-grouping-settings summary, .kl-grouping-source summary { cursor: pointer; font-size: 12px; color: var(--kl-muted); }
|
|
2011
|
+
.kl-grouping-settings summary span { margin-left: 8px; color: var(--kl-ink); }
|
|
2012
|
+
.kl-grouping-section-title { font-size: 14px; font-weight: 500; margin: 24px 0 10px; }
|
|
2013
|
+
.kl-grouping-source { border-top: .5px solid var(--kl-line); padding: 14px 0; }
|
|
2014
|
+
.kl-grouping-source-title strong { font-size: 13px; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
|
|
2015
|
+
.kl-grouping-source p, .kl-grouping-pending p, .kl-grouping-recovery p { font-size: 12px; line-height: 1.8; color: var(--kl-muted); overflow-wrap: anywhere; }
|
|
2016
|
+
.kl-grouping-source details button { margin-top: 8px; }
|
|
2017
|
+
.kl-grouping-editor .kl-grouping-sync { flex-direction: row; align-items: center; gap: 8px; margin-top: 20px; }
|
|
2018
|
+
.kl-grouping-sync input { width: 15px; height: 15px; padding: 0; accent-color: var(--kl-primary); flex: none; }
|
|
2019
|
+
.kl-grouping-editor footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
|
|
2020
|
+
.kl-grouping-recovery { border-left: 2px solid var(--kl-link); padding-left: 12px; font-size: 13px; }
|
|
2021
|
+
.kl-grouping-pending { border-top: .5px solid var(--kl-line); padding-top: 14px; font-size: 13px; }
|
|
2022
|
+
.kl-note-integration { border: .5px solid var(--kl-line); border-radius: 8px; padding: 14px; margin: 16px 0; }
|
|
2023
|
+
.kl-note-integration > strong { font-size: 14px; font-weight: 500; }
|
|
2024
|
+
.kl-note-integration p, .kl-integration-findings { font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
|
|
2025
|
+
.kl-integration-findings { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: .5px solid var(--kl-line); }
|
|
2026
|
+
.kl-integration-findings > span { color: var(--kl-muted); }
|
|
2027
|
+
.kl-integration-findings ul { margin: 0; padding-left: 16px; }
|
|
2028
|
+
.kl-integration-target { font-weight: 500; }
|
|
2029
|
+
.kl-integration-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow-y: auto; padding: 12px; background: var(--kl-hover); border-radius: 6px; font: inherit; font-size: 12px; line-height: 1.8; }
|
|
2030
|
+
.kl-note-integration details summary, .kl-knowledge-draft > details summary { cursor: pointer; font-size: 12px; color: var(--kl-muted); }
|
|
739
2031
|
.kl-body { position: relative; display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
740
2032
|
.kl-list { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 calc(var(--kl-gutter) - 8px) 24px; }
|
|
741
2033
|
.kl-body.with-detail .kl-list { flex: 0 0 38%; padding: 0 16px 24px calc(var(--kl-gutter) - 8px); }
|
|
742
2034
|
.kl-item { width: 100%; display: block; text-align: left; padding: 14px 12px; margin-bottom: 2px; border: 0; border-radius: var(--kl-radius); background: transparent; }
|
|
743
2035
|
.kl-item:hover, .kl-item.selected { background: var(--kl-hover); }
|
|
2036
|
+
.kl-item-row { position: relative; }
|
|
2037
|
+
.kl-item-row .kl-item { padding-right: 48px; }
|
|
2038
|
+
.kl-app .kl-row-action { position: absolute; top: 8px; right: 8px; }
|
|
2039
|
+
.kl-app .kl-danger, .kl-app .kl-danger:hover { color: var(--kl-error); }
|
|
744
2040
|
.kl-item-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 5px; }
|
|
745
2041
|
.kl-type { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--kl-muted); }
|
|
746
2042
|
.kl-item time { color: var(--kl-muted); font-size: 12px; }
|
|
@@ -821,6 +2117,9 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
821
2117
|
.kl-dialog > header p { margin: 0; color: var(--kl-muted); font-size: 12px; line-height: 1.7; }
|
|
822
2118
|
.kl-dialog > header > button { border: 0; border-radius: 8px; background: transparent; color: var(--kl-muted); padding: 4px; display: flex; }
|
|
823
2119
|
.kl-dialog > header > button:hover { background: var(--kl-hover); }
|
|
2120
|
+
.kl-delete-dialog { padding: 0 24px 24px; }
|
|
2121
|
+
.kl-delete-title { margin: 0 0 12px; font-weight: 500; overflow-wrap: anywhere; }
|
|
2122
|
+
.kl-delete-dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
|
|
824
2123
|
.kl-editor { padding: 0 24px; }
|
|
825
2124
|
.kl-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
|
|
826
2125
|
.kl-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: transparent; border: 0; color: var(--kl-muted); border-radius: 14px; min-height: 32px; padding: 5px 8px; font-size: 13px; }
|
|
@@ -847,14 +2146,58 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
847
2146
|
.kl-job time { font-size: 11px; color: var(--kl-muted); }
|
|
848
2147
|
.kl-job > strong { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 400; margin: 12px 0; }
|
|
849
2148
|
.kl-job > p { font-size: 12px; color: var(--kl-error); line-height: 1.7; }
|
|
850
|
-
.kl-job button { display: flex; align-items: center; gap: 4px; color: var(--kl-link); font-size: 12px; border: 0; background: transparent; border-radius: 6px; padding: 4px; }
|
|
851
|
-
.kl-job button:hover { background: var(--kl-hover); }
|
|
2149
|
+
.kl-job button, .kl-job a { display: flex; align-items: center; gap: 4px; color: var(--kl-link); font-size: 12px; border: 0; background: transparent; border-radius: 6px; padding: 4px; text-decoration: none; }
|
|
2150
|
+
.kl-job button:hover, .kl-job a:hover { background: var(--kl-hover); }
|
|
2151
|
+
.kl-job .kl-job-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
|
|
852
2152
|
.kl-job-status { font-size: 11px; border-radius: 6px; padding: 3px 7px; background: var(--kl-hover); color: var(--kl-secondary); }
|
|
853
2153
|
.kl-job-status.failed { color: var(--kl-error); }
|
|
854
2154
|
.kl-job-status.running { color: var(--kl-link); }
|
|
855
2155
|
.kl-info label { display: block; font-size: 12px; color: var(--kl-muted); margin-bottom: 8px; }
|
|
856
2156
|
.kl-info code { display: block; overflow-wrap: anywhere; background: var(--kl-sidebar); padding: 12px; border-radius: 8px; font-size: 12px; }
|
|
857
2157
|
.kl-info p { font-size: 13px; line-height: 1.8; color: var(--kl-secondary); margin: 16px 0; }
|
|
2158
|
+
.kl-root-field, .kl-folder-path { display: flex; gap: 8px; align-items: center; }
|
|
2159
|
+
.kl-root-field input, .kl-folder-path input { flex: 1; min-width: 0; border: .5px solid var(--kl-line); background: var(--kl-panel); border-radius: var(--kl-radius); padding: 10px 12px; font-size: 12px; }
|
|
2160
|
+
.kl-root-field input[readonly] { background: var(--kl-sidebar); }
|
|
2161
|
+
.kl-root-field button, .kl-folder-path button { flex-shrink: 0; }
|
|
2162
|
+
.kl-root-confirm { margin-top: 14px; padding: 12px; border: .5px solid var(--kl-line); border-radius: 10px; background: var(--kl-sidebar); }
|
|
2163
|
+
.kl-root-confirm p { margin: 0 0 12px; }
|
|
2164
|
+
.kl-root-confirm > div, .kl-folder-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
2165
|
+
.kl-folder-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
|
|
2166
|
+
.kl-folder-heading strong { font-size: 14px; font-weight: 500; }
|
|
2167
|
+
.kl-folder-crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
|
|
2168
|
+
.kl-folder-crumbs button { border: 0; background: transparent; padding: 3px 0; font-size: 12px; color: var(--kl-muted); overflow-wrap: anywhere; }
|
|
2169
|
+
.kl-folder-crumbs span { padding: 0 6px; color: var(--kl-caption); }
|
|
2170
|
+
.kl-folder-entries { height: 240px; overflow: auto; border: .5px solid var(--kl-line); border-radius: 10px; padding: 6px; }
|
|
2171
|
+
.kl-folder-entries > button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; border-radius: 6px; padding: 10px; background: transparent; }
|
|
2172
|
+
.kl-folder-entries > button:hover { background: var(--kl-hover); }
|
|
2173
|
+
.kl-folder-entries > button span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
2174
|
+
.kl-folder-entries > p { padding: 0 10px; }
|
|
2175
|
+
.kl-folder-actions { margin-top: 16px; }
|
|
2176
|
+
.kl-info .kl-settings-error { color: var(--kl-error); overflow-wrap: anywhere; }
|
|
2177
|
+
.kl-network-settings { margin-top: 20px; padding-top: 16px; border-top: .5px solid var(--kl-line); }
|
|
2178
|
+
.kl-network-settings h3 { font-size: 13px; font-weight: 500; margin: 0 0 12px; }
|
|
2179
|
+
.kl-info .kl-proxy-option { display: flex; align-items: flex-start; gap: 8px; color: var(--kl-ink); font-size: 13px; line-height: 20px; cursor: pointer; }
|
|
2180
|
+
.kl-proxy-option input { flex: none; width: 16px; height: 16px; margin: 2px 0; accent-color: var(--kl-ink); }
|
|
2181
|
+
.kl-network-settings p { font-size: 12px; margin: 8px 0 12px; }
|
|
2182
|
+
.kl-image-settings { margin-top: 20px; padding-top: 16px; border-top: .5px solid var(--kl-line); }
|
|
2183
|
+
.kl-image-settings h3, .kl-page-images h3 { font-size: 13px; font-weight: 500; margin: 0 0 12px; }
|
|
2184
|
+
.kl-image-settings p, .kl-image-record p { font-size: 12px; overflow-wrap: anywhere; }
|
|
2185
|
+
.kl-info .kl-image-limit { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
|
|
2186
|
+
.kl-image-limit input { width: 68px; padding: 6px 8px; border: .5px solid var(--kl-line); border-radius: 8px; background: var(--kl-bg); }
|
|
2187
|
+
.kl-image-policy { padding: 10px 12px; border-left: 2px solid var(--kl-link); background: var(--kl-sidebar); color: var(--kl-secondary); font-size: 12px; line-height: 1.8; margin: 0 0 16px; overflow-wrap: anywhere; }
|
|
2188
|
+
.kl-page-images { margin: 24px 0; padding-block: 16px; border-block: .5px solid var(--kl-line); }
|
|
2189
|
+
.kl-image-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
2190
|
+
.kl-image-heading h3 { margin: 0; }
|
|
2191
|
+
.kl-image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 16px; }
|
|
2192
|
+
.kl-image-record { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 12px; overflow-wrap: anywhere; }
|
|
2193
|
+
.kl-image-record > a:has(img) { width: 100%; }
|
|
2194
|
+
.kl-image-record img { display: block; width: 100%; height: 140px; object-fit: contain; border: .5px solid var(--kl-line); border-radius: 8px; background: var(--kl-sidebar); }
|
|
2195
|
+
.kl-image-record small { color: var(--kl-muted); }
|
|
2196
|
+
.kl-image-record a { color: var(--kl-link); }
|
|
2197
|
+
.kl-image-record p { margin: 0; color: var(--kl-secondary); }
|
|
2198
|
+
.kl-delete-dialog li { overflow-wrap: anywhere; }
|
|
2199
|
+
.kl-job > p { color: var(--kl-secondary); }
|
|
2200
|
+
.kl-job > p[role="alert"] { color: var(--kl-error); }
|
|
858
2201
|
.kl-error, .kl-form-error { background: var(--kl-sidebar); color: var(--kl-error); font-size: 13px; line-height: 1.7; padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }
|
|
859
2202
|
.kl-error { display: flex; align-items: center; gap: 12px; margin: 0 var(--kl-gutter) 14px; }
|
|
860
2203
|
.kl-error button { margin-left: auto; border: 0; background: transparent; color: inherit; display: flex; padding: 4px; }
|
|
@@ -882,10 +2225,14 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
882
2225
|
.kl-toolbar { padding: 0 20px 12px; gap: 4px; }
|
|
883
2226
|
.kl-search kbd, .kl-job-button span, .kl-sort-label { display: none; }
|
|
884
2227
|
.kl-filterbar { padding: 0 20px 10px; }
|
|
2228
|
+
.kl-trash-toolbar { padding: 0 20px 12px; flex-wrap: wrap; }
|
|
2229
|
+
.kl-knowledge-toolbar { padding: 0 20px 12px; flex-wrap: wrap; }
|
|
885
2230
|
.kl-list { padding: 0 12px 16px; }
|
|
886
2231
|
.kl-empty { padding: 40px 12px; }
|
|
887
2232
|
.kl-detail article { padding: 20px; }
|
|
888
2233
|
.kl-detail-toolbar { padding: 8px 12px; }
|
|
2234
|
+
.kl-detail-toolbar { flex-wrap: wrap; }
|
|
2235
|
+
.kl-detail-toolbar > div { margin-left: auto; }
|
|
889
2236
|
.kl-error { margin: 0 20px 12px; }
|
|
890
2237
|
}
|
|
891
2238
|
/* Fixed dialogs use viewport width even when the host panel is narrow. */
|
|
@@ -893,6 +2240,8 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
893
2240
|
.kl-modal-backdrop { padding: 12px; }
|
|
894
2241
|
.kl-dialog { max-height: calc(100dvh - 24px); }
|
|
895
2242
|
.kl-dialog > header { padding: 20px 18px 16px; }
|
|
2243
|
+
.kl-knowledge-form, .kl-knowledge-jobs { padding-inline: 18px; }
|
|
2244
|
+
.kl-knowledge-fields { grid-template-columns: 1fr; gap: 0; }
|
|
896
2245
|
.kl-editor { padding: 0 18px; }
|
|
897
2246
|
.kl-editor footer { margin-left: -18px; margin-right: -18px; padding: 14px 18px; }
|
|
898
2247
|
.kl-editor footer > span { font-size: 10px; }
|
|
@@ -900,6 +2249,7 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
900
2249
|
.kl-tabs button { padding: 5px; font-size: 12px; }
|
|
901
2250
|
.kl-form-grid { gap: 12px; }
|
|
902
2251
|
.kl-jobs, .kl-info { padding: 0 18px 20px; }
|
|
2252
|
+
.kl-delete-dialog { padding: 0 18px 20px; }
|
|
903
2253
|
}
|
|
904
2254
|
@media (prefers-reduced-motion: reduce) {
|
|
905
2255
|
.kl-app * { animation: none !important; transition: none !important; }
|
|
@@ -907,7 +2257,7 @@ var style_default = `/* Harness owns the palette and font. Fallbacks are for the
|
|
|
907
2257
|
`;
|
|
908
2258
|
|
|
909
2259
|
// src/client.tsx
|
|
910
|
-
var
|
|
2260
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
911
2261
|
var inject = ["slots"];
|
|
912
2262
|
function apply(ctx) {
|
|
913
2263
|
ctx.effect(() => {
|
|
@@ -917,13 +2267,13 @@ function apply(ctx) {
|
|
|
917
2267
|
document.head.append(style);
|
|
918
2268
|
return () => style.remove();
|
|
919
2269
|
});
|
|
920
|
-
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: "knowledge-library" }, () => /* @__PURE__ */ (0,
|
|
2270
|
+
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: "knowledge-library" }, () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(App, {})));
|
|
921
2271
|
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
922
2272
|
name: "sidebar.panellist",
|
|
923
2273
|
id: "knowledge-library",
|
|
924
2274
|
order: 20,
|
|
925
2275
|
label: "\u8D44\u6599\u5E93"
|
|
926
|
-
}, () => /* @__PURE__ */ (0,
|
|
2276
|
+
}, () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LibraryIcon, { size: 20 })));
|
|
927
2277
|
}
|
|
928
2278
|
|
|
929
2279
|
return module.exports;}});
|