dsh-knowledge-library 0.0.0-stage → 0.1.1
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 +22 -0
- package/LICENSE +21 -0
- package/README.md +231 -2
- package/cordis.patch.yml +3 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +929 -0
- package/dist/core/extract.d.ts +9 -0
- package/dist/core/extract.js +105 -0
- package/dist/core/fetch.d.ts +10 -0
- package/dist/core/fetch.js +105 -0
- package/dist/core/jobs.d.ts +30 -0
- package/dist/core/jobs.js +96 -0
- package/dist/core/library.d.ts +61 -0
- package/dist/core/library.js +386 -0
- package/dist/http.d.ts +6 -0
- package/dist/http.js +157 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +35 -0
- package/dist/public/app.css +261 -0
- package/dist/public/app.js +56 -0
- package/dist/public/index.html +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.js +38 -0
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +62 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.js +1 -0
- package/dist/ui/App.d.ts +2 -0
- package/dist/ui/App.js +223 -0
- package/dist/ui/icons.d.ts +8 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/main.d.ts +1 -0
- package/dist/ui/main.js +4 -0
- package/package.json +94 -4
package/dist/client.js
ADDED
|
@@ -0,0 +1,929 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-knowledge-library",factory:(require)=>{var module={exports:{}};var exports=module.exports;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client.tsx
|
|
22
|
+
var client_exports = {};
|
|
23
|
+
__export(client_exports, {
|
|
24
|
+
apply: () => apply,
|
|
25
|
+
inject: () => inject
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(client_exports);
|
|
28
|
+
|
|
29
|
+
// src/ui/App.tsx
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
|
|
32
|
+
// src/ui/icons.tsx
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
function Icon({ name, size = 20 }) {
|
|
35
|
+
const paths = {
|
|
36
|
+
library: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 4h5v16H4zM12 4h3v16h-3zM17 5l3-1 4 15-3 1z" }) }),
|
|
37
|
+
plus: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 5v14M5 12h14" }),
|
|
38
|
+
search: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
39
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "10.5", cy: "10.5", r: "6.5" }),
|
|
40
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m16 16 4 4" })
|
|
41
|
+
] }),
|
|
42
|
+
file: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 3H5v18h14V8zM14 3v5h5M8 13h8M8 17h6" }) }),
|
|
43
|
+
web: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 12h18M12 3c5 5 5 13 0 18-5-5-5-13 0-18" })
|
|
46
|
+
] }),
|
|
47
|
+
video: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
49
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m10 9 5 3-5 3z" })
|
|
50
|
+
] }),
|
|
51
|
+
note: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 4H5v16h14v-8M10 14l1-4 8-8 3 3-8 8z" }) }),
|
|
52
|
+
folder: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 6h7l2 3h9v11H3z" }),
|
|
53
|
+
inbox: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 4h14l3 11v5H2v-5zM2 15h6l2 3h4l2-3h6" }) }),
|
|
54
|
+
tag: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 3h9l9 9-9 9-9-9z" }),
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "8", cy: "8", r: "1" })
|
|
57
|
+
] }),
|
|
58
|
+
arrow: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m9 5 7 7-7 7" }),
|
|
59
|
+
close: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12M18 6 6 18" }),
|
|
60
|
+
upload: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16V3m-5 5 5-5 5 5M3 15v6h18v-6" }) }),
|
|
61
|
+
check: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m5 12 4 4L19 6" }),
|
|
62
|
+
clock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 7v6l4 2" })
|
|
65
|
+
] }),
|
|
66
|
+
copy: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "8", y: "8", width: "12", height: "13", rx: "2" }),
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 8V3H3v13h5" })
|
|
69
|
+
] }),
|
|
70
|
+
download: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 3v13m-5-5 5 5 5-5M3 17v4h18v-4" }) }),
|
|
71
|
+
settings: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 7h16M4 17h16" }),
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "9", cy: "7", r: "3" }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "15", cy: "17", r: "3" })
|
|
75
|
+
] })
|
|
76
|
+
};
|
|
77
|
+
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
|
+
}
|
|
79
|
+
var LibraryIcon = ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "library", size });
|
|
80
|
+
|
|
81
|
+
// src/ui/App.tsx
|
|
82
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
83
|
+
var API = "/knowledge-library/api";
|
|
84
|
+
var kinds = {
|
|
85
|
+
web: { label: "\u7F51\u9875", icon: "web" },
|
|
86
|
+
text: { label: "\u6587\u672C", icon: "file" },
|
|
87
|
+
file: { label: "\u6587\u4EF6", icon: "file" },
|
|
88
|
+
video: { label: "\u97F3\u89C6\u9891", icon: "video" },
|
|
89
|
+
transcript: { label: "\u5B57\u5E55", icon: "video" },
|
|
90
|
+
note: { label: "\u7B14\u8BB0", icon: "note" }
|
|
91
|
+
};
|
|
92
|
+
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
|
+
var date = (value) => new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit" }).format(new Date(value));
|
|
94
|
+
async function api(path, options = {}) {
|
|
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) {
|
|
102
|
+
return value.split(/[,,]/).map((v) => v.trim()).filter(Boolean);
|
|
103
|
+
}
|
|
104
|
+
function App() {
|
|
105
|
+
const [stats, setStats] = (0, import_react.useState)();
|
|
106
|
+
const [items, setItems] = (0, import_react.useState)([]);
|
|
107
|
+
const [total, setTotal] = (0, import_react.useState)(0);
|
|
108
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
109
|
+
const [filter, setFilter] = (0, import_react.useState)({});
|
|
110
|
+
const [selected, setSelected] = (0, import_react.useState)();
|
|
111
|
+
const [detail, setDetail] = (0, import_react.useState)();
|
|
112
|
+
const [anchor, setAnchor] = (0, import_react.useState)();
|
|
113
|
+
const [editor, setEditor] = (0, import_react.useState)();
|
|
114
|
+
const [jobs, setJobs] = (0, import_react.useState)([]);
|
|
115
|
+
const [showJobs, setShowJobs] = (0, import_react.useState)(false);
|
|
116
|
+
const [showInfo, setShowInfo] = (0, import_react.useState)(false);
|
|
117
|
+
const [showNavigation, setShowNavigation] = (0, import_react.useState)(false);
|
|
118
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
119
|
+
const [toast, setToast] = (0, import_react.useState)("");
|
|
120
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
121
|
+
const [detailLoading, setDetailLoading] = (0, import_react.useState)(false);
|
|
122
|
+
const [revision, setRevision] = (0, import_react.useState)(0);
|
|
123
|
+
const [limit, setLimit] = (0, import_react.useState)(40);
|
|
124
|
+
const searchRef = (0, import_react.useRef)(null);
|
|
125
|
+
const detailRef = (0, import_react.useRef)(null);
|
|
126
|
+
const refresh = (0, import_react.useCallback)(() => setRevision((v) => v + 1), []);
|
|
127
|
+
const notify = (message) => setToast(message);
|
|
128
|
+
const chooseFilter = (next) => {
|
|
129
|
+
setFilter(next);
|
|
130
|
+
setLimit(40);
|
|
131
|
+
setSelected(void 0);
|
|
132
|
+
setAnchor(void 0);
|
|
133
|
+
setDetail(void 0);
|
|
134
|
+
setShowNavigation(false);
|
|
135
|
+
};
|
|
136
|
+
const refreshMeta = (0, import_react.useCallback)(async () => {
|
|
137
|
+
const [s, j] = await Promise.all([api("/stats"), api("/jobs")]);
|
|
138
|
+
setStats(s);
|
|
139
|
+
setJobs(j);
|
|
140
|
+
}, []);
|
|
141
|
+
(0, import_react.useEffect)(() => {
|
|
142
|
+
void refreshMeta().catch((e) => setError(e.message));
|
|
143
|
+
}, [revision, refreshMeta]);
|
|
144
|
+
(0, import_react.useEffect)(() => {
|
|
145
|
+
const controller = new AbortController();
|
|
146
|
+
const timer = setTimeout(() => {
|
|
147
|
+
setLoading(true);
|
|
148
|
+
const params = new URLSearchParams({ query, limit: String(limit) });
|
|
149
|
+
for (const [key, value] of Object.entries(filter)) if (value) params.set(key, value);
|
|
150
|
+
api(`/materials?${params}`, { signal: controller.signal }).then((result) => {
|
|
151
|
+
setItems(result.items);
|
|
152
|
+
setTotal(result.total);
|
|
153
|
+
}).catch((e) => {
|
|
154
|
+
if (e.name !== "AbortError") setError(e.message);
|
|
155
|
+
}).finally(() => {
|
|
156
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
157
|
+
});
|
|
158
|
+
}, query ? 180 : 0);
|
|
159
|
+
return () => {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
controller.abort();
|
|
162
|
+
};
|
|
163
|
+
}, [query, filter, revision, limit]);
|
|
164
|
+
(0, import_react.useEffect)(() => {
|
|
165
|
+
if (!selected) {
|
|
166
|
+
setDetail(void 0);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const controller = new AbortController();
|
|
170
|
+
setDetailLoading(true);
|
|
171
|
+
setDetail(void 0);
|
|
172
|
+
api(`/materials/${selected}`, { signal: controller.signal }).then(setDetail).catch((e) => {
|
|
173
|
+
if (e.name !== "AbortError") setError(e.message);
|
|
174
|
+
}).finally(() => {
|
|
175
|
+
if (!controller.signal.aborted) setDetailLoading(false);
|
|
176
|
+
});
|
|
177
|
+
return () => controller.abort();
|
|
178
|
+
}, [selected, revision]);
|
|
179
|
+
(0, import_react.useEffect)(() => {
|
|
180
|
+
if (!detail || !anchor) return;
|
|
181
|
+
const element = Array.from(detailRef.current?.querySelectorAll("[data-segment-id]") || []).find((el) => el.dataset.segmentId === anchor);
|
|
182
|
+
element?.scrollIntoView({ block: "center" });
|
|
183
|
+
}, [detail, anchor]);
|
|
184
|
+
const pending = jobs.filter((j) => ["queued", "running"].includes(j.status)).length;
|
|
185
|
+
(0, import_react.useEffect)(() => {
|
|
186
|
+
if (!pending) return;
|
|
187
|
+
const interval = setInterval(refresh, 2500);
|
|
188
|
+
return () => clearInterval(interval);
|
|
189
|
+
}, [pending, refresh]);
|
|
190
|
+
(0, import_react.useEffect)(() => {
|
|
191
|
+
if (!toast) return;
|
|
192
|
+
const timer = setTimeout(() => setToast(""), 3500);
|
|
193
|
+
return () => clearTimeout(timer);
|
|
194
|
+
}, [toast]);
|
|
195
|
+
(0, import_react.useEffect)(() => {
|
|
196
|
+
const listener = (event) => {
|
|
197
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
198
|
+
event.preventDefault();
|
|
199
|
+
searchRef.current?.focus();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
window.addEventListener("keydown", listener);
|
|
203
|
+
return () => window.removeEventListener("keydown", listener);
|
|
204
|
+
}, []);
|
|
205
|
+
async function copy(text) {
|
|
206
|
+
try {
|
|
207
|
+
await navigator.clipboard.writeText(text);
|
|
208
|
+
notify("\u5F15\u7528\u5DF2\u590D\u5236");
|
|
209
|
+
} catch {
|
|
210
|
+
setError("\u526A\u8D34\u677F\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4ECE\u8D44\u6599\u8BE6\u60C5\u624B\u52A8\u590D\u5236\u8D44\u6599 ID");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const currentTitle = filter.category || filter.collection || (filter.tag ? `\u6807\u7B7E \xB7 ${filter.tag}` : filter.kind === "note" ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u5168\u90E8\u8D44\u6599");
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-app", children: [
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("main", { className: "kl-workspace", children: [
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "kl-header", children: [
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: currentTitle }),
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-header-actions", children: [
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-secondary", onClick: () => setEditor({ mode: "note" }), children: [
|
|
220
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "note", size: 16 }),
|
|
221
|
+
"\u5199\u7B14\u8BB0"
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-primary", onClick: () => setEditor({ mode: "capture" }), children: [
|
|
224
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "plus", size: 16 }),
|
|
225
|
+
"\u6536\u96C6\u8D44\u6599"
|
|
226
|
+
] })
|
|
227
|
+
] })
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-navigation", children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("nav", { "aria-label": "\u8D44\u6599\u5BFC\u822A", children: [
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-pressed": !Object.values(filter).some(Boolean), onClick: () => chooseFilter({}), children: "\u5168\u90E8\u8D44\u6599" }),
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-pressed": filter.category === "\u6536\u4EF6\u7BB1", onClick: () => chooseFilter({ category: "\u6536\u4EF6\u7BB1" }), children: "\u6536\u4EF6\u7BB1" }),
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-pressed": filter.kind === "note", onClick: () => chooseFilter({ kind: "note" }), children: "\u77E5\u8BC6\u7B14\u8BB0" })
|
|
234
|
+
] }),
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-directory-toggle", "aria-expanded": showNavigation, "aria-controls": "kl-directory", onClick: () => setShowNavigation((v) => !v), children: [
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "folder", size: 16 }),
|
|
237
|
+
"\u5206\u7C7B\u4E0E\u4E13\u9898"
|
|
238
|
+
] })
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-toolbar", children: [
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "kl-search", children: [
|
|
242
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "search", size: 19 }),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
setQuery(e.target.value);
|
|
245
|
+
setLimit(40);
|
|
246
|
+
} }),
|
|
247
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("kbd", { children: "Ctrl K" })
|
|
248
|
+
] }),
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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: [
|
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "clock", size: 17 }),
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: pending ? `${pending} \u9879\u5904\u7406\u4E2D` : "\u91C7\u96C6\u4EFB\u52A1" }),
|
|
252
|
+
jobs.some((j) => j.status === "failed") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("i", {})
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "kl-icon-button", "aria-label": "\u8D44\u6599\u5E93\u8BBE\u7F6E", title: "\u8D44\u6599\u5E93\u8BBE\u7F6E", onClick: () => setShowInfo(true), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "settings", size: 18 }) })
|
|
255
|
+
] }),
|
|
256
|
+
!!error && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-error", role: "alert", children: [
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: error }),
|
|
258
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { "aria-label": "\u5173\u95ED\u9519\u8BEF", onClick: () => setError(""), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", size: 16 }) })
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-filterbar", children: [
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: total }),
|
|
263
|
+
" \u4EFD\u8D44\u6599",
|
|
264
|
+
query && ` \xB7 \u201C${query}\u201D`
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("select", { "aria-label": "\u6309\u7C7B\u578B\u7B5B\u9009", value: filter.kind || "", onChange: (e) => {
|
|
268
|
+
setFilter({ ...filter, kind: e.target.value || void 0 });
|
|
269
|
+
setLimit(40);
|
|
270
|
+
}, children: [
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\u6240\u6709\u7C7B\u578B" }),
|
|
272
|
+
Object.entries(kinds).map(([value, kind]) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value, children: kind.label }, value))
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-sort-label", children: "\u6700\u8FD1\u66F4\u65B0 \u2193" })
|
|
275
|
+
] })
|
|
276
|
+
] }),
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `kl-body ${detail || detailLoading ? "with-detail" : ""}`, children: [
|
|
278
|
+
showNavigation && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "kl-nav", id: "kl-directory", "aria-label": "\u5206\u7C7B\u4E0E\u4E13\u9898", children: [
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-directory-title", children: [
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5206\u7C7B\u4E0E\u4E13\u9898" }),
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "kl-icon-button", "aria-label": "\u5173\u95ED\u5206\u7C7B\u5BFC\u822A", onClick: () => setShowNavigation(false), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", size: 16 }) })
|
|
282
|
+
] }),
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-nav-label", children: "\u5206\u7C7B" }),
|
|
285
|
+
stats?.categories.filter((c) => c.name !== "\u6536\u4EF6\u7BB1").map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { "aria-pressed": filter.category === c.name, className: "kl-nav-row", onClick: () => chooseFilter({ category: c.name }), children: [
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "folder", size: 16 }),
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { title: c.name, children: c.name }),
|
|
288
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: c.count })
|
|
289
|
+
] }, c.name)),
|
|
290
|
+
!stats?.categories.some((c) => c.name !== "\u6536\u4EF6\u7BB1") && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "kl-nav-hint", children: "\u6536\u96C6\u8D44\u6599\u65F6\u6DFB\u52A0\u5206\u7C7B" })
|
|
291
|
+
] }),
|
|
292
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-nav-label", children: "\u4E13\u9898" }),
|
|
294
|
+
stats?.collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { "aria-pressed": filter.collection === c.name, className: "kl-nav-row", onClick: () => chooseFilter({ collection: c.name }), children: [
|
|
295
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-collection-dot" }),
|
|
296
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { title: c.name, children: c.name }),
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: c.count })
|
|
298
|
+
] }, c.name)),
|
|
299
|
+
!stats?.collections.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "kl-nav-hint", children: "\u6536\u96C6\u8D44\u6599\u65F6\u6DFB\u52A0\u4E13\u9898" })
|
|
300
|
+
] }),
|
|
301
|
+
!!stats?.tags.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-section", children: [
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-nav-label", children: "\u6807\u7B7E" }),
|
|
303
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-tag-cloud", children: stats.tags.slice(0, 15).map((tag) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { "aria-pressed": filter.tag === tag.name, onClick: () => chooseFilter({ tag: tag.name }), children: [
|
|
304
|
+
"#",
|
|
305
|
+
tag.name
|
|
306
|
+
] }, tag.name)) })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-nav-bottom", children: [
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
|
|
310
|
+
"\u4FDD\u5B58\u5728\u8FD9\u53F0\u7535\u8111"
|
|
311
|
+
] })
|
|
312
|
+
] }),
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "kl-list", "aria-label": "\u8D44\u6599\u5217\u8868", "aria-busy": loading, children: [
|
|
314
|
+
loading && !items.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-spinner" }),
|
|
316
|
+
"\u6B63\u5728\u8BFB\u53D6\u8D44\u6599\u5E93\u2026"
|
|
317
|
+
] }) : !items.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
|
|
318
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "inbox", size: 28 }),
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: 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" }),
|
|
320
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u8BD5\u8BD5\u5176\u4ED6\u5173\u952E\u8BCD\uFF0C\u6216\u5207\u6362\u5206\u7C7B\u3002" }),
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" })
|
|
322
|
+
] }) : items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: `kl-item ${selected === item.id ? "selected" : ""}`, onClick: () => {
|
|
323
|
+
setAnchor(void 0);
|
|
324
|
+
setSelected(item.id);
|
|
325
|
+
}, children: [
|
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-item-top", children: [
|
|
327
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `kl-type kl-type-${item.kind}`, children: [
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: kinds[item.kind].icon, size: 15 }),
|
|
329
|
+
kinds[item.kind].label
|
|
330
|
+
] }),
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { children: date(item.createdAt) })
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: item.title }),
|
|
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
|
+
] })
|
|
344
|
+
] }, item.id)),
|
|
345
|
+
items.length < total && /* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
347
|
+
selected && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "kl-detail", "aria-label": "\u8D44\u6599\u8BE6\u60C5", ref: detailRef, children: [
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-detail-toolbar", children: [
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-back", onClick: () => {
|
|
350
|
+
setSelected(void 0);
|
|
351
|
+
setDetail(void 0);
|
|
352
|
+
}, children: [
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "close", size: 18 }),
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u5173\u95ED\u9605\u8BFB" })
|
|
355
|
+
] }),
|
|
356
|
+
detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.jsx)(Icon, { name: "copy", size: 17 }) }),
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { title: "\u5BFC\u51FA Markdown", "aria-label": "\u5BFC\u51FA Markdown", href: `${API}/materials/${detail.id}/export`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "download", size: 17 }) }),
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => setEditor({ mode: "edit", source: detail }), children: "\u7F16\u8F91\u4FE1\u606F" })
|
|
360
|
+
] })
|
|
361
|
+
] }),
|
|
362
|
+
detailLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-empty", children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-spinner" }),
|
|
364
|
+
"\u8BFB\u53D6\u4E2D\u2026"
|
|
365
|
+
] }) : detail && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { children: [
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-detail-kicker", children: [
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: kinds[detail.kind].label }),
|
|
368
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.category })
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: detail.title }),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-source", children: [
|
|
372
|
+
detail.sourceUrl ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: detail.sourceUrl, target: "_blank", rel: "noreferrer", children: [
|
|
373
|
+
new URL(detail.sourceUrl).hostname,
|
|
374
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 12 })
|
|
375
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.originalName || "\u672C\u5730\u6536\u96C6" }),
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: new Date(detail.createdAt).toLocaleDateString("zh-CN") }),
|
|
377
|
+
detail.author && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: detail.author })
|
|
378
|
+
] }),
|
|
379
|
+
!!detail.tags.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-detail-tags", children: detail.tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "kl-chip", children: [
|
|
380
|
+
"#",
|
|
381
|
+
t
|
|
382
|
+
] }, t)) }),
|
|
383
|
+
detail.sourceNote && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("aside", { className: "kl-source-note", children: detail.sourceNote }),
|
|
384
|
+
detail.status === "stored" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-notice", children: [
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file" }),
|
|
386
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
387
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u539F\u6587\u4EF6\u5DF2\u5B89\u5168\u5F52\u6863" }),
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: detail.extraction })
|
|
389
|
+
] })
|
|
390
|
+
] }),
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-content", children: detail.segments.map((segment) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `kl-segment ${anchor === segment.id ? "kl-cited" : ""}`, id: segment.id, "data-segment-id": segment.id, children: [
|
|
392
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-segment-line", children: [
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: segment.startSeconds !== void 0 ? time(segment.startSeconds) : segment.id }),
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.jsx)(Icon, { name: "note", size: 14 }) }),
|
|
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 }) })
|
|
396
|
+
] }),
|
|
397
|
+
/^#{1,6}\s/.test(segment.text) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: segment.text.replace(/^#{1,6}\s+/, "") }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: segment.text })
|
|
398
|
+
] }, segment.id)) }),
|
|
399
|
+
!!detail.citations.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-references", children: [
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: "\u6765\u6E90\u5F15\u7528" }),
|
|
401
|
+
detail.citations.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { "aria-label": `\u67E5\u770B\u5F15\u7528 ${i + 1}`, onClick: () => {
|
|
402
|
+
setAnchor(c.segmentId);
|
|
403
|
+
setSelected(c.materialId);
|
|
404
|
+
}, children: [
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file", size: 15 }),
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
407
|
+
c.materialId.slice(0, 15),
|
|
408
|
+
"\u2026",
|
|
409
|
+
c.segmentId ? ` / ${c.segmentId}` : ""
|
|
410
|
+
] }),
|
|
411
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 14 })
|
|
412
|
+
] }, i))
|
|
413
|
+
] }),
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: "kl-detail-footer", children: [
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
|
|
417
|
+
detail.extraction
|
|
418
|
+
] }),
|
|
419
|
+
detail.originalFile && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("a", { href: `${API}/materials/${detail.id}/original`, children: [
|
|
420
|
+
"\u4E0B\u8F7D\u539F\u59CB\u6587\u4EF6",
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "download", size: 14 })
|
|
422
|
+
] }),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: detail.id })
|
|
424
|
+
] })
|
|
425
|
+
] })
|
|
426
|
+
] })
|
|
427
|
+
] })
|
|
428
|
+
] }),
|
|
429
|
+
editor && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EditorDialog, { editor, categories: stats?.categories.map((c) => c.name) || [], onClose: () => setEditor(void 0), onSaved: (result) => {
|
|
430
|
+
setEditor(void 0);
|
|
431
|
+
refresh();
|
|
432
|
+
if (result.material) {
|
|
433
|
+
chooseFilter({});
|
|
434
|
+
setQuery("");
|
|
435
|
+
setSelected(result.material.id);
|
|
436
|
+
notify(result.duplicate ? "\u8D44\u6599\u5DF2\u5B58\u5728\uFF0C\u5DF2\u6253\u5F00\u539F\u8BB0\u5F55" : "\u5DF2\u4FDD\u5B58\u5230\u672C\u5730\u8D44\u6599\u5E93");
|
|
437
|
+
} else if (result.id) {
|
|
438
|
+
setSelected(result.id);
|
|
439
|
+
notify("\u8D44\u6599\u4FE1\u606F\u5DF2\u66F4\u65B0");
|
|
440
|
+
} else {
|
|
441
|
+
setShowJobs(true);
|
|
442
|
+
notify("\u7F51\u9875\u5DF2\u52A0\u5165\u91C7\u96C6\u961F\u5217");
|
|
443
|
+
}
|
|
444
|
+
} }),
|
|
445
|
+
showJobs && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Dialog, { title: "\u91C7\u96C6\u4EFB\u52A1", description: "\u7F51\u9875\u5728\u540E\u53F0\u63D0\u53D6\u6B63\u6587\u3002\u5173\u95ED\u5E94\u7528\u540E\uFF0C\u4E0B\u6B21\u542F\u52A8\u4F1A\u6062\u590D\u672A\u5B8C\u6210\u4EFB\u52A1\u3002", onClose: () => setShowJobs(false), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-jobs", children: !jobs.length ? /* @__PURE__ */ (0, import_jsx_runtime2.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_runtime2.jsxs)("div", { className: "kl-job", children: [
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: `kl-job-status ${job.status}`, children: { queued: "\u6392\u961F\u4E2D", running: "\u63D0\u53D6\u4E2D", completed: "\u5DF2\u5B8C\u6210", failed: "\u5931\u8D25" }[job.status] }),
|
|
448
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { children: date(job.createdAt) })
|
|
449
|
+
] }),
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: job.url }),
|
|
451
|
+
job.error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: job.status === "failed" ? "alert" : void 0, children: job.error }),
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
453
|
+
job.materialId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { onClick: () => {
|
|
454
|
+
setSelected(job.materialId);
|
|
455
|
+
setShowJobs(false);
|
|
456
|
+
refresh();
|
|
457
|
+
}, children: [
|
|
458
|
+
"\u67E5\u770B\u8D44\u6599 ",
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 14 })
|
|
460
|
+
] }),
|
|
461
|
+
job.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: () => void post(`/jobs/${job.id}/retry`, {}).then(refresh).catch((e) => setError(e.message)), children: "\u91CD\u65B0\u91C7\u96C6" })
|
|
462
|
+
] })
|
|
463
|
+
] }, job.id)) }) }),
|
|
464
|
+
showInfo && /* @__PURE__ */ (0, import_jsx_runtime2.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: () => setShowInfo(false), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-info", children: [
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "\u8D44\u6599\u5E93\u76EE\u5F55" }),
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: stats?.root }),
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" }),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "\u672C\u7248\u672C\u53EF\u63D0\u53D6\u6587\u7AE0\u6B63\u6587\u53CA\u5B57\u5E55\uFF1B\u97F3\u89C6\u9891\u3001PDF \u7B49\u683C\u5F0F\u53EF\u4EE5\u5F52\u6863\uFF0C\u81EA\u52A8\u8F6C\u5199\u548C OCR \u5C1A\u672A\u63A5\u5165\u3002" }),
|
|
469
|
+
stats?.warnings.map((w) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: "alert", children: w }, w)),
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "kl-secondary", onClick: () => void post("/rebuild", {}).then(() => {
|
|
471
|
+
refresh();
|
|
472
|
+
notify("\u7D22\u5F15\u5DF2\u91CD\u5EFA");
|
|
473
|
+
}).catch((e) => setError(e.message)), children: "\u4ECE\u8D44\u6599\u6587\u4EF6\u91CD\u5EFA\u7D22\u5F15" })
|
|
474
|
+
] }) }),
|
|
475
|
+
toast && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-toast", role: "status", children: [
|
|
476
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "check", size: 17 }),
|
|
477
|
+
toast
|
|
478
|
+
] })
|
|
479
|
+
] });
|
|
480
|
+
}
|
|
481
|
+
function Dialog({ title, description, onClose, children }) {
|
|
482
|
+
const ref = (0, import_react.useRef)(null);
|
|
483
|
+
const closeRef = (0, import_react.useRef)(onClose);
|
|
484
|
+
closeRef.current = onClose;
|
|
485
|
+
(0, import_react.useEffect)(() => {
|
|
486
|
+
const previous = document.activeElement;
|
|
487
|
+
const timer = setTimeout(() => ref.current?.querySelector("input,textarea,button")?.focus(), 0);
|
|
488
|
+
const key = (event) => {
|
|
489
|
+
if (event.key === "Escape") closeRef.current();
|
|
490
|
+
if (event.key === "Tab") {
|
|
491
|
+
const elements = Array.from(ref.current?.querySelectorAll("button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select,a[href]") || []);
|
|
492
|
+
const first = elements[0], last = elements[elements.length - 1];
|
|
493
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
last?.focus();
|
|
496
|
+
}
|
|
497
|
+
if (!event.shiftKey && document.activeElement === last) {
|
|
498
|
+
event.preventDefault();
|
|
499
|
+
first?.focus();
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
document.addEventListener("keydown", key);
|
|
504
|
+
return () => {
|
|
505
|
+
clearTimeout(timer);
|
|
506
|
+
document.removeEventListener("keydown", key);
|
|
507
|
+
previous?.focus();
|
|
508
|
+
};
|
|
509
|
+
}, []);
|
|
510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-modal-backdrop", onMouseDown: (event) => {
|
|
511
|
+
if (event.target === event.currentTarget) onClose();
|
|
512
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, ref, children: [
|
|
513
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { children: [
|
|
514
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: title }),
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description })
|
|
517
|
+
] }),
|
|
518
|
+
/* @__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" }) })
|
|
519
|
+
] }),
|
|
520
|
+
children
|
|
521
|
+
] }) });
|
|
522
|
+
}
|
|
523
|
+
function EditorDialog({ editor, categories, onClose, onSaved }) {
|
|
524
|
+
const editing = editor.mode === "edit";
|
|
525
|
+
const note = editor.mode === "note";
|
|
526
|
+
const source = editor.source;
|
|
527
|
+
const [type, setType] = (0, import_react.useState)("url");
|
|
528
|
+
const [title, setTitle] = (0, import_react.useState)(editing ? source?.title || "" : note && source ? `${source.title} \xB7 \u6458\u5F55` : "");
|
|
529
|
+
const [content, setContent] = (0, import_react.useState)(editor.segment ? `> ${editor.segment.text}
|
|
530
|
+
|
|
531
|
+
` : "");
|
|
532
|
+
const [category, setCategory] = (0, import_react.useState)(editing ? source?.category || "\u6536\u4EF6\u7BB1" : note ? "\u77E5\u8BC6\u7B14\u8BB0" : "\u6536\u4EF6\u7BB1");
|
|
533
|
+
const [tags, setTags] = (0, import_react.useState)(editing ? source?.tags.join("\uFF0C") || "" : "");
|
|
534
|
+
const [collection, setCollection] = (0, import_react.useState)(source?.collection || "");
|
|
535
|
+
const [sourceNote, setSourceNote] = (0, import_react.useState)(editing ? source?.sourceNote || "" : "");
|
|
536
|
+
const [file, setFile] = (0, import_react.useState)();
|
|
537
|
+
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
538
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
539
|
+
const citations = source && note ? [{ materialId: source.id, ...editor.segment ? { segmentId: editor.segment.id } : {} }] : [];
|
|
540
|
+
async function submit(event) {
|
|
541
|
+
event.preventDefault();
|
|
542
|
+
setError("");
|
|
543
|
+
setBusy(true);
|
|
544
|
+
try {
|
|
545
|
+
const data = { title, category, tags: splitTags(tags), collection, sourceNote };
|
|
546
|
+
let result;
|
|
547
|
+
if (editing) result = await post(`/materials/${source.id}`, data, "PATCH");
|
|
548
|
+
else if (note) result = await post("/notes", { ...data, content, citations });
|
|
549
|
+
else if (type === "file") {
|
|
550
|
+
if (!file) throw new Error("\u8BF7\u9009\u62E9\u4E00\u4E2A\u6587\u4EF6");
|
|
551
|
+
if (file.size > 64 * 1024 * 1024) throw new Error("\u6587\u4EF6\u8D85\u8FC7 64 MB\uFF0C\u8BF7\u5148\u62C6\u5206\u6216\u5BFC\u5165\u5B57\u5E55");
|
|
552
|
+
const base64 = await new Promise((resolve, reject) => {
|
|
553
|
+
const reader = new FileReader();
|
|
554
|
+
reader.onload = () => resolve(String(reader.result).split(",")[1]);
|
|
555
|
+
reader.onerror = () => reject(new Error("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6"));
|
|
556
|
+
reader.readAsDataURL(file);
|
|
557
|
+
});
|
|
558
|
+
result = await post("/upload", { ...data, name: file.name, base64 });
|
|
559
|
+
} else result = await post("/capture", { ...data, type, content });
|
|
560
|
+
onSaved(result);
|
|
561
|
+
} catch (e) {
|
|
562
|
+
setError(e.message);
|
|
563
|
+
} finally {
|
|
564
|
+
setBusy(false);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
const changeType = (value) => {
|
|
568
|
+
setType(value);
|
|
569
|
+
setContent("");
|
|
570
|
+
setError("");
|
|
571
|
+
};
|
|
572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
if (!busy) onClose();
|
|
574
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { onSubmit: submit, className: "kl-editor", children: [
|
|
575
|
+
!editing && !note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-tabs", role: "tablist", "aria-label": "\u91C7\u96C6\u65B9\u5F0F", children: ["url", "text", "file"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", role: "tab", "aria-selected": type === value, className: type === value ? "active" : "", onClick: () => changeType(value), children: [
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: value === "url" ? "web" : value === "file" ? "upload" : "file", size: 17 }),
|
|
577
|
+
value === "url" ? "\u7F51\u9875\u94FE\u63A5" : value === "file" ? "\u672C\u5730\u6587\u4EF6" : "\u6587\u672C\u6458\u5F55"
|
|
578
|
+
] }, value)) }),
|
|
579
|
+
!editing && !note && type === "url" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
580
|
+
"\u7F51\u9875\u5730\u5740",
|
|
581
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "url", required: true, placeholder: "https://\u2026", value: content, onChange: (e) => setContent(e.target.value) }),
|
|
582
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
584
|
+
!editing && !note && type === "file" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "kl-upload", children: [
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "upload", size: 27 }),
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: file?.name || "\u9009\u62E9\u6216\u62D6\u5165\u6587\u4EF6" }),
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6587\u672C\u3001HTML\u3001SRT / VTT \u5B57\u5E55\u53CA\u5176\u4ED6\u6587\u4EF6 \xB7 \u6700\u5927 64 MB" }),
|
|
588
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { "aria-label": "\u9009\u62E9\u672C\u5730\u6587\u4EF6", type: "file", onChange: (e) => setFile(e.target.files?.[0]) }),
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
592
|
+
"\u6807\u9898",
|
|
593
|
+
!editing && !note && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
596
|
+
!editing && (note || type === "text") && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
597
|
+
note ? "\u7B14\u8BB0\u5185\u5BB9" : "\u6B63\u6587",
|
|
598
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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" })
|
|
599
|
+
] }),
|
|
600
|
+
!!citations.length && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-citation-preview", children: [
|
|
601
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "file", size: 16 }),
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
603
|
+
"\u5F15\u7528\uFF1A",
|
|
604
|
+
source.title,
|
|
605
|
+
editor.segment ? ` / ${editor.segment.id}` : ""
|
|
606
|
+
] })
|
|
607
|
+
] }),
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "kl-form-grid", children: [
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
610
|
+
"\u5206\u7C7B",
|
|
611
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { list: "kl-categories", value: category, onChange: (e) => setCategory(e.target.value), placeholder: "\u4F8B\u5982 \u6280\u672F/AI" }),
|
|
612
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("datalist", { id: "kl-categories", children: categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: c }, c)) })
|
|
613
|
+
] }),
|
|
614
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
615
|
+
"\u4E13\u9898",
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { value: collection, onChange: (e) => setCollection(e.target.value), placeholder: "\u56F4\u7ED5\u4E00\u4E2A\u95EE\u9898\u7EC4\u7EC7\u8D44\u6599" })
|
|
618
|
+
] })
|
|
619
|
+
] }),
|
|
620
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
621
|
+
"\u6807\u7B7E",
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
|
|
623
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
626
|
+
"\u6765\u6E90\u5907\u6CE8",
|
|
627
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: "\u53EF\u9009" }),
|
|
628
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.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
|
+
] }),
|
|
630
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "kl-form-error", role: "alert", children: error }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { children: [
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "kl-live-dot" }),
|
|
634
|
+
"\u4EC5\u4FDD\u5B58\u5728\u672C\u5730"
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "kl-secondary", disabled: busy, onClick: onClose, children: "\u53D6\u6D88" }),
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "kl-primary", type: "submit", disabled: busy, children: [
|
|
638
|
+
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, import_jsx_runtime2.jsx)(Icon, { name: "arrow", size: 16 })
|
|
640
|
+
] })
|
|
641
|
+
] })
|
|
642
|
+
] }) });
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// src/ui/style.css
|
|
646
|
+
var style_default = `/* Harness owns the palette and font. Fallbacks are for the standalone preview. */
|
|
647
|
+
.kl-app {
|
|
648
|
+
--kl-bg: var(--dsw-alias-bg-base, light-dark(#fff, #191a1e));
|
|
649
|
+
--kl-panel: var(--dsw-alias-bg-layer-1, light-dark(#fff, #24252a));
|
|
650
|
+
--kl-sidebar: var(--dsw-specific-sidebar-fill, light-dark(#f8f9fa, #202126));
|
|
651
|
+
--kl-ink: var(--dsw-alias-label-primary, light-dark(#18191d, #f3f4f6));
|
|
652
|
+
--kl-secondary: var(--dsw-alias-label-secondary, light-dark(#555963, #c0c2c9));
|
|
653
|
+
--kl-muted: var(--dsw-alias-label-tertiary, light-dark(#858991, #979ba5));
|
|
654
|
+
--kl-caption: var(--dsw-alias-label-caption, light-dark(#a3a7b0, #737781));
|
|
655
|
+
--kl-line: var(--dsw-alias-border-l3, light-dark(#0000001f, #ffffff29));
|
|
656
|
+
--kl-divider: var(--dsw-alias-border-l1, light-dark(#0000000a, #ffffff0f));
|
|
657
|
+
--kl-hover: var(--dsw-alias-interactive-bg-hover, light-dark(#2631480f, #ffffff14));
|
|
658
|
+
--kl-active: var(--dsw-alias-interactive-bg-active, light-dark(#2631481a, #ffffff24));
|
|
659
|
+
--kl-primary: var(--dsw-alias-button-primary-fill, light-dark(#14151a, #f3f4f6));
|
|
660
|
+
--kl-primary-hover: var(--dsw-alias-button-primary-hover, light-dark(#373941, #dfe1e6));
|
|
661
|
+
--kl-on-primary: var(--dsw-alias-label-primary-foreground, light-dark(#fff, #14151a));
|
|
662
|
+
--kl-focus: var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary, #4d6bfe));
|
|
663
|
+
--kl-link: var(--dsw-alias-link, light-dark(#4162e7, #91a2ff));
|
|
664
|
+
--kl-success: var(--dsw-alias-state-success-primary, #36a774);
|
|
665
|
+
--kl-error: var(--dsw-alias-state-error-primary, light-dark(#c63e43, #ff8589));
|
|
666
|
+
--kl-warn: var(--dsw-alias-state-warn-label, light-dark(#926316, #d5ad62));
|
|
667
|
+
--kl-radius: var(--dsw-radius-md, 12px);
|
|
668
|
+
--kl-radius-lg: var(--dsw-radius-lg, 16px);
|
|
669
|
+
--kl-gutter: clamp(24px, 4cqi, 48px);
|
|
670
|
+
font-family: var(--dsw-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif);
|
|
671
|
+
font-size: 14px;
|
|
672
|
+
line-height: 1.6;
|
|
673
|
+
font-synthesis: none;
|
|
674
|
+
color: var(--kl-ink);
|
|
675
|
+
background: var(--kl-bg);
|
|
676
|
+
width: 100%;
|
|
677
|
+
height: 100%;
|
|
678
|
+
min-width: 0;
|
|
679
|
+
min-height: 0;
|
|
680
|
+
display: flex;
|
|
681
|
+
overflow: hidden;
|
|
682
|
+
container: knowledge-library / inline-size;
|
|
683
|
+
}
|
|
684
|
+
.kl-app, .kl-app * { box-sizing: border-box; }
|
|
685
|
+
.kl-preview { margin: 0; color-scheme: light dark; }
|
|
686
|
+
.kl-preview > #root > .kl-app { height: 100dvh; }
|
|
687
|
+
.kl-app button, .kl-app input, .kl-app textarea, .kl-app select { font: inherit; color: inherit; }
|
|
688
|
+
.kl-app button, .kl-app a { -webkit-tap-highlight-color: transparent; }
|
|
689
|
+
.kl-app button { cursor: pointer; transition: background-color .12s, color .12s, border-color .12s; }
|
|
690
|
+
.kl-app button:disabled { opacity: .5; cursor: not-allowed; }
|
|
691
|
+
.kl-app :is(button, a, input, textarea, select):focus-visible { outline: 2px solid var(--kl-focus); outline-offset: 2px; }
|
|
692
|
+
.kl-app input::placeholder, .kl-app textarea::placeholder { color: var(--kl-caption); }
|
|
693
|
+
.kl-app svg { flex-shrink: 0; }
|
|
694
|
+
.kl-app :is(time, small) { font-variant-numeric: tabular-nums; }
|
|
695
|
+
.kl-app :is(.kl-list, .kl-nav, .kl-detail, .kl-dialog) {
|
|
696
|
+
scrollbar-width: thin;
|
|
697
|
+
scrollbar-color: var(--dsw-alias-scrollbar-bg-l2, #8885) transparent;
|
|
698
|
+
overscroll-behavior: contain;
|
|
699
|
+
}
|
|
700
|
+
.kl-workspace { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
|
|
701
|
+
.kl-primary, .kl-secondary {
|
|
702
|
+
min-height: 32px; border-radius: var(--kl-radius-lg); padding: 5px 12px; font-size: 13px !important;
|
|
703
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
|
|
704
|
+
}
|
|
705
|
+
.kl-app .kl-primary { color: var(--kl-on-primary); background: var(--kl-primary); border: 1px solid transparent; }
|
|
706
|
+
.kl-app .kl-primary:hover:not(:disabled) { background: var(--kl-primary-hover); }
|
|
707
|
+
.kl-secondary { background: transparent; border: .5px solid var(--kl-line); }
|
|
708
|
+
.kl-secondary:hover:not(:disabled) { background: var(--kl-hover); }
|
|
709
|
+
.kl-app .kl-icon-button {
|
|
710
|
+
width: 32px; height: 32px; padding: 6px; border: 0; border-radius: 8px; flex: none;
|
|
711
|
+
display: inline-flex; align-items: center; justify-content: center; color: var(--kl-muted); background: transparent;
|
|
712
|
+
}
|
|
713
|
+
.kl-app .kl-icon-button:hover { color: var(--kl-ink); background: var(--kl-hover); }
|
|
714
|
+
.kl-header { padding: 28px var(--kl-gutter) 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
|
|
715
|
+
[data-platform="darwin"] .kl-header { padding-top: calc(28px + var(--dsh-frame-top-clearance, 0px)); }
|
|
716
|
+
.kl-header h1 { margin: 0; min-width: 0; font-size: 20px; line-height: 28px; font-weight: 500; overflow-wrap: anywhere; }
|
|
717
|
+
.kl-header-actions { display: flex; align-items: center; gap: 8px; flex: none; }
|
|
718
|
+
.kl-navigation { padding: 0 var(--kl-gutter) 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
719
|
+
.kl-navigation nav { display: flex; flex-wrap: wrap; gap: 8px 12px; }
|
|
720
|
+
.kl-navigation button { border: 0; border-radius: 14px; background: transparent; color: var(--kl-muted); padding: 3px 10px; min-height: 28px; }
|
|
721
|
+
.kl-navigation button:hover, .kl-navigation button[aria-pressed="true"], .kl-navigation button[aria-expanded="true"] { background: var(--kl-hover); color: var(--kl-ink); }
|
|
722
|
+
.kl-navigation .kl-directory-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
|
|
723
|
+
.kl-toolbar { padding: 0 var(--kl-gutter) 16px; display: flex; gap: 12px; align-items: center; }
|
|
724
|
+
.kl-search { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; height: 36px; border: .5px solid var(--kl-line); border-radius: var(--kl-radius); padding: 0 10px; color: var(--kl-caption); }
|
|
725
|
+
.kl-search > svg { width: 16px; height: 16px; }
|
|
726
|
+
.kl-search input { width: 0; min-width: 0; flex: 1; border: 0; padding: 0; height: 100%; background: transparent; color: var(--kl-ink); font-size: 14px; }
|
|
727
|
+
.kl-app .kl-search input:focus-visible { outline: none; }
|
|
728
|
+
.kl-search:focus-within { border-color: var(--kl-focus); }
|
|
729
|
+
.kl-search kbd { color: var(--kl-caption); border: .5px solid var(--kl-line); border-radius: 4px; padding: 0 4px; font-family: inherit; font-size: 10px; line-height: 18px; white-space: nowrap; }
|
|
730
|
+
.kl-app .kl-job-button { border: 0; border-radius: 8px; background: transparent; display: flex; align-items: center; gap: 6px; color: var(--kl-muted); padding: 6px; min-height: 32px; white-space: nowrap; font-size: 13px; }
|
|
731
|
+
.kl-job-button:hover { background: var(--kl-hover); }
|
|
732
|
+
.kl-job-button i { width: 5px; height: 5px; border-radius: 50%; corner-shape: round; background: var(--kl-error); }
|
|
733
|
+
.kl-app .kl-job-button.has-jobs { color: var(--kl-link); }
|
|
734
|
+
.kl-filterbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 var(--kl-gutter) 12px; color: var(--kl-muted); font-size: 12px; }
|
|
735
|
+
.kl-filterbar > span { min-width: 0; overflow-wrap: anywhere; }
|
|
736
|
+
.kl-filterbar b { font-weight: 400; }
|
|
737
|
+
.kl-filterbar > div { display: flex; align-items: center; gap: 16px; flex: none; }
|
|
738
|
+
.kl-filterbar select { background: var(--kl-bg); color: var(--kl-muted); border: 0; border-radius: 6px; padding: 3px; max-width: 110px; font-size: 12px; }
|
|
739
|
+
.kl-body { position: relative; display: flex; flex: 1; min-height: 0; overflow: hidden; }
|
|
740
|
+
.kl-list { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 calc(var(--kl-gutter) - 8px) 24px; }
|
|
741
|
+
.kl-body.with-detail .kl-list { flex: 0 0 38%; padding: 0 16px 24px calc(var(--kl-gutter) - 8px); }
|
|
742
|
+
.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
|
+
.kl-item:hover, .kl-item.selected { background: var(--kl-hover); }
|
|
744
|
+
.kl-item-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 5px; }
|
|
745
|
+
.kl-type { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--kl-muted); }
|
|
746
|
+
.kl-item time { color: var(--kl-muted); font-size: 12px; }
|
|
747
|
+
.kl-item h2 { margin: 0 0 5px; font-size: 14px; line-height: 23px; font-weight: 500; overflow-wrap: anywhere; }
|
|
748
|
+
.kl-item > p { margin: 0 0 10px; font-size: 13px; line-height: 21px; color: var(--kl-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
|
|
749
|
+
.kl-item-bottom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
|
750
|
+
.kl-category { display: flex; align-items: center; gap: 4px; max-width: 60%; overflow: hidden; white-space: nowrap; color: var(--kl-muted); font-size: 11px; }
|
|
751
|
+
.kl-chip { padding: 1px 6px; border-radius: 5px; background: var(--kl-hover); color: var(--kl-secondary); font-size: 11px; max-width: 100%; overflow-wrap: anywhere; }
|
|
752
|
+
.kl-item-bottom > svg { margin-left: auto; color: var(--kl-caption); }
|
|
753
|
+
.kl-stored { color: var(--kl-warn); font-size: 11px; }
|
|
754
|
+
.kl-load-more { width: 100%; padding: 16px; border: 0; border-radius: 8px; background: transparent; color: var(--kl-muted); font-size: 13px; }
|
|
755
|
+
.kl-load-more:hover { background: var(--kl-hover); }
|
|
756
|
+
|
|
757
|
+
/* An optional directory leaves the default view as uncluttered as native pages. */
|
|
758
|
+
.kl-nav { width: 200px; max-width: 80%; flex: none; padding: 12px; margin-left: var(--kl-gutter); border-right: .5px solid var(--kl-line); background: var(--kl-bg); overflow-y: auto; display: flex; flex-direction: column; }
|
|
759
|
+
.kl-directory-title { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 500; }
|
|
760
|
+
.kl-nav-section { margin-top: 20px; }
|
|
761
|
+
.kl-nav-label { padding: 0 8px 8px; color: var(--kl-muted); font-size: 12px; }
|
|
762
|
+
.kl-nav-row { width: 100%; display: flex; align-items: center; gap: 8px; background: transparent; border: 0; border-radius: 8px; padding: 8px; text-align: left; min-width: 0; font-size: 13px !important; }
|
|
763
|
+
.kl-nav-row > span:not(.kl-collection-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
764
|
+
.kl-nav-row > svg { color: var(--kl-muted); }
|
|
765
|
+
.kl-nav-row small { margin-left: auto; color: var(--kl-muted); font-size: 11px; }
|
|
766
|
+
.kl-nav button:hover, .kl-nav button[aria-pressed="true"] { background: var(--kl-hover); }
|
|
767
|
+
.kl-nav-hint { color: var(--kl-muted); font-size: 12px; margin: 0; padding: 0 8px; }
|
|
768
|
+
.kl-collection-dot { width: 6px; height: 6px; border-radius: 50%; corner-shape: round; border: 1px solid var(--kl-muted); flex: none; margin: 0 5px; }
|
|
769
|
+
.kl-tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
|
|
770
|
+
.kl-tag-cloud button { background: transparent; color: var(--kl-muted); border: 0; border-radius: 6px; padding: 3px 6px; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
|
|
771
|
+
.kl-nav-bottom { display: flex; align-items: center; gap: 6px; margin-top: auto; padding: 28px 8px 8px; color: var(--kl-muted); font-size: 11px; }
|
|
772
|
+
.kl-live-dot { width: 5px; height: 5px; border-radius: 50%; corner-shape: round; background: var(--kl-success); display: inline-block; flex-shrink: 0; }
|
|
773
|
+
.kl-detail { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; border-left: .5px solid var(--kl-line); background: var(--kl-bg); }
|
|
774
|
+
.kl-detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 20px; border-bottom: .5px solid var(--kl-divider); position: sticky; top: 0; background: var(--kl-bg); z-index: 1; }
|
|
775
|
+
.kl-detail-toolbar > div { display: flex; align-items: center; gap: 4px; }
|
|
776
|
+
.kl-detail-toolbar button, .kl-detail-toolbar a { display: flex; align-items: center; gap: 5px; background: transparent; border: 0; border-radius: 8px; min-height: 32px; padding: 6px 8px; color: var(--kl-muted); text-decoration: none; font-size: 12px; white-space: nowrap; }
|
|
777
|
+
.kl-detail-toolbar :is(button, a):hover { color: var(--kl-ink); background: var(--kl-hover); }
|
|
778
|
+
.kl-detail article { max-width: 800px; margin: 0 auto; padding: 24px 28px 40px; }
|
|
779
|
+
.kl-detail-kicker { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--kl-muted); overflow-wrap: anywhere; }
|
|
780
|
+
.kl-detail-kicker span + span::before { content: "/"; margin-right: 8px; color: var(--kl-caption); }
|
|
781
|
+
.kl-detail article > h2 { margin: 10px 0 12px; font-size: 20px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
|
|
782
|
+
.kl-source { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--kl-muted); font-size: 12px; overflow-wrap: anywhere; }
|
|
783
|
+
.kl-source a { color: var(--kl-link); display: flex; align-items: center; gap: 4px; text-decoration: none; }
|
|
784
|
+
.kl-source a:hover { text-decoration: underline; }
|
|
785
|
+
.kl-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
|
|
786
|
+
.kl-source-note { border-left: 2px solid var(--kl-line); padding: 10px 12px; font-size: 13px; line-height: 1.7; color: var(--kl-secondary); background: var(--kl-sidebar); margin: 20px 0; overflow-wrap: anywhere; }
|
|
787
|
+
.kl-content { margin-top: 24px; }
|
|
788
|
+
.kl-segment { margin-bottom: 20px; scroll-margin-top: 64px; }
|
|
789
|
+
.kl-segment.kl-cited { background: var(--kl-hover); box-shadow: 0 0 0 8px var(--kl-hover); border-radius: 4px; }
|
|
790
|
+
.kl-segment-line { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 11px; color: var(--kl-muted); font-variant-numeric: tabular-nums; }
|
|
791
|
+
.kl-segment-line > span { margin-right: auto; }
|
|
792
|
+
.kl-segment-line button { display: grid; place-items: center; width: 26px; height: 26px; background: transparent; border: 0; border-radius: 6px; color: var(--kl-muted); opacity: .6; padding: 4px; }
|
|
793
|
+
.kl-segment:hover button, .kl-segment:focus-within button { opacity: 1; }
|
|
794
|
+
.kl-segment-line button:hover { background: var(--kl-hover); }
|
|
795
|
+
.kl-segment p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--dsh-content-font-size, 14px); line-height: 1.8; margin: 0; color: var(--kl-ink); }
|
|
796
|
+
.kl-segment h3 { font-size: calc(16px + var(--dsh-content-font-delta, 0px)); line-height: 1.7; margin: 0; font-weight: 500; overflow-wrap: anywhere; }
|
|
797
|
+
.kl-detail-footer { margin-top: 32px; padding-top: 16px; border-top: .5px solid var(--kl-line); font-size: 11px; color: var(--kl-muted); }
|
|
798
|
+
.kl-detail-footer > div { display: flex; gap: 6px; align-items: center; }
|
|
799
|
+
.kl-detail-footer a { display: flex; align-items: center; gap: 6px; color: var(--kl-link); text-decoration: none; margin: 12px 0; }
|
|
800
|
+
.kl-detail-footer code { display: block; font-size: 10px; margin-top: 12px; overflow-wrap: anywhere; }
|
|
801
|
+
.kl-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 20px; text-align: center; color: var(--kl-muted); }
|
|
802
|
+
.kl-empty > svg { color: var(--kl-caption); margin-bottom: 4px; }
|
|
803
|
+
.kl-empty h2 { font-size: 14px; font-weight: 400; line-height: 1.6; margin: 0; color: var(--kl-muted); }
|
|
804
|
+
.kl-empty p { font-size: 13px; margin: 0; }
|
|
805
|
+
.kl-empty .kl-secondary { margin-top: 12px; color: var(--kl-ink); }
|
|
806
|
+
.kl-notice { display: flex; gap: 10px; padding: 14px; background: var(--kl-sidebar); margin-top: 20px; border-radius: 10px; color: var(--kl-secondary); }
|
|
807
|
+
.kl-notice strong { font-size: 13px; font-weight: 500; }
|
|
808
|
+
.kl-notice p { font-size: 12px; line-height: 1.7; margin: 4px 0 0; }
|
|
809
|
+
.kl-references { background: var(--kl-sidebar); padding: 14px; border-radius: 10px; margin-top: 24px; }
|
|
810
|
+
.kl-references h3 { font-size: 13px; font-weight: 500; margin: 0 0 8px; }
|
|
811
|
+
.kl-references button { display: flex; gap: 7px; align-items: center; border: 0; background: transparent; color: var(--kl-link); border-radius: 6px; font-size: 12px; padding: 6px; width: 100%; text-align: left; }
|
|
812
|
+
.kl-references button:hover { background: var(--kl-hover); }
|
|
813
|
+
.kl-references button > svg:last-child { margin-left: auto; }
|
|
814
|
+
.kl-references button > span { min-width: 0; overflow-wrap: anywhere; }
|
|
815
|
+
|
|
816
|
+
/* Dialogs remain descendants of .kl-app, so they inherit the same theme. */
|
|
817
|
+
.kl-modal-backdrop { position: fixed; inset: 0; background: var(--dsw-alias-bg-mask-1, #0006); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; }
|
|
818
|
+
.kl-dialog { background: var(--kl-panel); color: var(--kl-ink); width: 580px; max-width: 100%; max-height: calc(100dvh - 48px); overflow: auto; border: .5px solid var(--kl-line); border-radius: var(--kl-radius-lg); box-shadow: var(--dsw-elevation-prominent, 0 16px 64px #0003); animation: kl-enter .15s ease-out; }
|
|
819
|
+
.kl-dialog > header { padding: 24px 24px 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
|
|
820
|
+
.kl-dialog > header h2 { margin: 0 0 6px; font-size: 18px; line-height: 26px; font-weight: 500; }
|
|
821
|
+
.kl-dialog > header p { margin: 0; color: var(--kl-muted); font-size: 12px; line-height: 1.7; }
|
|
822
|
+
.kl-dialog > header > button { border: 0; border-radius: 8px; background: transparent; color: var(--kl-muted); padding: 4px; display: flex; }
|
|
823
|
+
.kl-dialog > header > button:hover { background: var(--kl-hover); }
|
|
824
|
+
.kl-editor { padding: 0 24px; }
|
|
825
|
+
.kl-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
|
|
826
|
+
.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; }
|
|
827
|
+
.kl-tabs button:hover, .kl-tabs button.active { background: var(--kl-hover); color: var(--kl-ink); }
|
|
828
|
+
.kl-editor label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--kl-secondary); margin-bottom: 16px; position: relative; min-width: 0; }
|
|
829
|
+
.kl-editor label > em { position: absolute; right: 0; top: 0; font-size: 11px; color: var(--kl-muted); font-style: normal; }
|
|
830
|
+
.kl-editor input, .kl-editor textarea { width: 100%; background: transparent; border: .5px solid var(--kl-line); border-radius: 10px; padding: 9px 11px; color: var(--kl-ink); font-size: 13px; }
|
|
831
|
+
.kl-editor textarea { resize: vertical; line-height: 1.7; min-height: 120px; max-height: 280px; }
|
|
832
|
+
.kl-editor label > small { color: var(--kl-muted); font-size: 11px; line-height: 1.7; }
|
|
833
|
+
.kl-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
|
|
834
|
+
.kl-editor footer { display: flex; align-items: center; gap: 8px; margin: 20px -24px 0; padding: 16px 24px; border-top: .5px solid var(--kl-divider); }
|
|
835
|
+
.kl-editor footer > span { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--kl-muted); margin-right: auto; }
|
|
836
|
+
.kl-editor .kl-upload { align-items: center; gap: 10px; border: 1px dashed var(--kl-line); background: var(--kl-sidebar); padding: 22px 16px; border-radius: var(--kl-radius); text-align: center; }
|
|
837
|
+
.kl-upload > strong { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
|
|
838
|
+
.kl-upload > span { font-size: 11px; color: var(--kl-muted); }
|
|
839
|
+
.kl-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
|
|
840
|
+
.kl-upload:focus-within { outline: 2px solid var(--kl-focus); outline-offset: 2px; }
|
|
841
|
+
.kl-citation-preview { display: flex; gap: 8px; align-items: center; background: var(--kl-sidebar); font-size: 12px; color: var(--kl-secondary); padding: 10px; border-radius: 8px; margin-bottom: 18px; overflow-wrap: anywhere; }
|
|
842
|
+
.kl-jobs, .kl-info { padding: 0 24px 24px; }
|
|
843
|
+
.kl-muted { color: var(--kl-muted); font-size: 13px; }
|
|
844
|
+
.kl-job { border-bottom: .5px solid var(--kl-line); padding: 0 0 18px; margin-bottom: 18px; }
|
|
845
|
+
.kl-job:last-child { margin-bottom: 0; }
|
|
846
|
+
.kl-job > div { display: flex; justify-content: space-between; align-items: center; }
|
|
847
|
+
.kl-job time { font-size: 11px; color: var(--kl-muted); }
|
|
848
|
+
.kl-job > strong { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 400; margin: 12px 0; }
|
|
849
|
+
.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); }
|
|
852
|
+
.kl-job-status { font-size: 11px; border-radius: 6px; padding: 3px 7px; background: var(--kl-hover); color: var(--kl-secondary); }
|
|
853
|
+
.kl-job-status.failed { color: var(--kl-error); }
|
|
854
|
+
.kl-job-status.running { color: var(--kl-link); }
|
|
855
|
+
.kl-info label { display: block; font-size: 12px; color: var(--kl-muted); margin-bottom: 8px; }
|
|
856
|
+
.kl-info code { display: block; overflow-wrap: anywhere; background: var(--kl-sidebar); padding: 12px; border-radius: 8px; font-size: 12px; }
|
|
857
|
+
.kl-info p { font-size: 13px; line-height: 1.8; color: var(--kl-secondary); margin: 16px 0; }
|
|
858
|
+
.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
|
+
.kl-error { display: flex; align-items: center; gap: 12px; margin: 0 var(--kl-gutter) 14px; }
|
|
860
|
+
.kl-error button { margin-left: auto; border: 0; background: transparent; color: inherit; display: flex; padding: 4px; }
|
|
861
|
+
.kl-form-error { margin-bottom: 14px; }
|
|
862
|
+
.kl-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); background: var(--dsw-alias-toast-bg, #303136); color: var(--dsw-alias-toast-label, #fff); padding: 10px 16px; display: flex; gap: 8px; align-items: center; border-radius: 12px; box-shadow: 0 4px 20px #0002; font-size: 13px; z-index: 1100; }
|
|
863
|
+
.kl-spinner { height: 20px; width: 20px; border: 2px solid var(--kl-line); border-top-color: var(--kl-muted); border-radius: 50%; corner-shape: round; animation: kl-spin 1s linear infinite; }
|
|
864
|
+
@keyframes kl-spin { to { transform: rotate(360deg); } }
|
|
865
|
+
@keyframes kl-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
|
866
|
+
|
|
867
|
+
/* Respond to the plugin's available space, including the host's side panels. */
|
|
868
|
+
@container knowledge-library (max-width: 900px) {
|
|
869
|
+
.kl-body.with-detail .kl-list { display: none; }
|
|
870
|
+
.kl-detail { border-left: 0; }
|
|
871
|
+
.kl-detail article { padding: 24px var(--kl-gutter) 36px; }
|
|
872
|
+
.kl-detail-toolbar { padding: 8px calc(var(--kl-gutter) - 8px); }
|
|
873
|
+
.kl-nav { position: absolute; top: 0; bottom: 0; left: 0; z-index: 2; margin: 0; width: 240px; border-top: .5px solid var(--kl-line); box-shadow: 8px 0 24px #0001; }
|
|
874
|
+
}
|
|
875
|
+
@container knowledge-library (max-width: 520px) {
|
|
876
|
+
.kl-header { padding: 20px 20px 18px; flex-wrap: wrap; gap: 12px; }
|
|
877
|
+
.kl-header h1 { font-size: 20px; }
|
|
878
|
+
.kl-header-actions { margin-left: auto; }
|
|
879
|
+
.kl-navigation { padding: 0 20px 12px; flex-wrap: wrap; gap: 8px; }
|
|
880
|
+
.kl-navigation nav { gap: 4px; }
|
|
881
|
+
.kl-navigation .kl-directory-toggle { margin-left: auto; }
|
|
882
|
+
.kl-toolbar { padding: 0 20px 12px; gap: 4px; }
|
|
883
|
+
.kl-search kbd, .kl-job-button span, .kl-sort-label { display: none; }
|
|
884
|
+
.kl-filterbar { padding: 0 20px 10px; }
|
|
885
|
+
.kl-list { padding: 0 12px 16px; }
|
|
886
|
+
.kl-empty { padding: 40px 12px; }
|
|
887
|
+
.kl-detail article { padding: 20px; }
|
|
888
|
+
.kl-detail-toolbar { padding: 8px 12px; }
|
|
889
|
+
.kl-error { margin: 0 20px 12px; }
|
|
890
|
+
}
|
|
891
|
+
/* Fixed dialogs use viewport width even when the host panel is narrow. */
|
|
892
|
+
@media (max-width: 600px) {
|
|
893
|
+
.kl-modal-backdrop { padding: 12px; }
|
|
894
|
+
.kl-dialog { max-height: calc(100dvh - 24px); }
|
|
895
|
+
.kl-dialog > header { padding: 20px 18px 16px; }
|
|
896
|
+
.kl-editor { padding: 0 18px; }
|
|
897
|
+
.kl-editor footer { margin-left: -18px; margin-right: -18px; padding: 14px 18px; }
|
|
898
|
+
.kl-editor footer > span { font-size: 10px; }
|
|
899
|
+
.kl-tabs { gap: 4px; }
|
|
900
|
+
.kl-tabs button { padding: 5px; font-size: 12px; }
|
|
901
|
+
.kl-form-grid { gap: 12px; }
|
|
902
|
+
.kl-jobs, .kl-info { padding: 0 18px 20px; }
|
|
903
|
+
}
|
|
904
|
+
@media (prefers-reduced-motion: reduce) {
|
|
905
|
+
.kl-app * { animation: none !important; transition: none !important; }
|
|
906
|
+
}
|
|
907
|
+
`;
|
|
908
|
+
|
|
909
|
+
// src/client.tsx
|
|
910
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
911
|
+
var inject = ["slots"];
|
|
912
|
+
function apply(ctx) {
|
|
913
|
+
ctx.effect(() => {
|
|
914
|
+
const style = document.createElement("style");
|
|
915
|
+
style.dataset.plugin = "dsh-knowledge-library";
|
|
916
|
+
style.textContent = style_default;
|
|
917
|
+
document.head.append(style);
|
|
918
|
+
return () => style.remove();
|
|
919
|
+
});
|
|
920
|
+
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: "knowledge-library" }, () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(App, {})));
|
|
921
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
922
|
+
name: "sidebar.panellist",
|
|
923
|
+
id: "knowledge-library",
|
|
924
|
+
order: 20,
|
|
925
|
+
label: "\u8D44\u6599\u5E93"
|
|
926
|
+
}, () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LibraryIcon, { size: 20 })));
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
return module.exports;}});
|