- 创建智能体页面:保存后自动跳转列表页、技能列表增加搜索过滤框 - Bootstrap 模式:开放全部技能可见性,注入专属提示词(skill_list 匹配意图、禁止 skill_manage) - 管理员记忆页面:新增 AdminMemoryPage 及路由,支持查看/编辑用户记忆条目 - 内存配置与管理员用户接口同步更新 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
214 lines
7.2 KiB
TypeScript
214 lines
7.2 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
BellIcon,
|
|
BrainIcon,
|
|
CalendarClockIcon,
|
|
ChevronsUpDown,
|
|
GaugeIcon,
|
|
HistoryIcon,
|
|
MessageSquareCodeIcon,
|
|
MessageSquarePlusIcon,
|
|
Settings2Icon,
|
|
SettingsIcon,
|
|
TagsIcon,
|
|
UsersIcon,
|
|
} from "lucide-react";
|
|
import { useEffect, useState } from "react";
|
|
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import {
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
useSidebar,
|
|
} from "@/components/ui/sidebar";
|
|
import { getStoredAuth } from "@/core/auth";
|
|
import { useI18n } from "@/core/i18n/hooks";
|
|
import { useUnreadCount } from "@/core/notifications";
|
|
|
|
import { NotificationDialog } from "./notification-dialog";
|
|
import { useNavigate } from "react-router-dom";
|
|
|
|
import { SettingsDialog } from "./settings";
|
|
|
|
function NavMenuButtonContent({
|
|
isSidebarOpen,
|
|
t,
|
|
}: {
|
|
isSidebarOpen: boolean;
|
|
t: ReturnType<typeof useI18n>["t"];
|
|
}) {
|
|
return isSidebarOpen ? (
|
|
<div className="text-sidebar-foreground/85 flex w-full items-center gap-2 text-left text-sm">
|
|
<SettingsIcon className="size-4" />
|
|
<span>{t.workspace.settingsAndMore}</span>
|
|
<ChevronsUpDown className="text-sidebar-foreground/55 ml-auto size-4" />
|
|
</div>
|
|
) : (
|
|
<div className="flex size-full items-center justify-center">
|
|
<SettingsIcon className="text-sidebar-foreground/80 size-4" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function WorkspaceNavMenu() {
|
|
const navigate = useNavigate();
|
|
const isAdmin = getStoredAuth()?.system_role === "admin";
|
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
const [settingsDefaultSection, setSettingsDefaultSection] = useState<
|
|
"appearance" | "memory" | "tools" | "about"
|
|
>("appearance");
|
|
const [notificationOpen, setNotificationOpen] = useState(false);
|
|
const [mounted, setMounted] = useState(false);
|
|
const { open: isSidebarOpen } = useSidebar();
|
|
const { t } = useI18n();
|
|
const { data: unreadCount = 0 } = useUnreadCount();
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<SettingsDialog
|
|
open={settingsOpen}
|
|
onOpenChange={setSettingsOpen}
|
|
defaultSection={settingsDefaultSection}
|
|
/>
|
|
<NotificationDialog
|
|
open={notificationOpen}
|
|
onOpenChange={setNotificationOpen}
|
|
/>
|
|
<SidebarMenu className="w-full">
|
|
<SidebarMenuItem>
|
|
{mounted ? (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<SidebarMenuButton
|
|
size="lg"
|
|
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
|
>
|
|
<NavMenuButtonContent isSidebarOpen={isSidebarOpen} t={t} />
|
|
</SidebarMenuButton>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent
|
|
className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
|
align="end"
|
|
sideOffset={4}
|
|
>
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem onClick={() => setNotificationOpen(true)}>
|
|
<BellIcon />
|
|
{t.notifications.title}
|
|
{unreadCount > 0 && (
|
|
<span className="ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-red-500 px-1 text-[10px] font-medium leading-none text-white">
|
|
{unreadCount > 99 ? "99+" : unreadCount}
|
|
</span>
|
|
)}
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
onClick={() => {
|
|
setSettingsDefaultSection("appearance");
|
|
setSettingsOpen(true);
|
|
}}
|
|
>
|
|
<Settings2Icon />
|
|
{t.common.settings}
|
|
</DropdownMenuItem>
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
navigate("/page/workspace/settings/recommended-questions")
|
|
}
|
|
>
|
|
<MessageSquarePlusIcon />
|
|
推荐问题配置
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
navigate("/page/workspace/settings/prompt-prefix")
|
|
}
|
|
>
|
|
<MessageSquareCodeIcon />
|
|
问答前缀配置
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
navigate("/page/workspace/settings/llm-metrics")
|
|
}
|
|
>
|
|
<GaugeIcon />
|
|
大模型调用统计
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() => navigate("/page/workspace/admin/users")}
|
|
>
|
|
<UsersIcon />
|
|
用户管理
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() => navigate("/page/workspace/admin/memory")}
|
|
>
|
|
<BrainIcon />
|
|
记忆管理
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
navigate("/page/workspace/admin/scheduled-tasks")
|
|
}
|
|
>
|
|
<CalendarClockIcon />
|
|
定时任务管理
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() =>
|
|
navigate("/page/workspace/admin/user-activity")
|
|
}
|
|
>
|
|
<HistoryIcon />
|
|
用户活动审计
|
|
</DropdownMenuItem>
|
|
)}
|
|
{isAdmin && (
|
|
<DropdownMenuItem
|
|
onClick={() => navigate("/page/workspace/admin/tags")}
|
|
>
|
|
<TagsIcon />
|
|
{t.adminTags.title}
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
) : (
|
|
<SidebarMenuButton size="lg" className="pointer-events-none">
|
|
<NavMenuButtonContent isSidebarOpen={isSidebarOpen} t={t} />
|
|
</SidebarMenuButton>
|
|
)}
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</>
|
|
);
|
|
}
|