Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions web/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,32 @@ describe("路由与根门", () => {

const brand = screen.getByRole("link", { name: "Template" })
expect(brand.getAttribute("href")).toBe("/workbench")
// 站点标是装饰性图形:带在链接里,但不进可访问名(名仍只是站名)。
const mark = brand.querySelector("svg")
expect(mark).not.toBeNull()
expect(mark).toHaveAttribute("aria-hidden", "true")
expect(
screen.getByText(/Template · \d+\.\d+\.\d+ · [0-9a-f]+\+build\.\d+/)
).toBeInTheDocument()
})

it("移动抽屉页头的站名同样带站点标", async () => {
vi.mocked(setupApi.state).mockResolvedValue(
setupState({ ownerExists: true, enabled: false })
)
vi.mocked(meApi.get).mockResolvedValue(me())

renderAt(routes, "/workbench")
await screen.findByRole("heading", { name: "工作台" })

await accountUser().click(screen.getByRole("button", { name: "菜单" }))

const dialog = await screen.findByRole("dialog")
const brand = within(dialog).getByRole("link", { name: "Template" })
expect(brand.getAttribute("href")).toBe("/workbench")
expect(brand.querySelector("svg")).toHaveAttribute("aria-hidden", "true")
})

it("侧栏宽度与收起状态从 localStorage 恢复,展开后写回", async () => {
vi.mocked(setupApi.state).mockResolvedValue(
setupState({ ownerExists: true, enabled: false })
Expand Down
11 changes: 9 additions & 2 deletions web/src/components/app-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { useTranslation } from "react-i18next"
import { NavLink, Outlet, useLocation, useNavigate } from "react-router"
import { LanguageCycleButton } from "@/components/language-toggle"
import { SiteLogo } from "@/components/site-logo"
import { ThemeCycleButton } from "@/components/theme-toggle"
import { Button } from "@/components/ui/button"
import {
Expand Down Expand Up @@ -227,8 +228,9 @@ export function AppShell() {
<SidebarHeader className="p-0">
<NavLink
to="/workbench"
className="flex h-14 items-center px-4 font-heading text-sm font-semibold tracking-tight transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:hidden"
className="flex h-14 items-center gap-2 px-4 font-heading text-sm font-semibold tracking-tight transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:hidden"
>
<SiteLogo />
{name}
</NavLink>
</SidebarHeader>
Expand Down Expand Up @@ -300,7 +302,12 @@ export function AppShell() {
<SheetContent side="left" className="w-64 bg-sidebar p-0">
<SheetHeader className="border-b px-4 py-3">
<SheetTitle className="text-sm font-semibold">
<NavLink to="/workbench" onClick={() => setMobileOpen(false)}>
<NavLink
to="/workbench"
onClick={() => setMobileOpen(false)}
className="inline-flex items-center gap-2"
>
<SiteLogo />
{name}
</NavLink>
</SheetTitle>
Expand Down
29 changes: 29 additions & 0 deletions web/src/components/site-logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { cn } from "@/lib/utils"

type SiteLogoProps = {
className?: string
}

/**
* 站点标(菱形环):外菱形挖掉内菱形,靠 evenodd 成环。
*
* 单色几何标,颜色一律继承 `currentColor`:亮/暗主题与侧栏前景色共用一份,
* 不做两套资源。纯装饰——可访问名交给同一行里的站名,因此 aria-hidden 后
* 不进入链接名。默认 `size-5`,尺寸需要时由调用方经 `cn` 覆盖。
*/
export function SiteLogo({ className }: SiteLogoProps) {
return (
<svg
viewBox="0 0 24 24"
fill="currentColor"
aria-hidden="true"
focusable="false"
className={cn("size-5 shrink-0", className)}
>
<path
fillRule="evenodd"
d="M12 2.5 21.5 12 12 21.5 2.5 12 12 2.5Z M12 8.6 15.4 12 12 15.4 8.6 12 12 8.6Z"
/>
</svg>
)
}
Loading