fix: apply admin theme/language toggle to homepage hero section as well
This commit is contained in:
parent
09d6a7305e
commit
c44cebeb18
|
|
@ -22,6 +22,7 @@ import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Copy, Check, Code, Terminal, FileCode, Box, Grid3X3, Play, Trophy, PieChart, BookOpen, Search, Sun, Moon, Monitor, Languages } from 'lucide-react';
|
import { Copy, Check, Code, Terminal, FileCode, Box, Grid3X3, Play, Trophy, PieChart, BookOpen, Search, Sun, Moon, Monitor, Languages } from 'lucide-react';
|
||||||
import { UserContext } from '../../context/User';
|
import { UserContext } from '../../context/User';
|
||||||
|
import { StatusContext } from '../../context/Status';
|
||||||
import { stringToColor } from '../../helpers';
|
import { stringToColor } from '../../helpers';
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -143,8 +144,13 @@ function HomeLanguageSelector() {
|
||||||
function HeroSection() {
|
function HeroSection() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [userState] = useContext(UserContext);
|
const [userState] = useContext(UserContext);
|
||||||
|
const [statusState] = useContext(StatusContext);
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
// 读取管理员开关:默认 true(未加载 status 前也显示)
|
||||||
|
const showThemeToggle = statusState?.status?.HeaderShowThemeToggle !== false;
|
||||||
|
const showLanguageSelector = statusState?.status?.HeaderShowLanguageSelector !== false;
|
||||||
const copyCmd = useCallback(() => {
|
const copyCmd = useCallback(() => {
|
||||||
navigator.clipboard.writeText("https://tokendance.space");
|
navigator.clipboard.writeText("https://tokendance.space");
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
|
|
@ -172,8 +178,8 @@ function HeroSection() {
|
||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<HomeThemeToggle />
|
{showThemeToggle && <HomeThemeToggle />}
|
||||||
<HomeLanguageSelector />
|
{showLanguageSelector && <HomeLanguageSelector />}
|
||||||
{userState.user ? (
|
{userState.user ? (
|
||||||
<Link to="/console" className="inline-flex items-center gap-2 bg-white/10 text-white px-3 py-1.5 text-sm rounded-full hover:bg-white/20 border border-white/20 transition-colors duration-200 ml-2">
|
<Link to="/console" className="inline-flex items-center gap-2 bg-white/10 text-white px-3 py-1.5 text-sm rounded-full hover:bg-white/20 border border-white/20 transition-colors duration-200 ml-2">
|
||||||
<span className="w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white flex-shrink-0" style={{ backgroundColor: stringToColor(userState.user.username) }}>
|
<span className="w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white flex-shrink-0" style={{ backgroundColor: stringToColor(userState.user.username) }}>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue