包含 s-file 后端、React 前端、MeshSafe 安全检测对接,以及内外网两套 compose/nginx/配置(仅前端 28180/28280 对外发布,其余端口不暴露)。 说明:deploy/config/application-iw.yml 与 application-ow.yml 按维护者 明确要求原样入库,其中含本机 Docker 用的库口令、RabbitMQ 口令与 JWT 密钥;上生产前需替换。
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
SidebarHeader,
|
|
} from "@/components/ui/sidebar";
|
|
import logo from "@/assets/image/logo.png";
|
|
import { useLocation, useRouter } from "@tanstack/react-router";
|
|
import { useMemo } from "react";
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
const title = import.meta.env.VITE_APP_TITLE;
|
|
const isInside = import.meta.env.VITE_IS_INSIDE === "true";
|
|
|
|
type Props = {
|
|
menus: any[];
|
|
isAdmin?: boolean;
|
|
};
|
|
|
|
export function AppSidebar({ menus, isAdmin }: Props) {
|
|
const router = useRouter();
|
|
const location = useLocation();
|
|
const currentPath = useMemo(
|
|
() => location.pathname.replace(import.meta.env.VITE_BASEPATH, ""),
|
|
[location.pathname],
|
|
);
|
|
return (
|
|
<Sidebar className="[&_.bg-sidebar]:bg-transparent border-none">
|
|
<SidebarHeader className="m-2 p-0">
|
|
<div className="flex items-center space-x-2 text-left w-full h-[60px]">
|
|
<img
|
|
src={logo}
|
|
alt=""
|
|
className="size-12 object-contain rounded-full bg-white overflow-hidden"
|
|
/>
|
|
<div className="text-primary text-2xl font-bold">
|
|
{isAdmin ? "管理后台" : title}
|
|
</div>
|
|
{isInside && (
|
|
<Badge className="bg-transparent text-primary border-primary">
|
|
内网
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
</SidebarHeader>
|
|
<SidebarContent className="rounded-xl bg-white/50 backdrop-blur-lg m-2 mt-0">
|
|
<SidebarGroup>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{menus.map((item) => (
|
|
<SidebarMenuItem key={item.title}>
|
|
<SidebarMenuButton
|
|
asChild
|
|
isActive={currentPath === item.url}
|
|
onClick={() => {
|
|
router.navigate({ to: item.url });
|
|
}}
|
|
className="data-[active=true]:!bg-primary data-[active=true]:!text-white hover:bg-primary/10"
|
|
>
|
|
<div className="h-[40px] px-4 cursor-pointer">
|
|
{item.icon}
|
|
<span>{item.title}</span>
|
|
</div>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
</SidebarContent>
|
|
</Sidebar>
|
|
);
|
|
}
|