feat: 新增表格文件预览,优化知识图谱与 Agent 详情交互
- 新增 spreadsheet-preview 组件及 xlsx 解析工具,支持产物中的表格文件预览 - 优化知识图谱画布、详情面板及样式 - 调整 Agent 详情面板、聊天与消息列表交互 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5daa4b3e20
commit
7d61bc09bc
18 files changed
+1092
-208
No files matched your search
@@ -35,6 +35,42 @@ import {
|
|||||||
const MIN_ZOOM = 0.15;
|
const MIN_ZOOM = 0.15;
|
||||||
const MAX_ZOOM = 4;
|
const MAX_ZOOM = 4;
|
||||||
|
|
||||||
|
/** Canvas-drawn colors per app theme (CSS variables don't reach the 2D context). */
|
||||||
|
const CANVAS_PALETTE = {
|
||||||
|
dark: {
|
||||||
|
exportBg: "#0b1020",
|
||||||
|
labelHalo: "rgba(2, 6, 23, 0.9)",
|
||||||
|
nodeRim: "rgba(2, 6, 23, 0.55)",
|
||||||
|
rootRim: "#e0f2fe",
|
||||||
|
expandedRim: "#7dd3fc",
|
||||||
|
rootRing: "rgba(125, 211, 252, 0.9)",
|
||||||
|
expandedDot: "#7dd3fc",
|
||||||
|
expandedDotRim: "rgba(2, 6, 23, 0.8)",
|
||||||
|
selectionRing: "#ffffff",
|
||||||
|
hoverRing: "rgba(255, 255, 255, 0.85)",
|
||||||
|
pin: "rgba(255, 255, 255, 0.8)",
|
||||||
|
labelActive: "#ffffff",
|
||||||
|
label: "#e2e8f0",
|
||||||
|
minimapViewport: "rgba(56, 189, 248, 0.8)",
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
exportBg: "#f8fafc",
|
||||||
|
labelHalo: "rgba(255, 255, 255, 0.92)",
|
||||||
|
nodeRim: "rgba(255, 255, 255, 0.9)",
|
||||||
|
rootRim: "#075985",
|
||||||
|
expandedRim: "#0284c7",
|
||||||
|
rootRing: "rgba(2, 132, 199, 0.85)",
|
||||||
|
expandedDot: "#0284c7",
|
||||||
|
expandedDotRim: "rgba(255, 255, 255, 0.9)",
|
||||||
|
selectionRing: "#0f172a",
|
||||||
|
hoverRing: "rgba(15, 23, 42, 0.7)",
|
||||||
|
pin: "rgba(15, 23, 42, 0.6)",
|
||||||
|
labelActive: "#0f172a",
|
||||||
|
label: "#334155",
|
||||||
|
minimapViewport: "rgba(2, 132, 199, 0.8)",
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
export interface GraphCanvasHandle {
|
export interface GraphCanvasHandle {
|
||||||
zoomIn: () => void;
|
zoomIn: () => void;
|
||||||
zoomOut: () => void;
|
zoomOut: () => void;
|
||||||
@@ -54,6 +90,8 @@ interface GraphCanvasProps {
|
|||||||
searchMatchIds: Set<string> | null;
|
searchMatchIds: Set<string> | null;
|
||||||
layoutType: LayoutType;
|
layoutType: LayoutType;
|
||||||
showLabels: boolean;
|
showLabels: boolean;
|
||||||
|
/** App theme; drives the canvas-drawn colors (labels, rims, rings). */
|
||||||
|
theme: "light" | "dark";
|
||||||
onSelectNode: (id: string | null) => void;
|
onSelectNode: (id: string | null) => void;
|
||||||
onTooltip: (tooltip: TooltipState | null) => void;
|
onTooltip: (tooltip: TooltipState | null) => void;
|
||||||
onZoomChange: (k: number) => void;
|
onZoomChange: (k: number) => void;
|
||||||
@@ -231,6 +269,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
props.searchMatchIds,
|
props.searchMatchIds,
|
||||||
props.showLabels,
|
props.showLabels,
|
||||||
props.explore,
|
props.explore,
|
||||||
|
props.theme,
|
||||||
requestDraw,
|
requestDraw,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -330,7 +369,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
out.height = main.height;
|
out.height = main.height;
|
||||||
const ctx = out.getContext("2d");
|
const ctx = out.getContext("2d");
|
||||||
if (!ctx) return;
|
if (!ctx) return;
|
||||||
ctx.fillStyle = "#0b1020";
|
ctx.fillStyle = CANVAS_PALETTE[propsRef.current.theme].exportBg;
|
||||||
ctx.fillRect(0, 0, out.width, out.height);
|
ctx.fillRect(0, 0, out.width, out.height);
|
||||||
ctx.drawImage(main, 0, 0);
|
ctx.drawImage(main, 0, 0);
|
||||||
out.toBlob((blob) => {
|
out.toBlob((blob) => {
|
||||||
@@ -381,6 +420,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
const search = p.searchMatchIds;
|
const search = p.searchMatchIds;
|
||||||
const k = t.k || 1;
|
const k = t.k || 1;
|
||||||
const explore = p.explore;
|
const explore = p.explore;
|
||||||
|
const palette = CANVAS_PALETTE[p.theme];
|
||||||
|
|
||||||
// ---- edges
|
// ---- edges
|
||||||
for (const e of sim.edges) {
|
for (const e of sim.edges) {
|
||||||
@@ -418,7 +458,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
ctx.textAlign = "center";
|
ctx.textAlign = "center";
|
||||||
ctx.textBaseline = "middle";
|
ctx.textBaseline = "middle";
|
||||||
ctx.lineWidth = 3 / k;
|
ctx.lineWidth = 3 / k;
|
||||||
ctx.strokeStyle = "rgba(2, 6, 23, 0.9)";
|
ctx.strokeStyle = palette.labelHalo;
|
||||||
ctx.strokeText(e.info.zh, mx, my);
|
ctx.strokeText(e.info.zh, mx, my);
|
||||||
ctx.fillStyle = e.info.color;
|
ctx.fillStyle = e.info.color;
|
||||||
ctx.fillText(e.info.zh, mx, my);
|
ctx.fillText(e.info.zh, mx, my);
|
||||||
@@ -443,7 +483,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
let baseRadius = n.radius;
|
let baseRadius = n.radius;
|
||||||
let labelByExplore = false;
|
let labelByExplore = false;
|
||||||
let strokeWidth = 1.4 / k;
|
let strokeWidth = 1.4 / k;
|
||||||
let strokeColor = "rgba(2, 6, 23, 0.55)";
|
let strokeColor: string = palette.nodeRim;
|
||||||
let fillColor = n.color;
|
let fillColor = n.color;
|
||||||
if (explore?.preview) {
|
if (explore?.preview) {
|
||||||
alpha *= 0.42;
|
alpha *= 0.42;
|
||||||
@@ -454,7 +494,12 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
alpha *= Math.max(0.45, 1 - depth * 0.12);
|
alpha *= Math.max(0.45, 1 - depth * 0.12);
|
||||||
labelByExplore = depth <= 2 || isActive || isSelected;
|
labelByExplore = depth <= 2 || isActive || isSelected;
|
||||||
strokeWidth = (depth === 0 ? 4 : isExpanded ? 3 : 1.5) / k;
|
strokeWidth = (depth === 0 ? 4 : isExpanded ? 3 : 1.5) / k;
|
||||||
strokeColor = depth === 0 ? "#e0f2fe" : isExpanded ? "#7dd3fc" : "rgba(2, 6, 23, 0.55)";
|
strokeColor =
|
||||||
|
depth === 0
|
||||||
|
? palette.rootRim
|
||||||
|
: isExpanded
|
||||||
|
? palette.expandedRim
|
||||||
|
: palette.nodeRim;
|
||||||
if (isExploreRoot) fillColor = "#38bdf8";
|
if (isExploreRoot) fillColor = "#38bdf8";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,15 +532,15 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x, n.y, r + 8 / k, 0, Math.PI * 2);
|
ctx.arc(n.x, n.y, r + 8 / k, 0, Math.PI * 2);
|
||||||
ctx.lineWidth = 1.4 / k;
|
ctx.lineWidth = 1.4 / k;
|
||||||
ctx.strokeStyle = "rgba(125, 211, 252, 0.9)";
|
ctx.strokeStyle = palette.rootRing;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
} else if (isExpanded) {
|
} else if (isExpanded) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x + r * 0.58, n.y - r * 0.58, Math.max(4 / k, 3), 0, Math.PI * 2);
|
ctx.arc(n.x + r * 0.58, n.y - r * 0.58, Math.max(4 / k, 3), 0, Math.PI * 2);
|
||||||
ctx.fillStyle = "#7dd3fc";
|
ctx.fillStyle = palette.expandedDot;
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
ctx.lineWidth = 1 / k;
|
ctx.lineWidth = 1 / k;
|
||||||
ctx.strokeStyle = "rgba(2, 6, 23, 0.8)";
|
ctx.strokeStyle = palette.expandedDotRim;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +549,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x, n.y, r + 4 / k, 0, Math.PI * 2);
|
ctx.arc(n.x, n.y, r + 4 / k, 0, Math.PI * 2);
|
||||||
ctx.lineWidth = 2 / k;
|
ctx.lineWidth = 2 / k;
|
||||||
ctx.strokeStyle = "#ffffff";
|
ctx.strokeStyle = palette.selectionRing;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x, n.y, r + 8 / k, 0, Math.PI * 2);
|
ctx.arc(n.x, n.y, r + 8 / k, 0, Math.PI * 2);
|
||||||
@@ -515,7 +560,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x, n.y, r + 3.5 / k, 0, Math.PI * 2);
|
ctx.arc(n.x, n.y, r + 3.5 / k, 0, Math.PI * 2);
|
||||||
ctx.lineWidth = 1.6 / k;
|
ctx.lineWidth = 1.6 / k;
|
||||||
ctx.strokeStyle = "rgba(255, 255, 255, 0.85)";
|
ctx.strokeStyle = palette.hoverRing;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +568,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
if (n.fx != null && !isSelected) {
|
if (n.fx != null && !isSelected) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(n.x, n.y, Math.max(r * 0.28, 2 / k), 0, Math.PI * 2);
|
ctx.arc(n.x, n.y, Math.max(r * 0.28, 2 / k), 0, Math.PI * 2);
|
||||||
ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
|
ctx.fillStyle = palette.pin;
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,9 +587,9 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
ctx.textAlign = "center";
|
ctx.textAlign = "center";
|
||||||
ctx.textBaseline = "top";
|
ctx.textBaseline = "top";
|
||||||
ctx.lineWidth = 3.5 / k;
|
ctx.lineWidth = 3.5 / k;
|
||||||
ctx.strokeStyle = "rgba(2, 6, 23, 0.9)";
|
ctx.strokeStyle = palette.labelHalo;
|
||||||
ctx.strokeText(text, n.x, n.y + r + 5 / k);
|
ctx.strokeText(text, n.x, n.y + r + 5 / k);
|
||||||
ctx.fillStyle = isActive || isSelected ? "#ffffff" : "#e2e8f0";
|
ctx.fillStyle = isActive || isSelected ? palette.labelActive : palette.label;
|
||||||
ctx.fillText(text, n.x, n.y + r + 5 / k);
|
ctx.fillText(text, n.x, n.y + r + 5 / k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,7 +644,7 @@ export const GraphCanvas = forwardRef<GraphCanvasHandle, GraphCanvasProps>(
|
|||||||
const y0 = ((0 - t.y) / t.k) * scale + oy;
|
const y0 = ((0 - t.y) / t.k) * scale + oy;
|
||||||
const x1 = ((w - t.x) / t.k) * scale + ox;
|
const x1 = ((w - t.x) / t.k) * scale + ox;
|
||||||
const y1 = ((h - t.y) / t.k) * scale + oy;
|
const y1 = ((h - t.y) / t.k) * scale + oy;
|
||||||
ctx.strokeStyle = "rgba(56, 189, 248, 0.8)";
|
ctx.strokeStyle = CANVAS_PALETTE[propsRef.current.theme].minimapViewport;
|
||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 1;
|
||||||
ctx.strokeRect(x0, y0, x1 - x0, y1 - y0);
|
ctx.strokeRect(x0, y0, x1 - x0, y1 - y0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,29 +125,22 @@ function DetailBody(props: GraphDetailPanelProps & { node: GraphNode }) {
|
|||||||
? ` · ${node.category}`
|
? ` · ${node.category}`
|
||||||
: ""}
|
: ""}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span className="kg-detail-type kg-detail-type-neutral">
|
||||||
className="kg-detail-type"
|
|
||||||
style={{ background: "rgba(148, 163, 184, 0.12)", color: "#cbd5e1" }}
|
|
||||||
>
|
|
||||||
度数 {props.degree}
|
度数 {props.degree}
|
||||||
</span>
|
</span>
|
||||||
{props.explore && props.explore.depth !== null ? (
|
{props.explore && props.explore.depth !== null ? (
|
||||||
<>
|
<>
|
||||||
<span
|
<span className="kg-detail-type kg-detail-type-primary">
|
||||||
className="kg-detail-type"
|
|
||||||
style={{ background: "rgba(56, 189, 248, 0.14)", color: "#7dd3fc" }}
|
|
||||||
>
|
|
||||||
{props.explore.isRoot
|
{props.explore.isRoot
|
||||||
? "探索起点"
|
? "探索起点"
|
||||||
: `第 ${props.explore.depth} 层`}
|
: `第 ${props.explore.depth} 层`}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
className="kg-detail-type"
|
className={`kg-detail-type ${
|
||||||
style={
|
|
||||||
props.explore.expanded
|
props.explore.expanded
|
||||||
? { background: "rgba(52, 211, 153, 0.14)", color: "#6ee7b7" }
|
? "kg-detail-type-success"
|
||||||
: { background: "rgba(251, 191, 36, 0.14)", color: "#fcd34d" }
|
: "kg-detail-type-warn"
|
||||||
}
|
}`}
|
||||||
>
|
>
|
||||||
{props.explore.expanded ? "已展开" : "可展开"}
|
{props.explore.expanded ? "已展开" : "可展开"}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,34 +1,134 @@
|
|||||||
/* Knowledge-graph workbench — dark, professional analysis-tool styling. */
|
/* Knowledge-graph workbench — professional analysis-tool styling.
|
||||||
|
Light theme is the default; dark values are applied under `.dark`
|
||||||
|
(the app toggles the `dark` class on <html>). */
|
||||||
|
|
||||||
.kg-page {
|
.kg-page {
|
||||||
--kg-bg: #0b1020;
|
--kg-bg: #f4f6fb;
|
||||||
--kg-panel: rgba(15, 23, 42, 0.78);
|
--kg-bg-image:
|
||||||
--kg-panel-solid: #0f172a;
|
radial-gradient(circle at 20% 10%, rgba(2, 132, 199, 0.07), transparent 32%),
|
||||||
--kg-border: rgba(148, 163, 184, 0.18);
|
radial-gradient(circle at 80% 20%, rgba(124, 58, 237, 0.06), transparent 28%);
|
||||||
--kg-text-main: #e5e7eb;
|
--kg-panel: rgba(255, 255, 255, 0.82);
|
||||||
--kg-text-secondary: #94a3b8;
|
--kg-panel-solid: #ffffff;
|
||||||
--kg-text-muted: #64748b;
|
--kg-header-bg: rgba(255, 255, 255, 0.88);
|
||||||
--kg-primary: #38bdf8;
|
--kg-float-bg: rgba(255, 255, 255, 0.88);
|
||||||
--kg-primary-soft: rgba(56, 189, 248, 0.16);
|
--kg-tooltip-bg: rgba(255, 255, 255, 0.97);
|
||||||
|
--kg-tooltip-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
|
||||||
|
--kg-button-bg: rgba(255, 255, 255, 0.75);
|
||||||
|
--kg-input-bg: rgba(255, 255, 255, 0.9);
|
||||||
|
--kg-card-bg: rgba(248, 250, 252, 0.9);
|
||||||
|
--kg-canvas-bg: rgba(255, 255, 255, 0.55);
|
||||||
|
--kg-canvas-glow: rgba(2, 132, 199, 0.06);
|
||||||
|
--kg-grid-line: rgba(15, 23, 42, 0.05);
|
||||||
|
|
||||||
|
--kg-border: rgba(15, 23, 42, 0.12);
|
||||||
|
--kg-border-soft: rgba(15, 23, 42, 0.09);
|
||||||
|
--kg-border-faint: rgba(15, 23, 42, 0.07);
|
||||||
|
--kg-divider: rgba(15, 23, 42, 0.06);
|
||||||
|
--kg-input-border: rgba(15, 23, 42, 0.16);
|
||||||
|
|
||||||
|
--kg-text-strong: #0f172a;
|
||||||
|
--kg-text-main: #1e293b;
|
||||||
|
--kg-text-soft: #334155;
|
||||||
|
--kg-text-secondary: #64748b;
|
||||||
|
--kg-text-muted: #94a3b8;
|
||||||
|
|
||||||
|
--kg-primary: #0284c7;
|
||||||
|
--kg-primary-text: #0369a1;
|
||||||
|
--kg-primary-accent: #0369a1;
|
||||||
|
--kg-primary-soft: rgba(2, 132, 199, 0.1);
|
||||||
|
--kg-primary-soft-strong: rgba(2, 132, 199, 0.16);
|
||||||
|
--kg-primary-soft-faint: rgba(2, 132, 199, 0.07);
|
||||||
|
--kg-primary-border: rgba(2, 132, 199, 0.3);
|
||||||
|
--kg-primary-border-strong: rgba(2, 132, 199, 0.45);
|
||||||
|
--kg-focus-border: rgba(2, 132, 199, 0.55);
|
||||||
|
--kg-focus-ring: rgba(2, 132, 199, 0.12);
|
||||||
|
|
||||||
|
--kg-pill-bg: rgba(2, 132, 199, 0.08);
|
||||||
|
--kg-pill-border: rgba(2, 132, 199, 0.24);
|
||||||
|
--kg-violet-bg: rgba(124, 58, 237, 0.08);
|
||||||
|
--kg-violet-border: rgba(124, 58, 237, 0.24);
|
||||||
|
--kg-violet-text: #6d28d9;
|
||||||
|
|
||||||
|
--kg-hover-bg: rgba(15, 23, 42, 0.07);
|
||||||
|
--kg-hover-bg-faint: rgba(15, 23, 42, 0.045);
|
||||||
|
--kg-warn: #b45309;
|
||||||
|
--kg-success-bg: rgba(5, 150, 105, 0.12);
|
||||||
|
--kg-success-text: #047857;
|
||||||
|
--kg-warn-bg: rgba(217, 119, 6, 0.12);
|
||||||
|
--kg-warn-text: #b45309;
|
||||||
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
background:
|
background-color: var(--kg-bg);
|
||||||
radial-gradient(circle at 20% 10%, rgba(56, 189, 248, 0.1), transparent 32%),
|
background-image: var(--kg-bg-image);
|
||||||
radial-gradient(circle at 80% 20%, rgba(167, 139, 250, 0.1), transparent 28%),
|
|
||||||
#0b1020;
|
|
||||||
color: var(--kg-text-main);
|
color: var(--kg-text-main);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark .kg-page {
|
||||||
|
--kg-bg: #0b1020;
|
||||||
|
--kg-bg-image:
|
||||||
|
radial-gradient(circle at 20% 10%, rgba(56, 189, 248, 0.1), transparent 32%),
|
||||||
|
radial-gradient(circle at 80% 20%, rgba(167, 139, 250, 0.1), transparent 28%);
|
||||||
|
--kg-panel: rgba(15, 23, 42, 0.78);
|
||||||
|
--kg-panel-solid: #0f172a;
|
||||||
|
--kg-header-bg: rgba(15, 23, 42, 0.86);
|
||||||
|
--kg-float-bg: rgba(15, 23, 42, 0.82);
|
||||||
|
--kg-tooltip-bg: rgba(15, 23, 42, 0.94);
|
||||||
|
--kg-tooltip-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
|
||||||
|
--kg-button-bg: rgba(15, 23, 42, 0.65);
|
||||||
|
--kg-input-bg: rgba(2, 6, 23, 0.45);
|
||||||
|
--kg-card-bg: rgba(2, 6, 23, 0.35);
|
||||||
|
--kg-canvas-bg: rgba(2, 6, 23, 0.5);
|
||||||
|
--kg-canvas-glow: rgba(56, 189, 248, 0.08);
|
||||||
|
--kg-grid-line: rgba(148, 163, 184, 0.04);
|
||||||
|
|
||||||
|
--kg-border: rgba(148, 163, 184, 0.18);
|
||||||
|
--kg-border-soft: rgba(148, 163, 184, 0.14);
|
||||||
|
--kg-border-faint: rgba(148, 163, 184, 0.1);
|
||||||
|
--kg-divider: rgba(148, 163, 184, 0.08);
|
||||||
|
--kg-input-border: rgba(148, 163, 184, 0.2);
|
||||||
|
|
||||||
|
--kg-text-strong: #ffffff;
|
||||||
|
--kg-text-main: #e5e7eb;
|
||||||
|
--kg-text-soft: #cbd5e1;
|
||||||
|
--kg-text-secondary: #94a3b8;
|
||||||
|
--kg-text-muted: #64748b;
|
||||||
|
|
||||||
|
--kg-primary: #38bdf8;
|
||||||
|
--kg-primary-text: #bae6fd;
|
||||||
|
--kg-primary-accent: #7dd3fc;
|
||||||
|
--kg-primary-soft: rgba(56, 189, 248, 0.14);
|
||||||
|
--kg-primary-soft-strong: rgba(56, 189, 248, 0.18);
|
||||||
|
--kg-primary-soft-faint: rgba(56, 189, 248, 0.08);
|
||||||
|
--kg-primary-border: rgba(56, 189, 248, 0.35);
|
||||||
|
--kg-primary-border-strong: rgba(56, 189, 248, 0.45);
|
||||||
|
--kg-focus-border: rgba(56, 189, 248, 0.55);
|
||||||
|
--kg-focus-ring: rgba(56, 189, 248, 0.1);
|
||||||
|
|
||||||
|
--kg-pill-bg: rgba(56, 189, 248, 0.12);
|
||||||
|
--kg-pill-border: rgba(56, 189, 248, 0.28);
|
||||||
|
--kg-violet-bg: rgba(167, 139, 250, 0.12);
|
||||||
|
--kg-violet-border: rgba(167, 139, 250, 0.28);
|
||||||
|
--kg-violet-text: #ddd6fe;
|
||||||
|
|
||||||
|
--kg-hover-bg: rgba(148, 163, 184, 0.12);
|
||||||
|
--kg-hover-bg-faint: rgba(148, 163, 184, 0.08);
|
||||||
|
--kg-warn: #fbbf24;
|
||||||
|
--kg-success-bg: rgba(52, 211, 153, 0.14);
|
||||||
|
--kg-success-text: #6ee7b7;
|
||||||
|
--kg-warn-bg: rgba(251, 191, 36, 0.14);
|
||||||
|
--kg-warn-text: #fcd34d;
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ header */
|
/* ------------------------------------------------------------------ header */
|
||||||
|
|
||||||
.kg-header {
|
.kg-header {
|
||||||
height: 56px;
|
height: 56px;
|
||||||
border-bottom: 1px solid var(--kg-border);
|
border-bottom: 1px solid var(--kg-border);
|
||||||
background: rgba(15, 23, 42, 0.86);
|
background: var(--kg-header-bg);
|
||||||
backdrop-filter: blur(14px);
|
backdrop-filter: blur(14px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -61,7 +161,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-back:hover {
|
.kg-back:hover {
|
||||||
background: rgba(148, 163, 184, 0.12);
|
background: var(--kg-hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-title-block {
|
.kg-title-block {
|
||||||
@@ -74,7 +174,7 @@
|
|||||||
.kg-title {
|
.kg-title {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,9 +194,9 @@
|
|||||||
height: 28px;
|
height: 28px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: rgba(56, 189, 248, 0.12);
|
background: var(--kg-pill-bg);
|
||||||
border: 1px solid rgba(56, 189, 248, 0.28);
|
border: 1px solid var(--kg-pill-border);
|
||||||
color: #bae6fd;
|
color: var(--kg-primary-text);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -105,9 +205,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-stat-pill.kg-stat-pill-violet {
|
.kg-stat-pill.kg-stat-pill-violet {
|
||||||
background: rgba(167, 139, 250, 0.12);
|
background: var(--kg-violet-bg);
|
||||||
border-color: rgba(167, 139, 250, 0.28);
|
border-color: var(--kg-violet-border);
|
||||||
color: #ddd6fe;
|
color: var(--kg-violet-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-header-actions {
|
.kg-header-actions {
|
||||||
@@ -123,8 +223,8 @@
|
|||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
border-radius: 9px;
|
border-radius: 9px;
|
||||||
border: 1px solid var(--kg-border);
|
border: 1px solid var(--kg-border);
|
||||||
background: rgba(15, 23, 42, 0.65);
|
background: var(--kg-button-bg);
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -138,9 +238,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-icon-button:hover {
|
.kg-icon-button:hover {
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
background: rgba(56, 189, 248, 0.14);
|
background: var(--kg-primary-soft);
|
||||||
border-color: rgba(56, 189, 248, 0.35);
|
border-color: var(--kg-primary-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-icon-button:disabled {
|
.kg-icon-button:disabled {
|
||||||
@@ -149,9 +249,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-icon-button.kg-icon-button-active {
|
.kg-icon-button.kg-icon-button-active {
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
background: rgba(56, 189, 248, 0.18);
|
background: var(--kg-primary-soft-strong);
|
||||||
border-color: rgba(56, 189, 248, 0.45);
|
border-color: var(--kg-primary-border-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-header-divider {
|
.kg-header-divider {
|
||||||
@@ -198,7 +298,7 @@
|
|||||||
.kg-panel-header {
|
.kg-panel-header {
|
||||||
height: 46px;
|
height: 46px;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
|
border-bottom: 1px solid var(--kg-border-soft);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -222,9 +322,9 @@
|
|||||||
width: 28px;
|
width: 28px;
|
||||||
height: 28px;
|
height: 28px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
border: 1px solid var(--kg-border);
|
||||||
background: rgba(15, 23, 42, 0.65);
|
background: var(--kg-button-bg);
|
||||||
color: #94a3b8;
|
color: var(--kg-text-secondary);
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -233,9 +333,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-panel-close-btn:hover {
|
.kg-panel-close-btn:hover {
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
background: rgba(56, 189, 248, 0.14);
|
background: var(--kg-primary-soft);
|
||||||
border-color: rgba(56, 189, 248, 0.35);
|
border-color: var(--kg-primary-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-panel-content {
|
.kg-panel-content {
|
||||||
@@ -266,8 +366,8 @@
|
|||||||
height: 36px;
|
height: 36px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 1px solid rgba(148, 163, 184, 0.2);
|
border: 1px solid var(--kg-input-border);
|
||||||
background: rgba(2, 6, 23, 0.45);
|
background: var(--kg-input-bg);
|
||||||
color: var(--kg-text-main);
|
color: var(--kg-text-main);
|
||||||
padding: 0 12px 0 32px;
|
padding: 0 12px 0 32px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
@@ -279,8 +379,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-search:focus {
|
.kg-search:focus {
|
||||||
border-color: rgba(56, 189, 248, 0.55);
|
border-color: var(--kg-focus-border);
|
||||||
box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
|
box-shadow: 0 0 0 3px var(--kg-focus-ring);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-search-hint {
|
.kg-search-hint {
|
||||||
@@ -290,11 +390,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-search-hint.kg-search-hint-warn {
|
.kg-search-hint.kg-search-hint-warn {
|
||||||
color: #fbbf24;
|
color: var(--kg-warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-filter-section {
|
.kg-filter-section {
|
||||||
border-top: 1px solid rgba(148, 163, 184, 0.1);
|
border-top: 1px solid var(--kg-border-faint);
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +407,7 @@
|
|||||||
height: 34px;
|
height: 34px;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -318,11 +418,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-filter-section-header:hover {
|
.kg-filter-section-header:hover {
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-filter-section-extra {
|
.kg-filter-section-extra {
|
||||||
color: #64748b;
|
color: var(--kg-text-muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -340,7 +440,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@@ -349,7 +449,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-check-row:hover {
|
.kg-check-row:hover {
|
||||||
background: rgba(148, 163, 184, 0.08);
|
background: var(--kg-hover-bg-faint);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-check-row-main {
|
.kg-check-row-main {
|
||||||
@@ -360,7 +460,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-check-row input[type="checkbox"] {
|
.kg-check-row input[type="checkbox"] {
|
||||||
accent-color: #38bdf8;
|
accent-color: var(--kg-primary);
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -390,15 +490,15 @@
|
|||||||
|
|
||||||
.kg-stat-card {
|
.kg-stat-card {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 1px solid rgba(148, 163, 184, 0.12);
|
border: 1px solid var(--kg-border-faint);
|
||||||
background: rgba(2, 6, 23, 0.35);
|
background: var(--kg-card-bg);
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-stat-card-value {
|
.kg-stat-card-value {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-stat-card-label {
|
.kg-stat-card-label {
|
||||||
@@ -411,13 +511,13 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 8px 6px;
|
padding: 8px 6px;
|
||||||
border-bottom: 1px solid rgba(148, 163, 184, 0.08);
|
border-bottom: 1px solid var(--kg-divider);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-rank-item:hover {
|
.kg-rank-item:hover {
|
||||||
background: rgba(56, 189, 248, 0.08);
|
background: var(--kg-primary-soft-faint);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-rank-index {
|
.kg-rank-index {
|
||||||
@@ -430,7 +530,7 @@
|
|||||||
|
|
||||||
.kg-rank-title {
|
.kg-rank-title {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -462,15 +562,14 @@
|
|||||||
|
|
||||||
.kg-canvas-wrap {
|
.kg-canvas-wrap {
|
||||||
position: relative;
|
position: relative;
|
||||||
background:
|
background-color: var(--kg-canvas-bg);
|
||||||
linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
|
background-image:
|
||||||
linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px),
|
linear-gradient(var(--kg-grid-line) 1px, transparent 1px),
|
||||||
radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.08), transparent 42%),
|
linear-gradient(90deg, var(--kg-grid-line) 1px, transparent 1px),
|
||||||
rgba(2, 6, 23, 0.5);
|
radial-gradient(circle at 50% 40%, var(--kg-canvas-glow), transparent 42%);
|
||||||
background-size:
|
background-size:
|
||||||
28px 28px,
|
28px 28px,
|
||||||
28px 28px,
|
28px 28px,
|
||||||
auto,
|
|
||||||
auto;
|
auto;
|
||||||
border: 1px solid var(--kg-border);
|
border: 1px solid var(--kg-border);
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
@@ -511,9 +610,9 @@
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: rgba(15, 23, 42, 0.82);
|
background: var(--kg-float-bg);
|
||||||
border: 1px solid var(--kg-border);
|
border: 1px solid var(--kg-border);
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -532,7 +631,7 @@
|
|||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -541,21 +640,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-pill-button:hover {
|
.kg-pill-button:hover {
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-pill-button.kg-pill-button-active {
|
.kg-pill-button.kg-pill-button-active {
|
||||||
background: rgba(56, 189, 248, 0.18);
|
background: var(--kg-primary-soft-strong);
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-explore-button {
|
.kg-explore-button {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
border: 1px solid rgba(148, 163, 184, 0.18);
|
border: 1px solid var(--kg-border);
|
||||||
background: rgba(15, 23, 42, 0.72);
|
background: var(--kg-float-bg);
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -565,8 +664,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-explore-button:hover {
|
.kg-explore-button:hover {
|
||||||
background: rgba(56, 189, 248, 0.14);
|
background: var(--kg-primary-soft);
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-explore-button:disabled {
|
.kg-explore-button:disabled {
|
||||||
@@ -583,9 +682,9 @@
|
|||||||
max-width: min(560px, calc(100% - 48px));
|
max-width: min(560px, calc(100% - 48px));
|
||||||
padding: 8px 14px;
|
padding: 8px 14px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
border: 1px solid rgba(56, 189, 248, 0.22);
|
border: 1px solid var(--kg-pill-border);
|
||||||
background: rgba(15, 23, 42, 0.78);
|
background: var(--kg-panel);
|
||||||
color: #bae6fd;
|
color: var(--kg-primary-text);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
backdrop-filter: blur(12px);
|
backdrop-filter: blur(12px);
|
||||||
@@ -599,9 +698,9 @@
|
|||||||
width: 32px;
|
width: 32px;
|
||||||
min-height: 88px;
|
min-height: 88px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 1px solid rgba(56, 189, 248, 0.28);
|
border: 1px solid var(--kg-pill-border);
|
||||||
background: rgba(15, 23, 42, 0.86);
|
background: var(--kg-header-bg);
|
||||||
color: #bae6fd;
|
color: var(--kg-primary-text);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -621,8 +720,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-side-rail-toggle:hover {
|
.kg-side-rail-toggle:hover {
|
||||||
background: rgba(56, 189, 248, 0.16);
|
background: var(--kg-primary-soft-strong);
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-minimap {
|
.kg-minimap {
|
||||||
@@ -632,7 +731,7 @@
|
|||||||
width: 180px;
|
width: 180px;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: rgba(15, 23, 42, 0.78);
|
background: var(--kg-panel);
|
||||||
border: 1px solid var(--kg-border);
|
border: 1px solid var(--kg-border);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
@@ -674,9 +773,9 @@
|
|||||||
max-width: 320px;
|
max-width: 320px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
background: rgba(15, 23, 42, 0.94);
|
background: var(--kg-tooltip-bg);
|
||||||
border: 1px solid rgba(56, 189, 248, 0.25);
|
border: 1px solid var(--kg-pill-border);
|
||||||
box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
|
box-shadow: var(--kg-tooltip-shadow);
|
||||||
color: var(--kg-text-main);
|
color: var(--kg-text-main);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
backdrop-filter: blur(14px);
|
backdrop-filter: blur(14px);
|
||||||
@@ -731,7 +830,7 @@
|
|||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
color: #ffffff;
|
color: var(--kg-text-strong);
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
@@ -748,8 +847,28 @@
|
|||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kg-detail-type-neutral {
|
||||||
|
background: var(--kg-hover-bg);
|
||||||
|
color: var(--kg-text-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.kg-detail-type-primary {
|
||||||
|
background: var(--kg-primary-soft);
|
||||||
|
color: var(--kg-primary-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.kg-detail-type-success {
|
||||||
|
background: var(--kg-success-bg);
|
||||||
|
color: var(--kg-success-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.kg-detail-type-warn {
|
||||||
|
background: var(--kg-warn-bg);
|
||||||
|
color: var(--kg-warn-text);
|
||||||
|
}
|
||||||
|
|
||||||
.kg-detail-summary {
|
.kg-detail-summary {
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
@@ -770,7 +889,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-detail-meta-value {
|
.kg-detail-meta-value {
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,8 +904,8 @@
|
|||||||
height: 24px;
|
height: 24px;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: rgba(148, 163, 184, 0.12);
|
background: var(--kg-hover-bg);
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -815,8 +934,8 @@
|
|||||||
.kg-neighbor-item {
|
.kg-neighbor-item {
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background: rgba(2, 6, 23, 0.35);
|
background: var(--kg-card-bg);
|
||||||
border: 1px solid rgba(148, 163, 184, 0.1);
|
border: 1px solid var(--kg-border-faint);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -824,15 +943,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kg-neighbor-item:hover {
|
.kg-neighbor-item:hover {
|
||||||
background: rgba(56, 189, 248, 0.1);
|
background: var(--kg-primary-soft-faint);
|
||||||
border-color: rgba(56, 189, 248, 0.24);
|
border-color: var(--kg-primary-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kg-neighbor-title {
|
.kg-neighbor-title {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #cbd5e1;
|
color: var(--kg-text-soft);
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -903,7 +1022,7 @@
|
|||||||
max-width: 240px;
|
max-width: 240px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
color: #bae6fd;
|
color: var(--kg-primary-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------- responsive */
|
/* -------------------------------------------------------------- responsive */
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ export function WikiHeader({
|
|||||||
</div>
|
</div>
|
||||||
<div className="leading-none">
|
<div className="leading-none">
|
||||||
<div className="text-base font-extrabold tracking-tight text-slate-900 dark:text-slate-100">
|
<div className="text-base font-extrabold tracking-tight text-slate-900 dark:text-slate-100">
|
||||||
知识库
|
问答梳理
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 text-xs text-emerald-500">LLM Wiki · 知识库中心</div>
|
<div className="mt-1 text-xs text-emerald-500">LLM Wiki · 问答梳理中心</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -123,14 +123,20 @@ export function splitRelatedSection(markdown: string): {
|
|||||||
export function noteFolderSegments(note: KnowledgeNote): string[] {
|
export function noteFolderSegments(note: KnowledgeNote): string[] {
|
||||||
const rawPath = note.vault_path?.replace(/\\/g, "/").replace(/^\/+/, "");
|
const rawPath = note.vault_path?.replace(/\\/g, "/").replace(/^\/+/, "");
|
||||||
if (rawPath && rawPath.includes("/")) {
|
if (rawPath && rawPath.includes("/")) {
|
||||||
return rawPath.split("/").slice(0, -1).filter(Boolean);
|
let segments = rawPath.split("/").slice(0, -1).filter(Boolean);
|
||||||
|
// Vault notes live under projects/<project>/<category>/ — the first two
|
||||||
|
// levels are constant scaffolding, so hide them from the directory tree.
|
||||||
|
if (segments[0] === "projects" || segments[0] === "project") {
|
||||||
|
segments = segments.slice(2);
|
||||||
|
}
|
||||||
|
if (segments.length > 0) return segments;
|
||||||
}
|
}
|
||||||
return [SOURCE_TYPE_LABELS[note.source_type] ?? FALLBACK_FOLDER];
|
return [SOURCE_TYPE_LABELS[note.source_type] ?? FALLBACK_FOLDER];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Breadcrumb segments for a note (folders only; the title is appended by the caller). */
|
/** Breadcrumb segments for a note (folders only; the title is appended by the caller). */
|
||||||
export function noteBreadcrumbSegments(note: KnowledgeNote): string[] {
|
export function noteBreadcrumbSegments(note: KnowledgeNote): string[] {
|
||||||
return ["知识库", ...noteFolderSegments(note)];
|
return ["问答梳理", ...noteFolderSegments(note)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortTree(nodes: TreeNode[]): void {
|
function sortTree(nodes: TreeNode[]): void {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BotIcon,
|
BotIcon,
|
||||||
|
CheckIcon,
|
||||||
GlobeIcon,
|
GlobeIcon,
|
||||||
InfoIcon,
|
InfoIcon,
|
||||||
Loader2Icon,
|
Loader2Icon,
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
SquarePenIcon,
|
SquarePenIcon,
|
||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
UserRoundIcon,
|
UserRoundIcon,
|
||||||
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useMemo, useState, type ReactNode } from "react";
|
import { useMemo, useState, type ReactNode } from "react";
|
||||||
@@ -156,6 +158,13 @@ export function AgentDetailPanel({
|
|||||||
const [mobileOpen, setMobileOpen] = useState(false);
|
const [mobileOpen, setMobileOpen] = useState(false);
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
const [draft, setDraft] = useState<AgentDraft | null>(null);
|
const [draft, setDraft] = useState<AgentDraft | null>(null);
|
||||||
|
const [editingQuestionIndex, setEditingQuestionIndex] = useState<
|
||||||
|
number | null
|
||||||
|
>(null);
|
||||||
|
const [questionDraft, setQuestionDraft] = useState<AgentQuestion>({
|
||||||
|
title: "",
|
||||||
|
prompt: "",
|
||||||
|
});
|
||||||
const [pickerOpen, setPickerOpen] = useState(false);
|
const [pickerOpen, setPickerOpen] = useState(false);
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
const [publishPickerOpen, setPublishPickerOpen] = useState(false);
|
const [publishPickerOpen, setPublishPickerOpen] = useState(false);
|
||||||
@@ -200,6 +209,7 @@ export function AgentDetailPanel({
|
|||||||
|
|
||||||
function beginEdit() {
|
function beginEdit() {
|
||||||
if (!agent || !canEdit) return;
|
if (!agent || !canEdit) return;
|
||||||
|
cancelQuestionEdit();
|
||||||
setDraft(draftFromAgent(agent));
|
setDraft(draftFromAgent(agent));
|
||||||
setEditing(true);
|
setEditing(true);
|
||||||
}
|
}
|
||||||
@@ -210,6 +220,42 @@ export function AgentDetailPanel({
|
|||||||
setPickerOpen(false);
|
setPickerOpen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function beginQuestionEdit(index: number, question: AgentQuestion) {
|
||||||
|
if (!canEdit) return;
|
||||||
|
setEditingQuestionIndex(index);
|
||||||
|
setQuestionDraft(question);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelQuestionEdit() {
|
||||||
|
setEditingQuestionIndex(null);
|
||||||
|
setQuestionDraft({ title: "", prompt: "" });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveQuestionEdit(index: number) {
|
||||||
|
if (!agent) return;
|
||||||
|
const nextQuestions = questions.map((question, questionIndex) =>
|
||||||
|
questionIndex === index
|
||||||
|
? {
|
||||||
|
title: questionDraft.title.trim() || questionDraft.prompt.trim(),
|
||||||
|
prompt: questionDraft.prompt.trim() || questionDraft.title.trim(),
|
||||||
|
}
|
||||||
|
: question,
|
||||||
|
);
|
||||||
|
const cleanedQuestions = nextQuestions.filter(
|
||||||
|
(question) => question.prompt.trim().length > 0,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await updateAgent.mutateAsync({
|
||||||
|
id: agent.id,
|
||||||
|
request: { common_questions: cleanedQuestions },
|
||||||
|
});
|
||||||
|
toast.success("Updated");
|
||||||
|
cancelQuestionEdit();
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(err instanceof Error ? err.message : String(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function saveEdit() {
|
async function saveEdit() {
|
||||||
if (!agent || !draft) return;
|
if (!agent || !draft) return;
|
||||||
const trimmedName = draft.name.trim();
|
const trimmedName = draft.name.trim();
|
||||||
@@ -367,7 +413,14 @@ export function AgentDetailPanel({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Button size="sm" variant="outline" onClick={beginEdit}>
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
className="hidden"
|
||||||
|
onClick={beginEdit}
|
||||||
|
aria-hidden="true"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<SquarePenIcon className="size-3.5" />
|
<SquarePenIcon className="size-3.5" />
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
@@ -544,21 +597,98 @@ export function AgentDetailPanel({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{questions.map((question, index) => (
|
{questions.map((question, index) => {
|
||||||
<button
|
const isEditingThis = editingQuestionIndex === index;
|
||||||
key={index}
|
return (
|
||||||
type="button"
|
<div
|
||||||
disabled={disabled}
|
key={index}
|
||||||
onClick={() => onAskQuestion(question.prompt)}
|
className="border-border/60 bg-background/60 rounded-xl border p-2"
|
||||||
title={desensitize(question.prompt)}
|
>
|
||||||
className={cn(
|
{isEditingThis ? (
|
||||||
"border-border/60 bg-background/60 hover:bg-accent hover:border-border w-full rounded-xl border px-3 py-2.5 text-left text-sm leading-relaxed transition-colors",
|
<div className="space-y-2">
|
||||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
<Input
|
||||||
)}
|
value={questionDraft.title}
|
||||||
>
|
disabled={isSaving}
|
||||||
{desensitize(question.title)}
|
placeholder="Title"
|
||||||
</button>
|
onChange={(e) =>
|
||||||
))}
|
setQuestionDraft({
|
||||||
|
...questionDraft,
|
||||||
|
title: e.currentTarget.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="h-8 text-sm font-medium"
|
||||||
|
/>
|
||||||
|
<Textarea
|
||||||
|
value={questionDraft.prompt}
|
||||||
|
disabled={isSaving}
|
||||||
|
placeholder="Prompt"
|
||||||
|
onChange={(e) =>
|
||||||
|
setQuestionDraft({
|
||||||
|
...questionDraft,
|
||||||
|
prompt: e.currentTarget.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="min-h-16 resize-none text-sm"
|
||||||
|
/>
|
||||||
|
<div className="flex justify-end gap-1.5">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={cancelQuestionEdit}
|
||||||
|
disabled={isSaving}
|
||||||
|
>
|
||||||
|
<XIcon className="size-3.5" />
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => void saveQuestionEdit(index)}
|
||||||
|
disabled={isSaving}
|
||||||
|
>
|
||||||
|
{isSaving ? (
|
||||||
|
<Loader2Icon className="size-3.5 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<CheckIcon className="size-3.5" />
|
||||||
|
)}
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={() => onAskQuestion(question.prompt)}
|
||||||
|
title={desensitize(question.prompt)}
|
||||||
|
className={cn(
|
||||||
|
"hover:bg-accent min-w-0 flex-1 rounded-lg px-2 py-1.5 text-left text-sm leading-relaxed transition-colors",
|
||||||
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="block truncate">
|
||||||
|
{desensitize(question.title)}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
{canEdit && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="icon-sm"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => beginQuestionEdit(index, question)}
|
||||||
|
disabled={isSaving}
|
||||||
|
aria-label="Edit question"
|
||||||
|
>
|
||||||
|
<SquarePenIcon className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import { useThread } from "../messages/context";
|
|||||||
import { Tooltip } from "../tooltip";
|
import { Tooltip } from "../tooltip";
|
||||||
|
|
||||||
import { useArtifacts } from "./context";
|
import { useArtifacts } from "./context";
|
||||||
|
import { SpreadsheetPreview } from "./spreadsheet-preview";
|
||||||
|
|
||||||
const SANDBOX_RESUME_EVENT = "workspace:sandbox-resume-autoscroll";
|
const SANDBOX_RESUME_EVENT = "workspace:sandbox-resume-autoscroll";
|
||||||
|
|
||||||
@@ -137,6 +138,11 @@ export function ArtifactFileDetail({
|
|||||||
const isSkillFile = useMemo(() => {
|
const isSkillFile = useMemo(() => {
|
||||||
return filepath.endsWith(".skill");
|
return filepath.endsWith(".skill");
|
||||||
}, [filepath]);
|
}, [filepath]);
|
||||||
|
// .xlsx is a ZIP archive — the generic binary iframe preview renders its
|
||||||
|
// raw bytes as mojibake, so it gets a dedicated table preview instead.
|
||||||
|
const isSpreadsheetFile = useMemo(() => {
|
||||||
|
return /\.xlsx$/i.test(filepath);
|
||||||
|
}, [filepath]);
|
||||||
const { isCodeFile, language } = useMemo(() => {
|
const { isCodeFile, language } = useMemo(() => {
|
||||||
if (useWriteFileStreaming) {
|
if (useWriteFileStreaming) {
|
||||||
let nextLanguage = checkCodeFile(filepath).language;
|
let nextLanguage = checkCodeFile(filepath).language;
|
||||||
@@ -174,13 +180,14 @@ export function ArtifactFileDetail({
|
|||||||
const hasMultipleArtifacts = (artifacts?.length ?? 0) > 1;
|
const hasMultipleArtifacts = (artifacts?.length ?? 0) > 1;
|
||||||
const fileTypeLabel = useMemo(() => {
|
const fileTypeLabel = useMemo(() => {
|
||||||
if (isImageFile(filepath)) return "IMG";
|
if (isImageFile(filepath)) return "IMG";
|
||||||
|
if (isSpreadsheetFile) return "XLSX";
|
||||||
if (isMermaidFile(filepath) || language === "mermaid") return "MMD";
|
if (isMermaidFile(filepath) || language === "mermaid") return "MMD";
|
||||||
if (language === "html") return "HTML";
|
if (language === "html") return "HTML";
|
||||||
if (language === "markdown") return "MD";
|
if (language === "markdown") return "MD";
|
||||||
if (isSkillFile) return "SKILL";
|
if (isSkillFile) return "SKILL";
|
||||||
if (language) return language.toUpperCase();
|
if (language) return language.toUpperCase();
|
||||||
return "FILE";
|
return "FILE";
|
||||||
}, [filepath, isSkillFile, language]);
|
}, [filepath, isSkillFile, isSpreadsheetFile, language]);
|
||||||
|
|
||||||
const [viewMode, setViewMode] = useState<"code" | "preview">("code");
|
const [viewMode, setViewMode] = useState<"code" | "preview">("code");
|
||||||
const [allowAutoViewSwitch, setAllowAutoViewSwitch] = useState(true);
|
const [allowAutoViewSwitch, setAllowAutoViewSwitch] = useState(true);
|
||||||
@@ -191,6 +198,9 @@ export function ArtifactFileDetail({
|
|||||||
const [binaryPreviewUrl, setBinaryPreviewUrl] = useState<string | null>(
|
const [binaryPreviewUrl, setBinaryPreviewUrl] = useState<string | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
const [spreadsheetData, setSpreadsheetData] = useState<ArrayBuffer | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
const artifactContentRef = useRef<HTMLDivElement | null>(null);
|
const artifactContentRef = useRef<HTMLDivElement | null>(null);
|
||||||
const resumeButtonTimeoutRef = useRef<number | null>(null);
|
const resumeButtonTimeoutRef = useRef<number | null>(null);
|
||||||
|
|
||||||
@@ -310,6 +320,7 @@ export function ArtifactFileDetail({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isCodeFile) {
|
if (isCodeFile) {
|
||||||
|
setSpreadsheetData(null);
|
||||||
setBinaryPreviewUrl((prev) => {
|
setBinaryPreviewUrl((prev) => {
|
||||||
if (prev) URL.revokeObjectURL(prev);
|
if (prev) URL.revokeObjectURL(prev);
|
||||||
return null;
|
return null;
|
||||||
@@ -325,6 +336,13 @@ export function ArtifactFileDetail({
|
|||||||
urlOfArtifact({ filepath, threadId, isMock, publicShareCode }),
|
urlOfArtifact({ filepath, threadId, isMock, publicShareCode }),
|
||||||
);
|
);
|
||||||
if (cancelled || !res.ok) return;
|
if (cancelled || !res.ok) return;
|
||||||
|
if (isSpreadsheetFile) {
|
||||||
|
const buffer = await res.arrayBuffer();
|
||||||
|
if (!cancelled) {
|
||||||
|
setSpreadsheetData(buffer);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
const blob = await res.blob();
|
const blob = await res.blob();
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
const u = URL.createObjectURL(blob);
|
const u = URL.createObjectURL(blob);
|
||||||
@@ -342,12 +360,13 @@ export function ArtifactFileDetail({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
setSpreadsheetData(null);
|
||||||
setBinaryPreviewUrl((prev) => {
|
setBinaryPreviewUrl((prev) => {
|
||||||
if (prev) URL.revokeObjectURL(prev);
|
if (prev) URL.revokeObjectURL(prev);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}, [filepath, threadId, isMock, isCodeFile, publicShareCode]);
|
}, [filepath, threadId, isMock, isCodeFile, isSpreadsheetFile, publicShareCode]);
|
||||||
|
|
||||||
const handlePauseAutoScroll = useCallback(() => {
|
const handlePauseAutoScroll = useCallback(() => {
|
||||||
if (!thread.isLoading || !autoScrollEnabled) {
|
if (!thread.isLoading || !autoScrollEnabled) {
|
||||||
@@ -766,7 +785,18 @@ export function ArtifactFileDetail({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{!isCodeFile && isSpreadsheetFile && (
|
||||||
|
spreadsheetData ? (
|
||||||
|
<SpreadsheetPreview data={spreadsheetData} />
|
||||||
|
) : (
|
||||||
|
<div className="text-muted-foreground flex size-full items-center justify-center gap-2 text-sm">
|
||||||
|
<LoaderIcon className="size-5 animate-spin" />
|
||||||
|
{t.common.loading}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
{!isCodeFile &&
|
{!isCodeFile &&
|
||||||
|
!isSpreadsheetFile &&
|
||||||
(binaryPreviewUrl ? (
|
(binaryPreviewUrl ? (
|
||||||
<iframe className="size-full bg-white" src={binaryPreviewUrl} />
|
<iframe className="size-full bg-white" src={binaryPreviewUrl} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { LoaderIcon, TriangleAlertIcon } from "lucide-react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { parseXlsx, type ParsedWorksheet } from "@/core/utils/xlsx";
|
||||||
|
import { desensitize } from "@/lib/desensitize";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders an .xlsx ArrayBuffer as sheet tabs + an HTML table, replacing the
|
||||||
|
* old binary-blob iframe preview that showed the raw ZIP bytes as mojibake.
|
||||||
|
*/
|
||||||
|
export function SpreadsheetPreview({
|
||||||
|
data,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
data: ArrayBuffer;
|
||||||
|
className?: string;
|
||||||
|
}) {
|
||||||
|
const [sheets, setSheets] = useState<ParsedWorksheet[] | null>(null);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [activeSheetIndex, setActiveSheetIndex] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setSheets(null);
|
||||||
|
setError(null);
|
||||||
|
setActiveSheetIndex(0);
|
||||||
|
parseXlsx(data)
|
||||||
|
.then((parsed) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
setSheets(parsed);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("xlsx preview parse failed:", err);
|
||||||
|
if (!cancelled) {
|
||||||
|
setError(err instanceof Error ? err.message : "解析失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"text-muted-foreground flex size-full flex-col items-center justify-center gap-2 p-6 text-sm",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<TriangleAlertIcon className="size-5" />
|
||||||
|
<div>无法预览此表格文件:{error}</div>
|
||||||
|
<div className="text-xs">可点击右上角下载后用本地软件打开。</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sheets) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"text-muted-foreground flex size-full items-center justify-center gap-2 text-sm",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<LoaderIcon className="size-5 animate-spin" />
|
||||||
|
正在解析表格…
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeSheet = sheets[activeSheetIndex] ?? sheets[0]!;
|
||||||
|
const [headerRow, ...bodyRows] = activeSheet.rows;
|
||||||
|
const columnCount = Math.max(
|
||||||
|
headerRow?.length ?? 0,
|
||||||
|
...activeSheet.rows.map((row) => row.length),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-artifact-preview-scroll
|
||||||
|
className={cn("flex size-full flex-col overflow-hidden", className)}
|
||||||
|
>
|
||||||
|
{sheets.length > 1 && (
|
||||||
|
<div className="border-border/70 flex shrink-0 items-center gap-1 overflow-x-auto border-b px-3 py-2">
|
||||||
|
{sheets.map((sheet, index) => (
|
||||||
|
<button
|
||||||
|
key={`${sheet.name}-${index}`}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setActiveSheetIndex(index)}
|
||||||
|
className={cn(
|
||||||
|
"shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",
|
||||||
|
index === activeSheetIndex
|
||||||
|
? "bg-primary/10 text-primary font-medium"
|
||||||
|
: "text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{desensitize(sheet.name)}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="min-h-0 flex-1 overflow-auto p-3">
|
||||||
|
{activeSheet.rows.length === 0 ? (
|
||||||
|
<div className="text-muted-foreground flex h-full items-center justify-center text-sm">
|
||||||
|
(空工作表)
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<table className="border-border w-max min-w-full border-collapse text-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{Array.from({ length: columnCount }, (_, columnIndex) => (
|
||||||
|
<th
|
||||||
|
key={columnIndex}
|
||||||
|
className="border-border bg-muted/60 text-foreground sticky top-0 border px-3 py-1.5 text-left font-medium whitespace-pre-wrap"
|
||||||
|
>
|
||||||
|
{desensitize(headerRow?.[columnIndex] ?? "")}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{bodyRows.map((row, rowIndex) => (
|
||||||
|
<tr key={rowIndex} className="even:bg-muted/30">
|
||||||
|
{Array.from({ length: columnCount }, (_, columnIndex) => (
|
||||||
|
<td
|
||||||
|
key={columnIndex}
|
||||||
|
className="border-border border px-3 py-1.5 align-top whitespace-pre-wrap"
|
||||||
|
>
|
||||||
|
{desensitize(row[columnIndex] ?? "")}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
{activeSheet.truncated && (
|
||||||
|
<div className="text-muted-foreground py-2 text-center text-xs">
|
||||||
|
表格过大,仅预览部分内容;完整数据请下载文件查看。
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ import {
|
|||||||
ArtifactFileList,
|
ArtifactFileList,
|
||||||
useArtifacts,
|
useArtifacts,
|
||||||
} from "../artifacts";
|
} from "../artifacts";
|
||||||
import { useThread } from "../messages/context";
|
import { ReferenceBatchesContext, useThread } from "../messages/context";
|
||||||
import { SkillDisplaySources } from "../skill-display-sources";
|
import { SkillDisplaySources } from "../skill-display-sources";
|
||||||
|
|
||||||
const CLOSE_MODE = { chat: 100, artifacts: 0 };
|
const CLOSE_MODE = { chat: 100, artifacts: 0 };
|
||||||
@@ -362,10 +362,15 @@ const ChatBox: React.FC<{
|
|||||||
}, [sidePanelOpen]);
|
}, [sidePanelOpen]);
|
||||||
|
|
||||||
if (disableArtifacts) {
|
if (disableArtifacts) {
|
||||||
return <>{children}</>;
|
return (
|
||||||
|
<ReferenceBatchesContext.Provider value={referenceBatches}>
|
||||||
|
{children}
|
||||||
|
</ReferenceBatchesContext.Provider>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<ReferenceBatchesContext.Provider value={referenceBatches}>
|
||||||
<ResizablePanelGroup
|
<ResizablePanelGroup
|
||||||
id={`${resizableIdBase}-panels`}
|
id={`${resizableIdBase}-panels`}
|
||||||
orientation="horizontal"
|
orientation="horizontal"
|
||||||
@@ -490,6 +495,7 @@ const ChatBox: React.FC<{
|
|||||||
</div>
|
</div>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
</ResizablePanelGroup>
|
</ResizablePanelGroup>
|
||||||
|
</ReferenceBatchesContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { BaseStream } from "@langchain/langgraph-sdk/react";
|
import type { BaseStream } from "@langchain/langgraph-sdk/react";
|
||||||
import { createContext, useContext } from "react";
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
|
import type { RuntimeDisplaySource } from "@/core/skill-display/runtime";
|
||||||
import type { AgentThreadState } from "@/core/threads";
|
import type { AgentThreadState } from "@/core/threads";
|
||||||
|
|
||||||
export interface ThreadContextType {
|
export interface ThreadContextType {
|
||||||
@@ -26,3 +27,18 @@ export function useThread() {
|
|||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One turn's reference sources, keyed to the assistant message that answered
|
||||||
|
* the turn. Provided by ChatBox so inline citation rendering and the
|
||||||
|
* right-side reference panel always resolve `[n]` against the SAME sources
|
||||||
|
* (the panel prefers backend reference batches, which the per-message
|
||||||
|
* frontend collection in MessageList knows nothing about).
|
||||||
|
*/
|
||||||
|
export interface ReferenceBatch {
|
||||||
|
id: string;
|
||||||
|
assistant_message_id?: string;
|
||||||
|
sources: RuntimeDisplaySource[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ReferenceBatchesContext = createContext<ReferenceBatch[]>([]);
|
||||||
@@ -37,7 +37,7 @@ import { resolveAllowMultiple } from "@/roundtable-planning/lib/clarification";
|
|||||||
import { ArtifactFileList } from "../artifacts/artifact-file-list";
|
import { ArtifactFileList } from "../artifacts/artifact-file-list";
|
||||||
import { StreamingIndicator } from "../streaming-indicator";
|
import { StreamingIndicator } from "../streaming-indicator";
|
||||||
|
|
||||||
import { ThreadContext } from "./context";
|
import { ReferenceBatchesContext, ThreadContext } from "./context";
|
||||||
import { MarkdownContent } from "./markdown-content";
|
import { MarkdownContent } from "./markdown-content";
|
||||||
import { MessageGroup } from "./message-group";
|
import { MessageGroup } from "./message-group";
|
||||||
import { MessageListItem } from "./message-list-item";
|
import { MessageListItem } from "./message-list-item";
|
||||||
@@ -146,6 +146,11 @@ export function MessageList({
|
|||||||
() => (ragModeEnabled ? buildSkillDisplayMap(skills) : new Map()),
|
() => (ragModeEnabled ? buildSkillDisplayMap(skills) : new Map()),
|
||||||
[ragModeEnabled, skills],
|
[ragModeEnabled, skills],
|
||||||
);
|
);
|
||||||
|
// Same per-turn reference batches the right-side panel renders (backend
|
||||||
|
// batches preferred). Inline [n] tokens must resolve against these so badge
|
||||||
|
// numbering matches the panel, and so citations still render when the
|
||||||
|
// frontend tool-message scan below comes up empty (e.g. after a reload).
|
||||||
|
const referenceBatches = useContext(ReferenceBatchesContext);
|
||||||
|
|
||||||
// Track which clarification messages are still awaiting an answer.
|
// Track which clarification messages are still awaiting an answer.
|
||||||
// Pending = clarification tool messages that appear after the last human message
|
// Pending = clarification tool messages that appear after the last human message
|
||||||
@@ -270,16 +275,24 @@ export function MessageList({
|
|||||||
{groupMessages(messages, (group) => {
|
{groupMessages(messages, (group) => {
|
||||||
if (group.type === "human" || group.type === "assistant") {
|
if (group.type === "human" || group.type === "assistant") {
|
||||||
return group.messages.map((msg) => {
|
return group.messages.map((msg) => {
|
||||||
const displaySources =
|
const isAssistantMessage =
|
||||||
ragModeEnabled &&
|
ragModeEnabled &&
|
||||||
group.type === "assistant" &&
|
group.type === "assistant" &&
|
||||||
msg.type === "ai"
|
msg.type === "ai";
|
||||||
? collectRuntimeDisplaySources(messages, skillDisplayMap, {
|
const batchSources = isAssistantMessage
|
||||||
|
? referenceBatches.find(
|
||||||
|
(batch) => batch.assistant_message_id === msg.id,
|
||||||
|
)?.sources ?? []
|
||||||
|
: [];
|
||||||
|
const displaySources = isAssistantMessage
|
||||||
|
? batchSources.length > 0
|
||||||
|
? batchSources
|
||||||
|
: collectRuntimeDisplaySources(messages, skillDisplayMap, {
|
||||||
afterMessageId: findPreviousHumanMessageId(messages, msg.id),
|
afterMessageId: findPreviousHumanMessageId(messages, msg.id),
|
||||||
beforeMessageId: msg.id,
|
beforeMessageId: msg.id,
|
||||||
includeBeforeMessage: true,
|
includeBeforeMessage: true,
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
return (
|
return (
|
||||||
<MessageListItem
|
<MessageListItem
|
||||||
key={`${group.id}/${msg.id}`}
|
key={`${group.id}/${msg.id}`}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ export function WorkspaceNavChatList({
|
|||||||
>
|
>
|
||||||
<Link href="/page/workspace/knowledge">
|
<Link href="/page/workspace/knowledge">
|
||||||
<BookOpen />
|
<BookOpen />
|
||||||
<span>知识库</span>
|
<span>问答梳理</span>
|
||||||
</Link>
|
</Link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ export const sidebarMenuItems: MenuItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "resource-knowledge-native",
|
id: "resource-knowledge-native",
|
||||||
label: "知识库",
|
label: "问答梳理",
|
||||||
icon: BookOpen,
|
icon: BookOpen,
|
||||||
path: "/page/workspace/knowledge",
|
path: "/page/workspace/knowledge",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -623,7 +623,46 @@ function normalizeLooseCitationTokens(
|
|||||||
return indexes.map((index) => `[${index}]`).join("");
|
return indexes.map((index) => `[${index}]`).join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
let next = content.replace(
|
// 全角括号写法:【1】→ [1]
|
||||||
|
let next = content.replace(/【\s*(\d{1,3})\s*】/g, (match, rawIndex: string) =>
|
||||||
|
isValidIndex(Number(rawIndex)) ? `[${rawIndex}]` : match,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 合并写法:[1,2,3] / [1,2] / [1、2] → [1][2][3]
|
||||||
|
next = next.replace(
|
||||||
|
/\\?\[(\d{1,3}(?:\s*[,,、]\s*\d{1,3})+)\\?\](?!\()/g,
|
||||||
|
(match, rawList: string) => {
|
||||||
|
const indexes = rawList.split(/[,,、]/).map((part) => Number(part.trim()));
|
||||||
|
if (indexes.some((index) => !isValidIndex(index))) {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
return indexes.map((index) => `[${index}]`).join("");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// 区间写法:[1-3] / [2~5] → [1][2][3]
|
||||||
|
next = next.replace(
|
||||||
|
/\\?\[(\d{1,3})\s*[-–~~]\s*(\d{1,3})\\?\](?!\()/g,
|
||||||
|
(match, rawStart: string, rawEnd: string) => {
|
||||||
|
const start = Number(rawStart);
|
||||||
|
const end = Number(rawEnd);
|
||||||
|
if (
|
||||||
|
end <= start ||
|
||||||
|
end - start > 20 ||
|
||||||
|
!isValidIndex(start) ||
|
||||||
|
!isValidIndex(end)
|
||||||
|
) {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
const tokens: string[] = [];
|
||||||
|
for (let index = start; index <= end; index++) {
|
||||||
|
tokens.push(`[${index}]`);
|
||||||
|
}
|
||||||
|
return tokens.join("");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
next = next.replace(
|
||||||
/(^|[^\d\[\]\\])((?:\d{1,3}|\\?\[\d{1,3}\\?\])(?:\\?\[\d{1,3}\\?\]|\d{1,3})+)/g,
|
/(^|[^\d\[\]\\])((?:\d{1,3}|\\?\[\d{1,3}\\?\])(?:\\?\[\d{1,3}\\?\]|\d{1,3})+)/g,
|
||||||
(match, prefix: string, rawRun: string) => {
|
(match, prefix: string, rawRun: string) => {
|
||||||
if (!rawRun.includes("[")) {
|
if (!rawRun.includes("[")) {
|
||||||
|
|||||||
@@ -0,0 +1,338 @@
|
|||||||
|
/**
|
||||||
|
* Dependency-free .xlsx reader for in-browser previews.
|
||||||
|
*
|
||||||
|
* An .xlsx file is a ZIP archive of XML parts. We unzip it with the native
|
||||||
|
* DecompressionStream("deflate-raw") and parse the parts with DOMParser, so
|
||||||
|
* spreadsheet previews work in this offline deployment without adding a
|
||||||
|
* SheetJS-style dependency. Covers the parts sandbox-generated workbooks
|
||||||
|
* (openpyxl / pandas) actually use: shared strings, inline strings, numbers,
|
||||||
|
* booleans and date-formatted cells. Legacy binary .xls is NOT a ZIP and is
|
||||||
|
* not supported here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface ParsedWorksheet {
|
||||||
|
name: string;
|
||||||
|
/** Dense row-major cell text. Ragged rows are allowed. */
|
||||||
|
rows: string[][];
|
||||||
|
/** True when rows were cut off at MAX_PREVIEW_ROWS. */
|
||||||
|
truncated: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MAX_PREVIEW_ROWS = 1000;
|
||||||
|
const MAX_PREVIEW_COLS = 200;
|
||||||
|
|
||||||
|
export async function parseXlsx(data: ArrayBuffer): Promise<ParsedWorksheet[]> {
|
||||||
|
const entries = readZipEntries(new Uint8Array(data));
|
||||||
|
const readXml = async (path: string): Promise<Document | null> => {
|
||||||
|
const entry = entries.get(path);
|
||||||
|
if (!entry) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const bytes = await extractZipEntry(new Uint8Array(data), entry);
|
||||||
|
const text = new TextDecoder("utf-8").decode(bytes);
|
||||||
|
return new DOMParser().parseFromString(text, "application/xml");
|
||||||
|
};
|
||||||
|
|
||||||
|
const workbook = await readXml("xl/workbook.xml");
|
||||||
|
if (!workbook) {
|
||||||
|
throw new Error("不是有效的 xlsx 文件(缺少 xl/workbook.xml)");
|
||||||
|
}
|
||||||
|
const rels = await readXml("xl/_rels/workbook.xml.rels");
|
||||||
|
const relTargets = new Map<string, string>();
|
||||||
|
if (rels) {
|
||||||
|
for (const rel of Array.from(elementsOf(rels, "Relationship"))) {
|
||||||
|
const id = rel.getAttribute("Id");
|
||||||
|
const target = rel.getAttribute("Target");
|
||||||
|
if (id && target) {
|
||||||
|
relTargets.set(id, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sharedStrings = await readSharedStrings(readXml);
|
||||||
|
const dateStyleFlags = await readDateStyleFlags(readXml);
|
||||||
|
|
||||||
|
const sheets: ParsedWorksheet[] = [];
|
||||||
|
for (const sheet of Array.from(elementsOf(workbook, "sheet"))) {
|
||||||
|
const name = sheet.getAttribute("name") ?? `Sheet${sheets.length + 1}`;
|
||||||
|
const rid =
|
||||||
|
sheet.getAttribute("r:id") ??
|
||||||
|
sheet.getAttributeNS(
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||||
|
"id",
|
||||||
|
) ??
|
||||||
|
"";
|
||||||
|
const target = relTargets.get(rid) ?? `worksheets/sheet${sheets.length + 1}.xml`;
|
||||||
|
const path = target.startsWith("/")
|
||||||
|
? target.slice(1)
|
||||||
|
: `xl/${target.replace(/^\.\//, "")}`;
|
||||||
|
const doc = await readXml(path);
|
||||||
|
if (!doc) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sheets.push({
|
||||||
|
name,
|
||||||
|
...parseWorksheet(doc, sharedStrings, dateStyleFlags),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (sheets.length === 0) {
|
||||||
|
throw new Error("xlsx 文件中没有可读取的工作表");
|
||||||
|
}
|
||||||
|
return sheets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Namespace-agnostic tag lookup — xlsx parts use a default namespace. */
|
||||||
|
function elementsOf(root: Document | Element, localName: string): Element[] {
|
||||||
|
return Array.from(root.getElementsByTagNameNS("*", localName));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readSharedStrings(
|
||||||
|
readXml: (path: string) => Promise<Document | null>,
|
||||||
|
): Promise<string[]> {
|
||||||
|
const doc = await readXml("xl/sharedStrings.xml");
|
||||||
|
if (!doc) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return elementsOf(doc, "si").map((si) =>
|
||||||
|
elementsOf(si, "t")
|
||||||
|
.map((t) => t.textContent ?? "")
|
||||||
|
.join(""),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For each cell style (cellXfs index), whether its number format is a
|
||||||
|
* date/time format — those cells hold Excel serial date numbers that must be
|
||||||
|
* rendered as dates instead of raw numbers like 45000.
|
||||||
|
*/
|
||||||
|
async function readDateStyleFlags(
|
||||||
|
readXml: (path: string) => Promise<Document | null>,
|
||||||
|
): Promise<boolean[]> {
|
||||||
|
const doc = await readXml("xl/styles.xml");
|
||||||
|
if (!doc) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const customDateFormats = new Set<number>();
|
||||||
|
for (const numFmt of elementsOf(doc, "numFmt")) {
|
||||||
|
const id = Number(numFmt.getAttribute("numFmtId"));
|
||||||
|
const code = numFmt.getAttribute("formatCode") ?? "";
|
||||||
|
if (Number.isFinite(id) && isDateFormatCode(code)) {
|
||||||
|
customDateFormats.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cellXfs = elementsOf(doc, "cellXfs")[0];
|
||||||
|
if (!cellXfs) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return elementsOf(cellXfs, "xf").map((xf) => {
|
||||||
|
const numFmtId = Number(xf.getAttribute("numFmtId") ?? "0");
|
||||||
|
return isBuiltinDateFormat(numFmtId) || customDateFormats.has(numFmtId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBuiltinDateFormat(numFmtId: number): boolean {
|
||||||
|
return (
|
||||||
|
(numFmtId >= 14 && numFmtId <= 22) ||
|
||||||
|
(numFmtId >= 27 && numFmtId <= 36) ||
|
||||||
|
(numFmtId >= 45 && numFmtId <= 47) ||
|
||||||
|
(numFmtId >= 50 && numFmtId <= 58)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDateFormatCode(code: string): boolean {
|
||||||
|
// Strip quoted literals, color/condition tags and escapes, then look for
|
||||||
|
// date/time tokens.
|
||||||
|
const cleaned = code
|
||||||
|
.replace(/"[^"]*"/g, "")
|
||||||
|
.replace(/\[[^\]]*\]/g, "")
|
||||||
|
.replace(/\\./g, "");
|
||||||
|
return /[ymdhs]/i.test(cleaned) && !/#|0/.test(cleaned);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseWorksheet(
|
||||||
|
doc: Document,
|
||||||
|
sharedStrings: string[],
|
||||||
|
dateStyleFlags: boolean[],
|
||||||
|
): { rows: string[][]; truncated: boolean } {
|
||||||
|
const rows: string[][] = [];
|
||||||
|
let truncated = false;
|
||||||
|
for (const row of elementsOf(doc, "row")) {
|
||||||
|
const rowNumber = Number(row.getAttribute("r") ?? rows.length + 1);
|
||||||
|
if (rowNumber > MAX_PREVIEW_ROWS) {
|
||||||
|
truncated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (rows.length < rowNumber - 1) {
|
||||||
|
rows.push([]);
|
||||||
|
}
|
||||||
|
const cells: string[] = [];
|
||||||
|
for (const cell of elementsOf(row, "c")) {
|
||||||
|
const ref = cell.getAttribute("r") ?? "";
|
||||||
|
const columnIndex = ref
|
||||||
|
? columnIndexOfRef(ref)
|
||||||
|
: cells.length;
|
||||||
|
if (columnIndex >= MAX_PREVIEW_COLS) {
|
||||||
|
truncated = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while (cells.length < columnIndex) {
|
||||||
|
cells.push("");
|
||||||
|
}
|
||||||
|
cells[columnIndex] = readCellText(cell, sharedStrings, dateStyleFlags);
|
||||||
|
}
|
||||||
|
rows.push(cells);
|
||||||
|
}
|
||||||
|
// Drop trailing fully-empty rows so a sparse sheet doesn't render a long
|
||||||
|
// empty tail.
|
||||||
|
while (rows.length > 0 && rows[rows.length - 1]!.every((cell) => !cell)) {
|
||||||
|
rows.pop();
|
||||||
|
}
|
||||||
|
return { rows, truncated };
|
||||||
|
}
|
||||||
|
|
||||||
|
function readCellText(
|
||||||
|
cell: Element,
|
||||||
|
sharedStrings: string[],
|
||||||
|
dateStyleFlags: boolean[],
|
||||||
|
): string {
|
||||||
|
const type = cell.getAttribute("t") ?? "n";
|
||||||
|
if (type === "inlineStr") {
|
||||||
|
const is = elementsOf(cell, "is")[0];
|
||||||
|
if (!is) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return elementsOf(is, "t")
|
||||||
|
.map((t) => t.textContent ?? "")
|
||||||
|
.join("");
|
||||||
|
}
|
||||||
|
const value = elementsOf(cell, "v")[0]?.textContent ?? "";
|
||||||
|
if (type === "s") {
|
||||||
|
return sharedStrings[Number(value)] ?? "";
|
||||||
|
}
|
||||||
|
if (type === "b") {
|
||||||
|
return value === "1" ? "TRUE" : "FALSE";
|
||||||
|
}
|
||||||
|
if (type === "str" || type === "e") {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
// Numeric cell — render date-styled serial numbers as dates.
|
||||||
|
if (value !== "") {
|
||||||
|
const styleIndex = Number(cell.getAttribute("s") ?? "-1");
|
||||||
|
if (dateStyleFlags[styleIndex]) {
|
||||||
|
const formatted = formatExcelSerialDate(Number(value));
|
||||||
|
if (formatted) {
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatExcelSerialDate(serial: number): string | null {
|
||||||
|
if (!Number.isFinite(serial)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Excel's day 0 is 1899-12-30 (the offset absorbs the fictitious 1900-02-29).
|
||||||
|
const ms = Math.round(serial * 86400000);
|
||||||
|
const date = new Date(Date.UTC(1899, 11, 30) + ms);
|
||||||
|
if (Number.isNaN(date.getTime())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const pad = (n: number) => String(n).padStart(2, "0");
|
||||||
|
const datePart = `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
||||||
|
const timePart = `${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}`;
|
||||||
|
if (serial < 1) {
|
||||||
|
return timePart;
|
||||||
|
}
|
||||||
|
return timePart === "00:00:00" ? datePart : `${datePart} ${timePart}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function columnIndexOfRef(ref: string): number {
|
||||||
|
let index = 0;
|
||||||
|
for (let i = 0; i < ref.length; i++) {
|
||||||
|
const code = ref.charCodeAt(i);
|
||||||
|
if (code >= 65 && code <= 90) {
|
||||||
|
index = index * 26 + (code - 64);
|
||||||
|
} else if (code >= 97 && code <= 122) {
|
||||||
|
index = index * 26 + (code - 96);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Math.max(0, index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Minimal ZIP reading (central directory + stored/deflate entries)
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
interface ZipEntry {
|
||||||
|
compressionMethod: number;
|
||||||
|
compressedSize: number;
|
||||||
|
localHeaderOffset: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readZipEntries(bytes: Uint8Array): Map<string, ZipEntry> {
|
||||||
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||||
|
// End of central directory record: signature 0x06054b50, located within the
|
||||||
|
// last 22..(22+65535) bytes depending on the archive comment length.
|
||||||
|
let eocd = -1;
|
||||||
|
const scanStart = Math.max(0, bytes.length - 22 - 65535);
|
||||||
|
for (let i = bytes.length - 22; i >= scanStart; i--) {
|
||||||
|
if (view.getUint32(i, true) === 0x06054b50) {
|
||||||
|
eocd = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eocd < 0) {
|
||||||
|
throw new Error("不是有效的 xlsx/zip 文件");
|
||||||
|
}
|
||||||
|
const entryCount = view.getUint16(eocd + 10, true);
|
||||||
|
let offset = view.getUint32(eocd + 16, true);
|
||||||
|
|
||||||
|
const entries = new Map<string, ZipEntry>();
|
||||||
|
for (let i = 0; i < entryCount; i++) {
|
||||||
|
if (view.getUint32(offset, true) !== 0x02014b50) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const compressionMethod = view.getUint16(offset + 10, true);
|
||||||
|
const compressedSize = view.getUint32(offset + 20, true);
|
||||||
|
const nameLength = view.getUint16(offset + 28, true);
|
||||||
|
const extraLength = view.getUint16(offset + 30, true);
|
||||||
|
const commentLength = view.getUint16(offset + 32, true);
|
||||||
|
const localHeaderOffset = view.getUint32(offset + 42, true);
|
||||||
|
const name = new TextDecoder("utf-8").decode(
|
||||||
|
bytes.subarray(offset + 46, offset + 46 + nameLength),
|
||||||
|
);
|
||||||
|
entries.set(name, { compressionMethod, compressedSize, localHeaderOffset });
|
||||||
|
offset += 46 + nameLength + extraLength + commentLength;
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function extractZipEntry(
|
||||||
|
bytes: Uint8Array,
|
||||||
|
entry: ZipEntry,
|
||||||
|
): Promise<Uint8Array> {
|
||||||
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
||||||
|
const base = entry.localHeaderOffset;
|
||||||
|
if (view.getUint32(base, true) !== 0x04034b50) {
|
||||||
|
throw new Error("xlsx/zip 文件结构损坏");
|
||||||
|
}
|
||||||
|
const nameLength = view.getUint16(base + 26, true);
|
||||||
|
const extraLength = view.getUint16(base + 28, true);
|
||||||
|
const dataStart = base + 30 + nameLength + extraLength;
|
||||||
|
const compressed = bytes.subarray(dataStart, dataStart + entry.compressedSize);
|
||||||
|
if (entry.compressionMethod === 0) {
|
||||||
|
return compressed;
|
||||||
|
}
|
||||||
|
if (entry.compressionMethod !== 8) {
|
||||||
|
throw new Error(`不支持的 zip 压缩方式: ${entry.compressionMethod}`);
|
||||||
|
}
|
||||||
|
// .slice() copies into a fresh ArrayBuffer, which also satisfies BlobPart's
|
||||||
|
// non-shared-buffer requirement.
|
||||||
|
const stream = new Blob([compressed.slice()]).stream().pipeThrough(
|
||||||
|
new DecompressionStream("deflate-raw"),
|
||||||
|
);
|
||||||
|
return new Uint8Array(await new Response(stream).arrayBuffer());
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { BotIcon, MessageCircleQuestionIcon, PlusSquare } from "lucide-react";
|
import { BotIcon, PlusSquare } from "lucide-react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useRouteBase } from "@/core/route-base";
|
import { useRouteBase } from "@/core/route-base";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
@@ -62,7 +62,6 @@ export default function AgentChatPage() {
|
|||||||
const agentDisplayName = desensitize(
|
const agentDisplayName = desensitize(
|
||||||
agent?.name ?? (isAgentLoading ? t.common.loading : ""),
|
agent?.name ?? (isAgentLoading ? t.common.loading : ""),
|
||||||
);
|
);
|
||||||
// 常用问题 shown as a list beside the input box on the landing screen.
|
|
||||||
const commonQuestions = useMemo(
|
const commonQuestions = useMemo(
|
||||||
() => normalizeAgentQuestions(agent?.common_questions),
|
() => normalizeAgentQuestions(agent?.common_questions),
|
||||||
[agent?.common_questions],
|
[agent?.common_questions],
|
||||||
@@ -181,9 +180,9 @@ export default function AgentChatPage() {
|
|||||||
separate flex sibling, so nothing in the main column can ever bleed
|
separate flex sibling, so nothing in the main column can ever bleed
|
||||||
over it. */}
|
over it. */}
|
||||||
<div className="flex size-full min-h-0 overflow-hidden">
|
<div className="flex size-full min-h-0 overflow-hidden">
|
||||||
{/* ── Left: main conversation column ───────────────────────────── */}
|
{/* Left: main conversation column */}
|
||||||
<main className="flex min-h-0 min-w-0 flex-1 flex-col">
|
<main className="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||||
{/* Header — in normal flow (not absolute), fixed height. */}
|
{/* Header in normal flow, fixed height. */}
|
||||||
<header className="bg-card/90 border-border/70 flex h-12 shrink-0 items-center gap-2 border-b px-4 backdrop-blur-md">
|
<header className="bg-card/90 border-border/70 flex h-12 shrink-0 items-center gap-2 border-b px-4 backdrop-blur-md">
|
||||||
<div className="flex shrink-0 items-center gap-1.5 rounded-md border px-2 py-1">
|
<div className="flex shrink-0 items-center gap-1.5 rounded-md border px-2 py-1">
|
||||||
<BotIcon className="text-primary h-3.5 w-3.5" />
|
<BotIcon className="text-primary h-3.5 w-3.5" />
|
||||||
@@ -223,9 +222,9 @@ export default function AgentChatPage() {
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
{isLandingState ? (
|
{isLandingState ? (
|
||||||
/* ── home: centered hero + suggested questions + input ──────
|
/* Home: centered hero, suggested questions, and input.
|
||||||
Everything lives inside the scrollable main column. No fixed,
|
Everything lives inside the scrollable main column. No fixed,
|
||||||
no absolute, no viewport centering — so the avatar can't touch
|
no absolute, no viewport centering, so the avatar can't touch
|
||||||
the header and the input can't cover the sidebar. */
|
the header and the input can't cover the sidebar. */
|
||||||
<div className="flex min-h-0 flex-1 flex-col items-center overflow-y-auto px-6 pb-10 pt-16 sm:pt-24">
|
<div className="flex min-h-0 flex-1 flex-col items-center overflow-y-auto px-6 pb-10 pt-16 sm:pt-24">
|
||||||
<AgentWelcome
|
<AgentWelcome
|
||||||
@@ -233,42 +232,28 @@ export default function AgentChatPage() {
|
|||||||
agentName={agentDisplayName}
|
agentName={agentDisplayName}
|
||||||
className="mb-7"
|
className="mb-7"
|
||||||
/>
|
/>
|
||||||
{/* 常用问题 sit as a list to the LEFT of the input box (not as
|
<div className="w-full max-w-(--container-width-md)">
|
||||||
floating pills above it). On narrow screens the list stacks
|
|
||||||
above the input instead of squeezing it. */}
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"flex w-full flex-col gap-3 sm:flex-row sm:items-end sm:gap-4",
|
|
||||||
commonQuestions.length > 0
|
|
||||||
? "max-w-(--container-width-lg)"
|
|
||||||
: "max-w-(--container-width-md)",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{commonQuestions.length > 0 && (
|
{commonQuestions.length > 0 && (
|
||||||
<div className="border-border/60 bg-card/60 w-full shrink-0 rounded-xl border p-3 sm:w-64">
|
<div className="mb-2 flex max-h-20 flex-wrap items-start justify-start gap-2 overflow-y-auto px-1">
|
||||||
<div className="text-muted-foreground mb-2 flex items-center gap-1.5 text-xs font-medium">
|
{commonQuestions.map((question, index) => (
|
||||||
<MessageCircleQuestionIcon className="size-3.5" />
|
<button
|
||||||
常用问题
|
key={index}
|
||||||
</div>
|
type="button"
|
||||||
<div className="flex max-h-44 flex-col gap-1.5 overflow-y-auto">
|
disabled={isDemoMode}
|
||||||
{commonQuestions.map((question, index) => (
|
onClick={() =>
|
||||||
<button
|
handleSubmit({ text: question.prompt, files: [] })
|
||||||
key={index}
|
}
|
||||||
type="button"
|
title={desensitize(question.prompt)}
|
||||||
disabled={isDemoMode}
|
className={cn(
|
||||||
onClick={() =>
|
"border-border/70 bg-background/85 hover:bg-accent hover:border-border max-w-full rounded-full border px-3 py-1.5 text-left text-sm leading-5 shadow-sm transition-colors",
|
||||||
handleSubmit({ text: question.prompt, files: [] })
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
}
|
)}
|
||||||
title={desensitize(question.prompt)}
|
>
|
||||||
className={cn(
|
<span className="block max-w-[220px] truncate">
|
||||||
"border-border/60 bg-background/60 hover:bg-accent hover:border-border w-full truncate rounded-lg border px-3 py-2 text-left text-sm transition-colors",
|
|
||||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{desensitize(question.title)}
|
{desensitize(question.title)}
|
||||||
</button>
|
</span>
|
||||||
))}
|
</button>
|
||||||
</div>
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
@@ -298,7 +283,7 @@ export default function AgentChatPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
/* ── conversation (active / history): messages scroll, input
|
/* Conversation: messages scroll, input
|
||||||
docked at the bottom of the main column only. */
|
docked at the bottom of the main column only. */
|
||||||
<div className="flex min-h-0 flex-1 flex-col">
|
<div className="flex min-h-0 flex-1 flex-col">
|
||||||
<MessageList
|
<MessageList
|
||||||
@@ -347,8 +332,7 @@ export default function AgentChatPage() {
|
|||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
{/* ── Right: agent detail panel (profile + inline editing for
|
{/* Right: agent detail panel. */}
|
||||||
admins / owners; read-only for everyone else) ───────────────── */}
|
|
||||||
<AgentDetailPanel
|
<AgentDetailPanel
|
||||||
agent={agent}
|
agent={agent}
|
||||||
agentName={agentDisplayName}
|
agentName={agentDisplayName}
|
||||||
@@ -360,3 +344,4 @@ export default function AgentChatPage() {
|
|||||||
</ThreadContext.Provider>
|
</ThreadContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,10 +28,12 @@ import {
|
|||||||
getNodeTitle,
|
getNodeTitle,
|
||||||
} from "@/components/knowledge-graph/graphUtils";
|
} from "@/components/knowledge-graph/graphUtils";
|
||||||
import "@/components/knowledge-graph/graphStyles.css";
|
import "@/components/knowledge-graph/graphStyles.css";
|
||||||
|
import { useTheme } from "@/contexts/ThemeContext";
|
||||||
import { useKnowledgeGraph, useKnowledgeNote } from "@/core/knowledge/hooks";
|
import { useKnowledgeGraph, useKnowledgeNote } from "@/core/knowledge/hooks";
|
||||||
|
|
||||||
export default function KnowledgeGraphPage() {
|
export default function KnowledgeGraphPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { theme } = useTheme();
|
||||||
const pageRef = useRef<HTMLDivElement>(null);
|
const pageRef = useRef<HTMLDivElement>(null);
|
||||||
const canvasRef = useRef<GraphCanvasHandle>(null);
|
const canvasRef = useRef<GraphCanvasHandle>(null);
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ export default function KnowledgeGraphPage() {
|
|||||||
const [showDetail, setShowDetail] = useState(false);
|
const [showDetail, setShowDetail] = useState(false);
|
||||||
const [zoomLevel, setZoomLevel] = useState(1);
|
const [zoomLevel, setZoomLevel] = useState(1);
|
||||||
const [tooltip, setTooltip] = useState<TooltipState | null>(null);
|
const [tooltip, setTooltip] = useState<TooltipState | null>(null);
|
||||||
const [graphMode, setGraphMode] = useState<GraphMode>("explore");
|
const [graphMode, setGraphMode] = useState<GraphMode>("full");
|
||||||
const [exploreRootId, setExploreRootId] = useState<string | null>(null);
|
const [exploreRootId, setExploreRootId] = useState<string | null>(null);
|
||||||
const [expandedNodeIds, setExpandedNodeIds] = useState<Set<string>>(new Set());
|
const [expandedNodeIds, setExpandedNodeIds] = useState<Set<string>>(new Set());
|
||||||
const [visibleNodeIds, setVisibleNodeIds] = useState<Set<string>>(new Set());
|
const [visibleNodeIds, setVisibleNodeIds] = useState<Set<string>>(new Set());
|
||||||
@@ -269,14 +271,16 @@ export default function KnowledgeGraphPage() {
|
|||||||
return matches;
|
return matches;
|
||||||
}, [searchKeyword, filteredNodes]);
|
}, [searchKeyword, filteredNodes]);
|
||||||
|
|
||||||
const topNodes = useMemo(
|
const topNodes = useMemo(() => {
|
||||||
() =>
|
// 搜索时核心节点榜单只保留命中的节点,与画布高亮保持一致。
|
||||||
[...allNodes]
|
const pool = searchMatchIds
|
||||||
.map((node) => ({ node, degree: degrees.get(node.id) ?? 0 }))
|
? filteredNodes.filter((node) => searchMatchIds.has(node.id))
|
||||||
.sort((a, b) => b.degree - a.degree)
|
: allNodes;
|
||||||
.slice(0, 8),
|
return pool
|
||||||
[allNodes, degrees],
|
.map((node) => ({ node, degree: degrees.get(node.id) ?? 0 }))
|
||||||
);
|
.sort((a, b) => b.degree - a.degree)
|
||||||
|
.slice(0, 8);
|
||||||
|
}, [allNodes, filteredNodes, searchMatchIds, degrees]);
|
||||||
|
|
||||||
const selectedNode = selectedNodeId ? (nodeById.get(selectedNodeId) ?? null) : null;
|
const selectedNode = selectedNodeId ? (nodeById.get(selectedNodeId) ?? null) : null;
|
||||||
const selectedNeighbors = useMemo(() => {
|
const selectedNeighbors = useMemo(() => {
|
||||||
@@ -633,6 +637,7 @@ export default function KnowledgeGraphPage() {
|
|||||||
searchMatchIds={searchMatchIds}
|
searchMatchIds={searchMatchIds}
|
||||||
layoutType={layoutType}
|
layoutType={layoutType}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels}
|
||||||
|
theme={theme}
|
||||||
onSelectNode={handleSelectNode}
|
onSelectNode={handleSelectNode}
|
||||||
onTooltip={setTooltip}
|
onTooltip={setTooltip}
|
||||||
onZoomChange={setZoomLevel}
|
onZoomChange={setZoomLevel}
|
||||||
|
|||||||
@@ -433,14 +433,22 @@ export default function NewAgentPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<PromptInput
|
<PromptInput
|
||||||
onSubmit={({ text }) => void handleChatSubmit(text)}
|
onSubmit={({ text }) => {
|
||||||
|
if (thread.isLoading) {
|
||||||
|
void thread.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void handleChatSubmit(text);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<PromptInputTextarea
|
<PromptInputTextarea
|
||||||
placeholder="直接告诉模型你想要什么样的智能体,或回答模型的问题"
|
placeholder="直接告诉模型你想要什么样的智能体,或回答模型的问题"
|
||||||
disabled={thread.isLoading}
|
disabled={thread.isLoading}
|
||||||
/>
|
/>
|
||||||
<PromptInputFooter className="justify-end">
|
<PromptInputFooter className="justify-end">
|
||||||
<PromptInputSubmit disabled={thread.isLoading} />
|
<PromptInputSubmit
|
||||||
|
status={thread.isLoading ? "streaming" : "ready"}
|
||||||
|
/>
|
||||||
</PromptInputFooter>
|
</PromptInputFooter>
|
||||||
</PromptInput>
|
</PromptInput>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user