feat: 更新主题配置与系统设置
This commit is contained in:
1 parent
1555d5344b
commit
151ecceb85
12 files changed
+145
-27
No files matched your search
@@ -29,10 +29,12 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
import { useTheme } from "../contexts/ThemeContext";
|
||||
|
||||
const iconButtonClass = (isDark: boolean, isPaleLightTheme: boolean) =>
|
||||
const iconButtonClass = (isDark: boolean, isPaleLightTheme: boolean, isCustomTheme: boolean) =>
|
||||
cn(
|
||||
"size-8 shrink-0 rounded-sm",
|
||||
isDark
|
||||
isCustomTheme
|
||||
? "text-[var(--navigation-foreground)] hover:bg-white/20 hover:text-[var(--navigation-foreground)] active:bg-white/30"
|
||||
: isDark
|
||||
? "text-slate-400 hover:bg-slate-800/50 hover:text-white"
|
||||
: isPaleLightTheme
|
||||
? "text-[var(--foreground)] hover:bg-white/55 hover:text-[var(--foreground)] active:bg-white/75"
|
||||
@@ -48,9 +50,22 @@ type HeaderProps = {
|
||||
};
|
||||
|
||||
const Header = ({ collapsed }: HeaderProps) => {
|
||||
const { theme } = useTheme();
|
||||
const isDark = theme === "dark";
|
||||
const { theme, baseMode } = useTheme();
|
||||
const isDark = baseMode === "dark";
|
||||
const isCustomTheme = theme.startsWith("custom-theme-");
|
||||
const isPaleLightTheme = theme === "iceblue" || theme === "lightyellow";
|
||||
const headerTone = isCustomTheme
|
||||
? "banner-custom"
|
||||
: isDark
|
||||
? "banner-dark"
|
||||
: isPaleLightTheme
|
||||
? "content"
|
||||
: "banner-light";
|
||||
const headerTextClass = isCustomTheme
|
||||
? "text-[var(--navigation-foreground)]"
|
||||
: isPaleLightTheme
|
||||
? "text-[var(--foreground)]"
|
||||
: "text-white";
|
||||
const darkLogoPosition =
|
||||
readRuntimeEnv("VITE_DARK_LOGO_POSITION") === "left" ? "left" : "center";
|
||||
const isDarkLogoOnLeft = darkLogoPosition === "left";
|
||||
@@ -152,11 +167,11 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
// 右侧操作区(换肤/通知/用户)—— 深浅两套布局共用
|
||||
const actionCluster = (
|
||||
<>
|
||||
<CompactShortcutButtons tone={isDark ? "banner-dark" : isPaleLightTheme ? "content" : "banner-light"} />
|
||||
<ThemeSwitcher tone={isDark ? "banner-dark" : isPaleLightTheme ? "content" : "banner-light"} />
|
||||
<CompactShortcutButtons tone={headerTone} />
|
||||
<ThemeSwitcher tone={headerTone} />
|
||||
|
||||
<LayoutModeSwitcher
|
||||
tone={isDark ? "banner-dark" : isPaleLightTheme ? "content" : "banner-light"}
|
||||
tone={headerTone}
|
||||
fallback="full"
|
||||
/>
|
||||
|
||||
@@ -165,7 +180,7 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
onClick={() => setNotificationOpen(true)}
|
||||
className={cn(iconButtonClass(isDark, isPaleLightTheme), "relative")}
|
||||
className={cn(iconButtonClass(isDark, isPaleLightTheme, isCustomTheme), "relative")}
|
||||
title="通知"
|
||||
>
|
||||
<Bell className="size-4" />
|
||||
@@ -186,7 +201,13 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
<div
|
||||
className={cn(
|
||||
"mx-1 h-8 w-px",
|
||||
isDark ? "bg-blue-800/30" : isPaleLightTheme ? "bg-[var(--brand-900)]/25" : "bg-white/30",
|
||||
isCustomTheme
|
||||
? "bg-[var(--navigation-foreground)]/25"
|
||||
: isDark
|
||||
? "bg-blue-800/30"
|
||||
: isPaleLightTheme
|
||||
? "bg-[var(--brand-900)]/25"
|
||||
: "bg-white/30",
|
||||
)}
|
||||
aria-hidden
|
||||
/>
|
||||
@@ -196,7 +217,9 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"h-8 gap-2 rounded-sm px-2",
|
||||
isDark
|
||||
isCustomTheme
|
||||
? "text-[var(--navigation-foreground)] hover:bg-white/20 active:bg-white/30"
|
||||
: isDark
|
||||
? "text-slate-200 hover:bg-slate-800/50"
|
||||
: isPaleLightTheme
|
||||
? "text-[var(--foreground)] hover:bg-white/55 active:bg-white/75"
|
||||
@@ -206,7 +229,9 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
<div
|
||||
className={cn(
|
||||
"flex size-8 shrink-0 items-center justify-center rounded-sm",
|
||||
isDark
|
||||
isCustomTheme
|
||||
? "bg-white/25"
|
||||
: isDark
|
||||
? "bg-gradient-to-br from-blue-500 to-cyan-400"
|
||||
: "bg-white",
|
||||
)}
|
||||
@@ -214,16 +239,16 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
<User
|
||||
className={cn(
|
||||
"size-4",
|
||||
isDark ? "text-white" : "text-[var(--brand-900)]",
|
||||
isDark && !isCustomTheme ? "text-white" : "text-[var(--brand-900)]",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="hidden text-left sm:block">
|
||||
<p className={cn("text-sm leading-tight font-medium", isPaleLightTheme ? "text-[var(--foreground)]" : "text-white")}>
|
||||
<p className={cn("text-sm leading-tight font-medium", headerTextClass)}>
|
||||
{displayName}
|
||||
</p>
|
||||
{positionName && (
|
||||
<p className={cn("text-[11px] leading-tight", isPaleLightTheme ? "text-[var(--muted-foreground)]" : "text-white/70")}>
|
||||
<p className={cn("text-[11px] leading-tight", isCustomTheme ? "text-[var(--navigation-foreground)]/75" : isPaleLightTheme ? "text-[var(--muted-foreground)]" : "text-white/70")}>
|
||||
{positionName}
|
||||
</p>
|
||||
)}
|
||||
@@ -231,7 +256,7 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
<ChevronDown
|
||||
className={cn(
|
||||
"size-4 shrink-0",
|
||||
isDark ? "text-slate-500" : isPaleLightTheme ? "text-[var(--muted-foreground)]" : "text-white/80",
|
||||
isCustomTheme ? "text-[var(--navigation-foreground)]/80" : isDark ? "text-slate-500" : isPaleLightTheme ? "text-[var(--muted-foreground)]" : "text-white/80",
|
||||
)}
|
||||
/>
|
||||
</Button>
|
||||
@@ -323,7 +348,7 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
onError={handleBrandLogoError}
|
||||
/>
|
||||
</div>
|
||||
<span className={cn("whitespace-nowrap text-lg font-semibold", isPaleLightTheme ? "text-[var(--foreground)]" : "text-white")}>
|
||||
<span className={cn("whitespace-nowrap text-lg font-semibold", headerTextClass)}>
|
||||
{desensitizeText("CM业务中心")}
|
||||
</span>
|
||||
</div>
|
||||
@@ -342,7 +367,9 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg",
|
||||
isDark
|
||||
isCustomTheme
|
||||
? "bg-white/25"
|
||||
: isDark
|
||||
? "bg-gradient-to-br from-blue-500 to-cyan-400"
|
||||
: isPaleLightTheme
|
||||
? "bg-white/55"
|
||||
@@ -358,7 +385,7 @@ const Header = ({ collapsed }: HeaderProps) => {
|
||||
/>
|
||||
</div>
|
||||
{!collapsed && (
|
||||
<span className={cn("text-sm font-semibold", isPaleLightTheme ? "text-[var(--foreground)]" : "text-white")}>
|
||||
<span className={cn("text-sm font-semibold", headerTextClass)}>
|
||||
{desensitizeText("CM业务中心")}
|
||||
</span>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user