diff --git a/stash-web/index.html b/stash-web/index.html index 0210b7f..49b8e73 100644 --- a/stash-web/index.html +++ b/stash-web/index.html @@ -4,7 +4,15 @@ - + + { - document.documentElement.dataset.scheme = effectiveTheme - }, [effectiveTheme]) - /** 当前实际是深色吗(auto 时按系统偏好算) */ const isDark = isDarkScheme(effectiveTheme) + const scheme = isDark ? 'dark' : 'light' + + useEffect(() => { + const root = document.documentElement + if (root.dataset.scheme === scheme) return + root.classList.add('theme-transition') + root.dataset.scheme = scheme + const timer = window.setTimeout(() => root.classList.remove('theme-transition'), 260) + return () => { + window.clearTimeout(timer) + root.classList.remove('theme-transition') + } + }, [scheme]) /** 页头的明暗切换:只写本机偏好,不需要登录;站点默认值在后台改 */ const toggleTheme = () => { @@ -663,6 +671,7 @@ export default function AppNext() { headerSpeed={site.header.speed} headerGap={site.header.gap} site={site.site} + ready={settings !== null} authenticated={session?.authenticated === true} username={session?.username ?? undefined} refreshing={refreshing} @@ -707,7 +716,7 @@ export default function AppNext() { onOpenApi={() => navigate('/interface')} /> )} - {settings !== null && site.sidebar.show_nav !== false && ( + {settings !== null && !loading && site.sidebar.show_nav !== false && (
- {headerEnabled && ( + {ready && headerEnabled && ( {headerItems.map((item, index) => ( @@ -94,34 +97,42 @@ export function SiteHeader({
- {site.actions.theme && ( - } - onClick={onToggleTheme} - /> + {ready && ( + <> + {site.actions.theme && ( + } + onClick={onToggleTheme} + /> + )} + {site.actions.refresh && ( + } + spinning={refreshing} + onClick={onRefresh} + /> + )} + {site.actions.settings && authenticated && ( + } + onClick={onSettings} + /> + )} + {site.actions.session && + (authenticated ? ( + } + onClick={onLogout} + /> + ) : ( + } onClick={onLogin} /> + ))} + )} - {site.actions.refresh && ( - } - spinning={refreshing} - onClick={onRefresh} - /> - )} - {site.actions.settings && authenticated && ( - } onClick={onSettings} /> - )} - {site.actions.session && - (authenticated ? ( - } - onClick={onLogout} - /> - ) : ( - } onClick={onLogin} /> - ))}
) diff --git a/stash-web/src/index.css b/stash-web/src/index.css index de2cc67..ef8fa43 100644 --- a/stash-web/src/index.css +++ b/stash-web/src/index.css @@ -11,6 +11,10 @@ -moz-osx-font-smoothing: grayscale; } +html[data-scheme='dark'] { + color-scheme: dark; +} + * { box-sizing: border-box; margin: 0;