refactor: support i18n
This commit is contained in:
@@ -4,6 +4,7 @@ import type { ComponentProps } from "react"
|
||||
import Link from "next/link"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { useI18n } from "@/i18n/provider"
|
||||
import {
|
||||
filterDashboardNavForSession,
|
||||
filterDashboardSecondaryNavForSession,
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
} from "@/components/ui/sidebar"
|
||||
|
||||
export function AppSidebar({ ...props }: ComponentProps<typeof Sidebar>) {
|
||||
const t = useI18n()
|
||||
const { session } = useAuth()
|
||||
const navSections = useMemo(
|
||||
() => filterDashboardNavForSession(session?.permissions, session?.roles),
|
||||
@@ -33,8 +35,8 @@ export function AppSidebar({ ...props }: ComponentProps<typeof Sidebar>) {
|
||||
[session?.permissions, session?.roles]
|
||||
)
|
||||
const user = {
|
||||
name: session?.user.nickname || session?.user.username || "未登录",
|
||||
email: session?.user.username || "guest",
|
||||
name: session?.user.nickname || session?.user.username || t("common.notSignedIn"),
|
||||
email: session?.user.username || t("common.guest"),
|
||||
avatar: session?.user.avatar || "",
|
||||
}
|
||||
|
||||
@@ -49,19 +51,26 @@ export function AppSidebar({ ...props }: ComponentProps<typeof Sidebar>) {
|
||||
>
|
||||
<img
|
||||
src="/images/logo.svg"
|
||||
alt="贝壳AGENT"
|
||||
alt={t("app.brand")}
|
||||
width="32"
|
||||
height="32"
|
||||
className="size-7 shrink-0 object-contain"
|
||||
/>
|
||||
<span className="text-base font-semibold">贝壳AGENT</span>
|
||||
<span className="text-base font-semibold">{t("app.brand")}</span>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarHeader>
|
||||
<SidebarContent>
|
||||
{navSections.map((section) => (
|
||||
<NavMain key={section.title} title={section.title} items={section.items} />
|
||||
<NavMain
|
||||
key={section.titleKey}
|
||||
title={t(section.titleKey)}
|
||||
items={section.items.map((item) => ({
|
||||
...item,
|
||||
title: t(item.titleKey),
|
||||
}))}
|
||||
/>
|
||||
))}
|
||||
{secondaryNavItems.length > 0 ? (
|
||||
<NavSecondary items={secondaryNavItems} className="mt-auto" />
|
||||
|
||||
Reference in New Issue
Block a user