Merge origin/develop into feature/a-card-operations
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router";
|
||||
|
||||
import { PanelLeft, ChevronRight } from "lucide-react";
|
||||
import { navigation } from "./platform.navigation";
|
||||
import { ChevronRight, Menu } from "lucide-react";
|
||||
import {
|
||||
navigation,
|
||||
pathForPage,
|
||||
pageTitleFromPath,
|
||||
} from "./platform.navigation";
|
||||
import type { ActivePage, NavigationItem } from "./platform.navigation";
|
||||
import { Collapsible } from "@base-ui/react/collapsible";
|
||||
|
||||
@@ -21,9 +25,10 @@ import {
|
||||
SidebarMenuSub,
|
||||
SidebarMenuSubItem,
|
||||
SidebarMenuSubButton,
|
||||
SidebarTrigger,
|
||||
SidebarInset,
|
||||
useSidebar,
|
||||
} from "~/components/ui/sidebar";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { useApi, useAuth, usePermission, type AuthWorkspace } from "~/context/AuthContext";
|
||||
import { useEditSessionLifecycle } from "~/features/platform/hooks/useEditSessionLifecycle";
|
||||
import {
|
||||
@@ -47,11 +52,6 @@ function pageFromPath(pathname: string): ActivePage {
|
||||
return "home";
|
||||
}
|
||||
|
||||
function pathForPage(page: ActivePage): string {
|
||||
if (page === "home") return "/workbench";
|
||||
return `/${page}`;
|
||||
}
|
||||
|
||||
const OPERATIONS_GLOBAL_WORKSPACE: AuthWorkspace = {
|
||||
workspace_id: "operations-global",
|
||||
workspace_code: "operations-global",
|
||||
@@ -59,7 +59,6 @@ const OPERATIONS_GLOBAL_WORKSPACE: AuthWorkspace = {
|
||||
role_code: "viewer",
|
||||
role_name: "运维用户",
|
||||
};
|
||||
|
||||
export function meta({}: Route.MetaArgs) {
|
||||
return [
|
||||
{ title: "模型实验开发平台" },
|
||||
@@ -151,6 +150,26 @@ function NavRow({
|
||||
);
|
||||
}
|
||||
|
||||
function SidebarCollapseButton() {
|
||||
const { toggleSidebar, state } = useSidebar();
|
||||
const collapsed = state === "collapsed";
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleSidebar}
|
||||
className={cn(
|
||||
"flex w-full cursor-pointer items-center gap-2.5 border-t border-sidebar-border py-3.5 text-sm text-sidebar-foreground/75 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
||||
collapsed ? "justify-center px-0" : "px-[17px]",
|
||||
)}
|
||||
aria-label={collapsed ? "展开菜单" : "收起菜单"}
|
||||
>
|
||||
<Menu className="size-4 shrink-0" />
|
||||
{!collapsed && <span>收起菜单</span>}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PlatformLayout() {
|
||||
const { currentWorkspace } = useAuth();
|
||||
const location = useLocation();
|
||||
@@ -171,6 +190,7 @@ function AuthenticatedLayout() {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const activePage = pageFromPath(location.pathname);
|
||||
const pageTitle = pageTitleFromPath(location.pathname);
|
||||
const auth = useAuth();
|
||||
const {
|
||||
user,
|
||||
@@ -284,16 +304,14 @@ function AuthenticatedLayout() {
|
||||
))}
|
||||
</SidebarMenu>
|
||||
</SidebarContent>
|
||||
<SidebarFooter>
|
||||
<SidebarTrigger>
|
||||
<PanelLeft /> {!sidebarCollapsed && <span>收起菜单</span>}
|
||||
</SidebarTrigger>
|
||||
<SidebarFooter className="p-0">
|
||||
<SidebarCollapseButton />
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
|
||||
<SidebarInset className="h-screen min-w-0">
|
||||
<Topbar
|
||||
activePage={activePage}
|
||||
pageTitle={pageTitle}
|
||||
apiOnline={apiOnline}
|
||||
user={user}
|
||||
currentWorkspace={effectiveWorkspace}
|
||||
|
||||
Reference in New Issue
Block a user