mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-03 17:06:36 +08:00
fix: theme persistence and update version to 2.1.9-beta9
This commit is contained in:
@@ -12,6 +12,12 @@ import React from "react";
|
||||
import "@/themes/loader";
|
||||
|
||||
import { ThemeProvider as ThemeContextProvider } from "@/themes/context";
|
||||
import { initThemeSystem } from "@/themes/registry";
|
||||
|
||||
// Restore saved theme SYNCHRONOUSLY at module load time — before first render.
|
||||
// This ensures the CSS tokens are injected before any component renders,
|
||||
// preventing a flash of the default theme.
|
||||
initThemeSystem();
|
||||
|
||||
interface ThemeProviderProps {
|
||||
children: React.ReactNode;
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
type AnnouncementData,
|
||||
} from "@/api";
|
||||
import { BackIcon, SettingsIcon } from "@/components/icons";
|
||||
import { ThemeSettings } from "@/components/theme-settings";
|
||||
import { isAdmin } from "@/utils/auth";
|
||||
import { getCachedConfigs, configCache, updateSiteConfig } from "@/config/site";
|
||||
import {
|
||||
@@ -979,6 +980,11 @@ export default function ConfigPage() {
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
{/* 主题设置 */}
|
||||
<div className="mt-6">
|
||||
<ThemeSettings />
|
||||
</div>
|
||||
|
||||
{hasChanges && (
|
||||
<Card className="mt-4 bg-warning-50 dark:bg-warning-900/20 border-warning-200 dark:border-warning-800 shadow-sm overflow-hidden">
|
||||
<div className="h-10 flex items-center justify-center gap-2 text-warning-700 dark:text-warning-300">
|
||||
|
||||
@@ -10,7 +10,6 @@ import { Switch } from "@/shadcn-bridge/heroui/switch";
|
||||
import { reinitializeBaseURL } from "@/api/network";
|
||||
import { getConfigByName, updateConfig } from "@/api";
|
||||
import { BackIcon } from "@/components/icons";
|
||||
import { ThemeSettings } from "@/components/theme-settings";
|
||||
import {
|
||||
type UpdateReleaseChannel,
|
||||
getUpdateReleaseChannel,
|
||||
@@ -182,7 +181,6 @@ export const SettingsPage = () => {
|
||||
{/* 内容区域 */}
|
||||
<div className="max-w-4xl mx-auto px-4 py-6">
|
||||
<div className="space-y-6">
|
||||
<ThemeSettings />
|
||||
<Card className="border border-gray-200 dark:border-gray-700">
|
||||
<CardBody className="p-6">
|
||||
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
|
||||
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
getSavedMode,
|
||||
saveMode,
|
||||
getEffectiveMode,
|
||||
initThemeSystem,
|
||||
registerTheme,
|
||||
unregisterTheme,
|
||||
type ThemeMode,
|
||||
@@ -95,11 +94,6 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
|
||||
// Re-render whenever register changes
|
||||
useSyncExternalStore(originalSubscribe, getSnapshot);
|
||||
|
||||
// Initialise on mount
|
||||
useEffect(() => {
|
||||
initThemeSystem();
|
||||
}, []);
|
||||
|
||||
// Listen for system mode changes
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
|
||||
Reference in New Issue
Block a user