feat: system knowledge base management with admin/user role separation
- Auto-create system KBs from data/knowledge_base/ subdirectories on startup - Upgrade existing user KBs to system KBs when matching directory found - Admin can upload to system KBs (saved to knowledge_base dir) - Regular users see only their own KBs on knowledge page - Fix API permission checks for system KBs (list, detail, documents, update, delete) - Add is_superuser to UserResponse and frontend User type - Fix sidebar session menu visibility for long titles Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Download, FileText, FileJson, File } from "lucide-react";
|
||||
import { Download, FileText, FileJson } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
@@ -61,12 +61,6 @@ export default function ExportDialog({ sessionId, sessionTitle, children, onClos
|
||||
description: "可读性好的文本格式,适合分享",
|
||||
icon: FileText,
|
||||
},
|
||||
{
|
||||
value: "pdf",
|
||||
label: "PDF 格式",
|
||||
description: "适合打印和正式文档",
|
||||
icon: File,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,7 +11,7 @@ import { format } from "date-fns";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useChatStore } from "@/store/chat";
|
||||
import SourceReferences from "./source-references";
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
interface MessageItemProps {
|
||||
@@ -21,6 +21,7 @@ interface MessageItemProps {
|
||||
|
||||
const ThinkingProcess = ({ thinking, isStreaming }: { thinking: ThinkingStep[]; isStreaming?: boolean }) => {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
if (!thinking || thinking.length === 0) return null;
|
||||
|
||||
// 只提取有实际内容的步骤:推理内容和检索文档
|
||||
@@ -32,6 +33,11 @@ const ThinkingProcess = ({ thinking, isStreaming }: { thinking: ThinkingStep[];
|
||||
// 没有推理内容也没有文档详情时不显示
|
||||
if (!hasReasoning && !hasDocs && !isStreaming) return null;
|
||||
|
||||
// 流式生成时自动展开,完成后自动收起
|
||||
useEffect(() => {
|
||||
setExpanded(!!isStreaming);
|
||||
}, [isStreaming]);
|
||||
|
||||
// 合并推理文本
|
||||
const reasoningText = reasoningSteps.map(s => s.message).join('');
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Download,
|
||||
Search,
|
||||
MoreVertical,
|
||||
PanelLeftClose,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -121,9 +122,13 @@ export default function Sidebar({ onClose }: SidebarProps) {
|
||||
<div className="px-3 pt-4 pb-3 space-y-3 border-b border-border/30">
|
||||
<div className="flex items-center justify-between px-1">
|
||||
<span className="text-sm font-semibold text-foreground">对话</span>
|
||||
<Button onClick={handleNewChat} size="sm" variant="ghost" className="h-7 w-7 p-0 hover:bg-primary/10 hover:text-primary">
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
|
||||
title="收起侧边栏"
|
||||
>
|
||||
<PanelLeftClose className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" />
|
||||
|
||||
Reference in New Issue
Block a user