mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-09-05 23:30:31 +08:00
feat: ui optiminize
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
import { useEffect } from "react";
|
||||
import { useLayoutEffect } from "react";
|
||||
import { Theme, useAppConfig } from "@/app/store/config";
|
||||
|
||||
const DARK_CLASS = "dark-new";
|
||||
const LIGHT_CLASS = "light-new";
|
||||
|
||||
export function useSwitchTheme() {
|
||||
const config = useAppConfig();
|
||||
|
||||
useEffect(() => {
|
||||
document.body.classList.remove("dark");
|
||||
useLayoutEffect(() => {
|
||||
document.body.classList.remove(DARK_CLASS);
|
||||
document.body.classList.remove(LIGHT_CLASS);
|
||||
|
||||
if (config.theme === Theme.Dark) {
|
||||
document.body.classList.add("dark");
|
||||
document.body.classList.add(DARK_CLASS);
|
||||
} else {
|
||||
document.body.classList.add(LIGHT_CLASS);
|
||||
}
|
||||
}, [config.theme]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user