import { useTranslation } from "react-i18next" import { Label } from "@/components/ui/label" import type { SettingsDraft, DraftSetter } from "../settings-types" import { normalizeSidebarNavConfig, type SidebarNavItemId, } from "@/lib/sidebar-nav-preferences" interface Props { draft: SettingsDraft setDraft: DraftSetter } const UI_LANGUAGES = [ { value: "en", label: "English" }, { value: "zh", label: "中文" }, ] const FONT_SIZE_PRESETS = [ { label: "小", value: 0.9 }, { label: "默认", value: 1 }, { label: "大", value: 1.15 }, { label: "特大", value: 1.3 }, ] const SIDEBAR_NAV_LABEL_KEYS: Record = { wiki: "novel.nav.wiki", sources: "novel.nav.sources", graph: "novel.nav.graph", lint: "novel.nav.lint", soul: "novel.nav.soul", bookAnalysis: "novel.nav.dismantling", reviewCenter: "novel.nav.reviewCenter", storySimulation: "novel.nav.storySimulation", search: "novel.nav.search", trash: "nav.trash", } export function InterfaceSection({ draft, setDraft }: Props) { const { t } = useTranslation() const scalePercent = Math.round(draft.uiFontSizeScale * 100) const sidebarNavConfig = normalizeSidebarNavConfig(draft.sidebarNavConfig) const hiddenSidebarNavIds = new Set(sidebarNavConfig.hidden) const handleToggleSidebarNavItem = (id: SidebarNavItemId, visible: boolean) => { const hidden = visible ? sidebarNavConfig.hidden.filter((itemId) => itemId !== id) : [...sidebarNavConfig.hidden, id] setDraft("sidebarNavConfig", normalizeSidebarNavConfig({ ...sidebarNavConfig, hidden, })) } return (

{t("settings.sections.interface.title")}

{t("settings.sections.interface.description")}

{UI_LANGUAGES.map((l) => { const active = draft.uiLanguage === l.value return ( ) })}

{t("settings.sections.interface.uiLanguageHint")}

{t("settings.sections.interface.sidebarNavDescription")}

{sidebarNavConfig.order.map((id) => { const visible = !hiddenSidebarNavIds.has(id) return ( ) })}

{t("settings.sections.interface.sidebarNavOrderHint")}

{scalePercent}%
setDraft("uiFontSizeScale", Number(e.target.value) / 100)} className="w-full accent-primary" aria-label="界面字号" />
{FONT_SIZE_PRESETS.map((preset) => { const active = Math.abs(draft.uiFontSizeScale - preset.value) < 0.001 return ( ) })}

调整整个应用的字号,保存后立即生效。

) }