mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 09:11:38 +00:00
Update into the dark mode
This commit is contained in:
@ -27,6 +27,27 @@ const About: NextPageWithLayout = () => {
|
|||||||
}, 300);
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// After model loading, set theme to dark mode.
|
||||||
|
const restore = useRef(false);
|
||||||
|
const { systemTheme, theme, setTheme } = useTheme();
|
||||||
|
const currentTheme = theme === 'system' ? systemTheme : theme;
|
||||||
|
const setDarkMode = () => {
|
||||||
|
if (!showLoading) return;
|
||||||
|
if (currentTheme === 'dark') return;
|
||||||
|
document.body.style.transition = 'all 1.2s ease-out';
|
||||||
|
setTheme('dark');
|
||||||
|
restore.current = true;
|
||||||
|
};
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
if (!restore.current) return;
|
||||||
|
setTheme('light');
|
||||||
|
document.body.style.transition = 'all 0.3s ease-out';
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
const init: InitFn = ({
|
const init: InitFn = ({
|
||||||
scene,
|
scene,
|
||||||
controls,
|
controls,
|
||||||
@ -97,6 +118,7 @@ const About: NextPageWithLayout = () => {
|
|||||||
.easing(TWEEN.Easing.Circular.Out);
|
.easing(TWEEN.Easing.Circular.Out);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
enter.start();
|
enter.start();
|
||||||
|
setDarkMode();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// Render animation
|
// Render animation
|
||||||
@ -131,28 +153,6 @@ const About: NextPageWithLayout = () => {
|
|||||||
alpha: true,
|
alpha: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// After model loading, set theme to dark mode.
|
|
||||||
const restore = useRef(false);
|
|
||||||
const { systemTheme, theme, setTheme } = useTheme();
|
|
||||||
const currentTheme = theme === 'system' ? systemTheme : theme;
|
|
||||||
useEffect(() => {
|
|
||||||
if (!loading) return;
|
|
||||||
if (currentTheme === 'dark') return;
|
|
||||||
setTimeout(() => {
|
|
||||||
setTheme('dark');
|
|
||||||
restore.current = true;
|
|
||||||
}, 1300);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [currentTheme, loading]);
|
|
||||||
useEffect(
|
|
||||||
() => () => {
|
|
||||||
if (!restore.current) return;
|
|
||||||
setTheme('light');
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="fixed top-0 left-0 -z-10">
|
<div className="fixed top-0 left-0 -z-10">
|
||||||
|
Reference in New Issue
Block a user