mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
refactor: Extract dashboard title into separate component
This commit is contained in:
parent
4a98942064
commit
3bbf87d875
@ -1,33 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
import { DashboardTitle } from "@/components/layout/dashboard-title";
|
||||
|
||||
import { Header } from "./header";
|
||||
|
||||
export function DashboardHeader() {
|
||||
const pathname = usePathname();
|
||||
|
||||
const getTitle = () => {
|
||||
if (pathname === "/dashboard") return "控制台";
|
||||
if (pathname === "/dashboard/clients") return "应用管理";
|
||||
if (pathname.includes("/dashboard/clients/")) return "应用详情";
|
||||
if (pathname === "/dashboard/settings") return "账号设置";
|
||||
if (pathname === "/admin/users") return "用户列表";
|
||||
if (pathname === "/admin/logs") return "系统日志";
|
||||
if (pathname === "/admin") return "管理后台";
|
||||
if (pathname === "/admin/clients") return "应用管理";
|
||||
if (pathname === "/admin/authorizations") return "授权管理";
|
||||
return "";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<Header />
|
||||
<div className="border-b">
|
||||
<div className="mx-auto flex h-16 max-w-7xl items-center px-4 sm:px-6 lg:px-8">
|
||||
<h1 className="text-2xl font-bold">{getTitle()}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<DashboardTitle />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
28
src/components/layout/dashboard-title.tsx
Normal file
28
src/components/layout/dashboard-title.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
export function DashboardTitle() {
|
||||
const pathname = usePathname();
|
||||
|
||||
const getTitle = () => {
|
||||
if (pathname === "/dashboard") return "控制台";
|
||||
if (pathname === "/dashboard/clients") return "应用管理";
|
||||
if (pathname.includes("/dashboard/clients/")) return "应用详情";
|
||||
if (pathname === "/dashboard/settings") return "账号设置";
|
||||
if (pathname === "/admin/users") return "用户列表";
|
||||
if (pathname === "/admin/logs") return "系统日志";
|
||||
if (pathname === "/admin") return "管理后台";
|
||||
if (pathname === "/admin/clients") return "应用管理";
|
||||
if (pathname === "/admin/authorizations") return "授权管理";
|
||||
return "";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="border-b">
|
||||
<div className="mx-auto flex h-16 max-w-7xl items-center px-4 sm:px-6 lg:px-8">
|
||||
<h1 className="text-2xl font-bold">{getTitle()}</h1>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user