feat(webui): animated login background + three independent motion settings
Login page now has a mouse-reactive wavy-line background (ported a-waves + embedded Perlin noise, themed to the accent, rendered behind the card which sits on a 95%-opaque blurred surface so content stays readable). A "我觉得这个 界面很卡怎么办?" link opens a dialog that toggles it off — a device-local preference (localStorage, works pre-auth, defaults off when the OS prefers reduced motion), independent of the system motion settings. Motion settings are now three: - 关闭登录页的动效 — the login background toggle above (device-local). - 减弱动效 (reduceMotion) — soft: transforms/springs off, durations collapsed, page/sidebar instant; gentle entrance fades remain. - 关闭全部动效 (disableMotion, NEW appearance field) — everything reduce does plus data-no-motion CSS (kills pulse dots; spinners excluded so "busy" stays legible) and the entrance opacity fades gated off across overview/processes/logs/config lists.
This commit is contained in:
12 files changed
+363
-33
No files matched your search
@@ -1,10 +1,13 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import { ArrowRight, Eye, EyeOff, KeyRound } from 'lucide-react';
|
||||
import { ArrowRight, Eye, EyeOff, KeyRound, Sparkles } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { ToggleSwitch } from '@/components/ui/toggle-switch';
|
||||
import { ThemeToggle } from '@/components/theme-toggle';
|
||||
import { LoginWaves } from '@/components/login-waves';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { APP_NAME, APP_VERSION } from '@/types';
|
||||
@@ -13,6 +16,22 @@ interface LoginPageProps {
|
||||
onLogin: (password: string) => Promise<{ success: boolean; error?: string }>;
|
||||
}
|
||||
|
||||
// Device-local preference for the (heavy) animated login background. Kept out
|
||||
// of the server-synced appearance on purpose: it's a "this device feels laggy"
|
||||
// choice, and it must work pre-auth (where settings can't persist to the
|
||||
// server). Independent of the system 减弱动效 / 关闭全部动效 settings.
|
||||
const LOGIN_FX_KEY = 'snowluma_login_fx';
|
||||
function readLoginFx(): boolean {
|
||||
try {
|
||||
const v = localStorage.getItem(LOGIN_FX_KEY);
|
||||
if (v === '0') return false;
|
||||
if (v === '1') return true;
|
||||
} catch { /* ignore */ }
|
||||
// No explicit choice yet → on by default, unless the OS asks for reduced
|
||||
// motion (an accessibility default; still fully overridable via the toggle).
|
||||
try { return !window.matchMedia('(prefers-reduced-motion: reduce)').matches; } catch { return true; }
|
||||
}
|
||||
|
||||
export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
const { appearance } = useTheme();
|
||||
const customBg = appearance.background.type !== 'none';
|
||||
@@ -27,6 +46,13 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [shake, setShake] = useState(0);
|
||||
const [fxOn, setFxOn] = useState(readLoginFx);
|
||||
const [helpOpen, setHelpOpen] = useState(false);
|
||||
|
||||
const toggleFx = (v: boolean) => {
|
||||
setFxOn(v);
|
||||
try { localStorage.setItem(LOGIN_FX_KEY, v ? '1' : '0'); } catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -42,7 +68,10 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
|
||||
return (
|
||||
<div className={cn('relative flex min-h-screen items-center justify-center overflow-hidden px-4 py-8', customBg ? 'bg-transparent' : 'bg-background')}>
|
||||
{/* Sky gradient backdrop */}
|
||||
{/* Animated wavy-line background (device-local toggle) */}
|
||||
{fxOn && <LoginWaves />}
|
||||
|
||||
{/* Sky gradient backdrop — also softens the waves so the card stands out */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0"
|
||||
style={{
|
||||
@@ -50,20 +79,8 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
'radial-gradient(80% 60% at 50% 0%, color-mix(in oklab, var(--primary) 18%, transparent) 0%, transparent 70%)',
|
||||
}}
|
||||
/>
|
||||
<motion.div
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute -left-24 top-24 size-72 rounded-full bg-primary/15 blur-3xl"
|
||||
animate={{ scale: [1, 1.08, 1] }}
|
||||
transition={{ duration: 8, repeat: Infinity, ease: 'easeInOut' }}
|
||||
/>
|
||||
<motion.div
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute -right-16 bottom-10 size-80 rounded-full bg-primary/10 blur-3xl"
|
||||
animate={{ scale: [1, 1.12, 1] }}
|
||||
transition={{ duration: 10, repeat: Infinity, ease: 'easeInOut', delay: 0.6 }}
|
||||
/>
|
||||
|
||||
<div className="absolute right-4 top-4">
|
||||
<div className="absolute right-4 top-4 z-20">
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
|
||||
@@ -73,7 +90,7 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
transition={{ duration: 0.45, ease: [0.16, 1, 0.3, 1] }}
|
||||
className="relative z-10 w-full max-w-md"
|
||||
>
|
||||
<Card className="border-primary/15 shadow-xl">
|
||||
<Card className="border-primary/15 shadow-xl backdrop-blur-sm supports-[backdrop-filter]:bg-card/95">
|
||||
<CardContent className="p-7 sm:p-9">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex size-12 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/20">
|
||||
@@ -139,7 +156,42 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Perf escape hatch for the animated background */}
|
||||
<div className="mt-4 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setHelpOpen(true)}
|
||||
className="inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40"
|
||||
>
|
||||
<Sparkles className="size-3.5" />
|
||||
我觉得这个界面很卡怎么办?
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
<Dialog open={helpOpen} onOpenChange={setHelpOpen}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>界面有点卡顿?</DialogTitle>
|
||||
<DialogDescription>
|
||||
登录页背景是一个跟随鼠标的动态线条效果,在部分设备上可能比较吃性能。可以在这里关掉它——该开关仅作用于本设备的登录页,与系统的动效设置相互独立。
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex items-center justify-between gap-4 rounded-lg border bg-muted/20 px-4 py-3">
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium">登录页动态背景</p>
|
||||
<p className="mt-0.5 text-[11px] text-muted-foreground">{fxOn ? '已开启 · 关闭后背景为静态' : '已关闭 · 背景为静态'}</p>
|
||||
</div>
|
||||
<ToggleSwitch value={fxOn} onChange={toggleFx} ariaLabel="登录页动态背景" />
|
||||
</div>
|
||||
|
||||
<p className="text-[11px] leading-relaxed text-muted-foreground">
|
||||
登录后,你还可以在「系统设置 → 无障碍」里进一步「减弱动效」或「关闭全部动效」。
|
||||
</p>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ function ToolButton({ label, onClick, children, active, danger, disabled }: Tool
|
||||
|
||||
export function LogsPage() {
|
||||
const api = useApi();
|
||||
const { formatClock } = useTheme();
|
||||
const { formatClock, appearance } = useTheme();
|
||||
const { pages, setPages } = useLayout();
|
||||
const prefs = pages.logs;
|
||||
|
||||
@@ -434,9 +434,9 @@ export function LogsPage() {
|
||||
return (
|
||||
<motion.div
|
||||
key={log.id}
|
||||
initial={{ opacity: 0 }}
|
||||
initial={appearance.disableMotion ? false : { opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
transition={{ duration: 0.12 }}
|
||||
transition={appearance.disableMotion ? { duration: 0 } : { duration: 0.12 }}
|
||||
className="flex flex-col gap-0.5 px-3 py-1.5 transition-colors hover:bg-accent/40 sm:flex-row sm:items-start sm:gap-3 sm:py-1"
|
||||
style={hl ? { boxShadow: `inset 3px 0 0 ${hl}`, backgroundColor: `color-mix(in oklab, ${hl} 8%, transparent)` } : undefined}
|
||||
>
|
||||
|
||||
@@ -46,6 +46,7 @@ function renderWidget(block: UiLayoutItem): ReactNode {
|
||||
export function OverviewPage() {
|
||||
const { qqList, processList } = useAppState();
|
||||
const { overviewBlocks, setOverviewBlocks, resetLayout, editing: editingCtx, setEditing } = useLayout();
|
||||
const off = useTheme().appearance.disableMotion;
|
||||
const isWide = useMediaQuery('(min-width: 768px)');
|
||||
// Free-grid editing is desktop-only (no room to drag/resize on a phone).
|
||||
const editing = isWide && editingCtx;
|
||||
@@ -100,7 +101,7 @@ export function OverviewPage() {
|
||||
|
||||
{/* First-run nudge — always shown (not a grid widget) so it can't be hidden. */}
|
||||
{qqList.length === 0 && (
|
||||
<motion.div initial={{ opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }}>
|
||||
<motion.div initial={off ? false : { opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }}>
|
||||
<Link
|
||||
to="/processes"
|
||||
className="flex items-center gap-3 rounded-xl border border-primary/30 bg-primary/5 px-4 py-3 transition-colors hover:bg-primary/10"
|
||||
@@ -367,6 +368,7 @@ function HostBlock() {
|
||||
|
||||
function SessionsBlock({ config }: { config: SessionsConfig }) {
|
||||
const { qqList } = useAppState();
|
||||
const off = useTheme().appearance.disableMotion;
|
||||
const list = useMemo(() => {
|
||||
const f = config.filter.trim().toLowerCase();
|
||||
let arr = f
|
||||
@@ -398,10 +400,10 @@ function SessionsBlock({ config }: { config: SessionsConfig }) {
|
||||
{list.map((q, idx) => (
|
||||
<motion.div
|
||||
key={q.uin}
|
||||
initial={{ opacity: 0, y: 6 }}
|
||||
initial={off ? false : { opacity: 0, y: 6 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.03 + idx * 0.04, duration: 0.22 }}
|
||||
whileHover={{ y: -2 }}
|
||||
transition={off ? { duration: 0 } : { delay: 0.03 + idx * 0.04, duration: 0.22 }}
|
||||
whileHover={off ? undefined : { y: -2 }}
|
||||
className="flex items-center gap-3 rounded-lg border bg-card/40 p-3"
|
||||
>
|
||||
<Avatar size={40}>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { cn } from '@/lib/utils';
|
||||
import type { HookProcessInfo } from '@/types';
|
||||
import { useAppState } from '@/contexts/AppStateContext';
|
||||
import { useLayout } from '@/contexts/LayoutContext';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
|
||||
const SORT_OPTIONS: { id: string; label: string }[] = [
|
||||
{ id: 'pid', label: 'PID' },
|
||||
@@ -50,6 +51,7 @@ export function ProcessesPage() {
|
||||
const { processList, processOps, refreshProcesses } = useAppState();
|
||||
const { statusOf, banner: processActionStatus, load, unload, refresh } = processOps;
|
||||
const { pages, setPages } = useLayout();
|
||||
const off = useTheme().appearance.disableMotion;
|
||||
const [confirm, setConfirm] = useState<{ kind: 'load' | 'unload'; pid: number; name: string } | null>(null);
|
||||
const [probeDialog, setProbeDialog] = useState<{ pid: number; name: string } | null>(null);
|
||||
|
||||
@@ -101,7 +103,7 @@ export function ProcessesPage() {
|
||||
<CardContent>
|
||||
{processActionStatus && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: -4 }}
|
||||
initial={off ? false : { opacity: 0, y: -4 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="mb-3 flex items-center gap-2 rounded-lg border border-primary/20 bg-primary/[0.06] px-3 py-2 text-xs text-primary"
|
||||
>
|
||||
@@ -131,9 +133,9 @@ export function ProcessesPage() {
|
||||
return (
|
||||
<motion.div
|
||||
key={proc.pid}
|
||||
initial={{ opacity: 0, y: 6 }}
|
||||
initial={off ? false : { opacity: 0, y: 6 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.03 + idx * 0.025, duration: 0.22 }}
|
||||
transition={off ? { duration: 0 } : { delay: 0.03 + idx * 0.025, duration: 0.22 }}
|
||||
className="flex flex-col gap-3 rounded-xl border bg-card/50 p-3.5 transition-colors hover:bg-accent/20 sm:flex-row sm:items-center"
|
||||
>
|
||||
{/* icon + info stay horizontal; on phones the actions drop to
|
||||
|
||||
@@ -380,8 +380,11 @@ function AppearancePanel() {
|
||||
</Group>
|
||||
|
||||
<Group title="无障碍与侧栏" icon={Accessibility} description="动效、对比度与侧栏默认状态。">
|
||||
<SettingRow label="减少动效" hint="关闭页面切换、弹簧等装饰性动画,对低端设备与晕动敏感者更友好。" layout="inline">
|
||||
<ToggleSwitch value={a.reduceMotion} onChange={(reduceMotion) => setAppearance({ reduceMotion })} ariaLabel="减少动效" />
|
||||
<SettingRow label="减弱动效" hint="弱化页面切换、弹簧等装饰性动画(保留轻微淡入),对低端设备与晕动敏感者更友好。" layout="inline">
|
||||
<ToggleSwitch value={a.reduceMotion} onChange={(reduceMotion) => setAppearance({ reduceMotion })} ariaLabel="减弱动效" />
|
||||
</SettingRow>
|
||||
<SettingRow label="关闭全部动效" hint="比“减弱动效”更彻底:移除所有界面动画,包括入场淡入与状态点闪烁。" layout="inline">
|
||||
<ToggleSwitch value={a.disableMotion} onChange={(disableMotion) => setAppearance({ disableMotion })} ariaLabel="关闭全部动效" />
|
||||
</SettingRow>
|
||||
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
||||
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
||||
|
||||
Reference in new issue
Block a user