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:
@@ -86,7 +86,10 @@ export interface UiAppearance {
|
||||
/** Corner radius in rem, 0…2. */
|
||||
radius: number;
|
||||
density: Density;
|
||||
/** Soften animations (transforms off, shorter durations). */
|
||||
reduceMotion: boolean;
|
||||
/** Hard-disable all UI animations (stronger than reduceMotion). */
|
||||
disableMotion: boolean;
|
||||
highContrast: boolean;
|
||||
sidebarDefaultCollapsed: boolean;
|
||||
timeFormat: TimeFormat;
|
||||
@@ -193,6 +196,7 @@ const DEFAULT_APPEARANCE: UiAppearance = {
|
||||
radius: 0.75,
|
||||
density: 'cozy',
|
||||
reduceMotion: false,
|
||||
disableMotion: false,
|
||||
highContrast: false,
|
||||
sidebarDefaultCollapsed: false,
|
||||
timeFormat: '24h',
|
||||
@@ -400,6 +404,7 @@ export function normalizeAppearance(value: unknown, imageState: ServerImageState
|
||||
radius: clampNum(v.radius, 0, 2, DEFAULT_APPEARANCE.radius),
|
||||
density: oneOf<Density>(v.density, ['cozy', 'compact'], DEFAULT_APPEARANCE.density),
|
||||
reduceMotion: boolOr(v.reduceMotion, DEFAULT_APPEARANCE.reduceMotion),
|
||||
disableMotion: boolOr(v.disableMotion, DEFAULT_APPEARANCE.disableMotion),
|
||||
highContrast: boolOr(v.highContrast, DEFAULT_APPEARANCE.highContrast),
|
||||
sidebarDefaultCollapsed: boolOr(v.sidebarDefaultCollapsed, DEFAULT_APPEARANCE.sidebarDefaultCollapsed),
|
||||
timeFormat: oneOf<TimeFormat>(v.timeFormat, ['12h', '24h'], DEFAULT_APPEARANCE.timeFormat),
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { ToggleSwitch } from '@/components/ui/toggle-switch';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import type { AdapterCommon } from './defaults';
|
||||
import type { AdapterStatus } from '@/types';
|
||||
|
||||
@@ -47,12 +48,13 @@ export function NodeSummaryCard<T extends AdapterCommon>({
|
||||
}: NodeSummaryCardProps<T>) {
|
||||
const enabled = item.enabled !== false;
|
||||
const blankName = !item.name?.trim();
|
||||
const off = useTheme().appearance.disableMotion;
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 4 }}
|
||||
initial={off ? false : { opacity: 0, y: 4 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.18 }}
|
||||
transition={off ? { duration: 0 } : { duration: 0.18 }}
|
||||
className={cn(
|
||||
'flex flex-col gap-2 rounded-xl border bg-card/40 p-3.5 transition-all hover:bg-accent/20 sm:flex-row sm:items-center sm:gap-3',
|
||||
!enabled && 'opacity-60',
|
||||
|
||||
@@ -31,7 +31,7 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
|
||||
// Framer's reducedMotion only suppresses transforms, so the always-present
|
||||
// width + page-transition animations need an explicit opt-out to make the
|
||||
// “减少动效” setting actually felt.
|
||||
const reduce = appearance.reduceMotion;
|
||||
const reduce = appearance.reduceMotion || appearance.disableMotion;
|
||||
const { editing } = useLayout();
|
||||
// Force the sidebar open while editing layout so its drag-to-reorder list
|
||||
// has room (it returns to the user's collapsed pref on 完成).
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
// ── Perlin noise (perlin2) — compact port of Joseph Gentle's noisejs (public domain) ──
|
||||
class Grad {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
constructor(x: number, y: number, z: number) { this.x = x; this.y = y; this.z = z; }
|
||||
dot2(x: number, y: number) { return this.x * x + this.y * y; }
|
||||
}
|
||||
|
||||
const GRAD3 = [
|
||||
new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0),
|
||||
new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1),
|
||||
new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1),
|
||||
];
|
||||
|
||||
const P = [
|
||||
151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99,
|
||||
37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32,
|
||||
57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
|
||||
77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54,
|
||||
65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86,
|
||||
164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212,
|
||||
207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70,
|
||||
221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104,
|
||||
218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,
|
||||
49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93,
|
||||
222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180,
|
||||
];
|
||||
|
||||
class Noise {
|
||||
private perm = new Array<number>(512);
|
||||
private gradP = new Array<Grad>(512);
|
||||
constructor(seed: number) { this.seed(seed); }
|
||||
|
||||
seed(seed: number) {
|
||||
if (seed > 0 && seed < 1) seed *= 65536;
|
||||
seed = Math.floor(seed);
|
||||
if (seed < 256) seed |= seed << 8;
|
||||
for (let i = 0; i < 256; i++) {
|
||||
const v = (i & 1) ? P[i] ^ (seed & 255) : P[i] ^ ((seed >> 8) & 255);
|
||||
this.perm[i] = this.perm[i + 256] = v;
|
||||
this.gradP[i] = this.gradP[i + 256] = GRAD3[v % 12];
|
||||
}
|
||||
}
|
||||
|
||||
private fade(t: number) { return t * t * t * (t * (t * 6 - 15) + 10); }
|
||||
private lerp(a: number, b: number, t: number) { return (1 - t) * a + t * b; }
|
||||
|
||||
perlin2(x: number, y: number) {
|
||||
let X = Math.floor(x), Y = Math.floor(y);
|
||||
x -= X; y -= Y;
|
||||
X &= 255; Y &= 255;
|
||||
const n00 = this.gradP[X + this.perm[Y]].dot2(x, y);
|
||||
const n01 = this.gradP[X + this.perm[Y + 1]].dot2(x, y - 1);
|
||||
const n10 = this.gradP[X + 1 + this.perm[Y]].dot2(x - 1, y);
|
||||
const n11 = this.gradP[X + 1 + this.perm[Y + 1]].dot2(x - 1, y - 1);
|
||||
const u = this.fade(x);
|
||||
return this.lerp(this.lerp(n00, n10, u), this.lerp(n01, n11, u), this.fade(y));
|
||||
}
|
||||
}
|
||||
|
||||
// ── Wavy-lines background (ported from the a-waves effect) ──
|
||||
interface Pt {
|
||||
x: number; y: number;
|
||||
wave: { x: number; y: number };
|
||||
cursor: { x: number; y: number; vx: number; vy: number };
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorative, mouse-reactive wavy-line field rendered as SVG paths and animated
|
||||
* via requestAnimationFrame. Purely presentational (aria-hidden, pointer-events
|
||||
* none) so it sits behind interactive content. Heavy on low-end devices — the
|
||||
* login page lets the user disable it (a device-local preference).
|
||||
*/
|
||||
export function LoginWaves() {
|
||||
const hostRef = useRef<HTMLDivElement>(null);
|
||||
const svgRef = useRef<SVGSVGElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const host = hostRef.current;
|
||||
const svg = svgRef.current;
|
||||
if (!host || !svg) return;
|
||||
|
||||
const noise = new Noise(Math.random());
|
||||
const mouse = { x: -10, y: 0, lx: 0, ly: 0, sx: 0, sy: 0, v: 0, vs: 0, a: 0, set: false };
|
||||
let bounding = host.getBoundingClientRect();
|
||||
let lines: Pt[][] = [];
|
||||
let paths: SVGPathElement[] = [];
|
||||
let raf = 0;
|
||||
|
||||
const setSize = () => {
|
||||
bounding = host.getBoundingClientRect();
|
||||
svg.style.width = `${bounding.width}px`;
|
||||
svg.style.height = `${bounding.height}px`;
|
||||
};
|
||||
|
||||
const setLines = () => {
|
||||
const { width, height } = bounding;
|
||||
lines = [];
|
||||
paths.forEach((p) => p.remove());
|
||||
paths = [];
|
||||
|
||||
const xGap = 10;
|
||||
const yGap = 32;
|
||||
const oWidth = width + 200;
|
||||
const oHeight = height + 30;
|
||||
const totalLines = Math.ceil(oWidth / xGap);
|
||||
const totalPoints = Math.ceil(oHeight / yGap);
|
||||
const xStart = (width - xGap * totalLines) / 2;
|
||||
const yStart = (height - yGap * totalPoints) / 2;
|
||||
|
||||
for (let i = 0; i <= totalLines; i++) {
|
||||
const points: Pt[] = [];
|
||||
for (let j = 0; j <= totalPoints; j++) {
|
||||
points.push({
|
||||
x: xStart + xGap * i,
|
||||
y: yStart + yGap * j,
|
||||
wave: { x: 0, y: 0 },
|
||||
cursor: { x: 0, y: 0, vx: 0, vy: 0 },
|
||||
});
|
||||
}
|
||||
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
||||
svg.appendChild(path);
|
||||
paths.push(path);
|
||||
lines.push(points);
|
||||
}
|
||||
};
|
||||
|
||||
const updateMouse = (x: number, y: number) => {
|
||||
// pageX/pageY are already document-relative, so don't re-add scrollY.
|
||||
mouse.x = x - bounding.left;
|
||||
mouse.y = y - bounding.top;
|
||||
if (!mouse.set) {
|
||||
mouse.sx = mouse.x; mouse.sy = mouse.y;
|
||||
mouse.lx = mouse.x; mouse.ly = mouse.y;
|
||||
mouse.set = true;
|
||||
}
|
||||
};
|
||||
const onMouseMove = (e: MouseEvent) => updateMouse(e.pageX, e.pageY);
|
||||
const onTouchMove = (e: TouchEvent) => {
|
||||
const t = e.touches[0];
|
||||
if (t) updateMouse(t.clientX, t.clientY);
|
||||
};
|
||||
const onResize = () => { setSize(); setLines(); };
|
||||
|
||||
const movePoints = (time: number) => {
|
||||
lines.forEach((points) => {
|
||||
points.forEach((p) => {
|
||||
const move = noise.perlin2((p.x + time * 0.0125) * 0.002, (p.y + time * 0.005) * 0.0015) * 12;
|
||||
p.wave.x = Math.cos(move) * 32;
|
||||
p.wave.y = Math.sin(move) * 16;
|
||||
|
||||
const dx = p.x - mouse.sx;
|
||||
const dy = p.y - mouse.sy;
|
||||
const d = Math.hypot(dx, dy);
|
||||
const l = Math.max(175, mouse.vs);
|
||||
if (d < l) {
|
||||
const s = 1 - d / l;
|
||||
const f = Math.cos(d * 0.001) * s;
|
||||
p.cursor.vx += Math.cos(mouse.a) * f * l * mouse.vs * 0.00065;
|
||||
p.cursor.vy += Math.sin(mouse.a) * f * l * mouse.vs * 0.00065;
|
||||
}
|
||||
p.cursor.vx += (0 - p.cursor.x) * 0.005;
|
||||
p.cursor.vy += (0 - p.cursor.y) * 0.005;
|
||||
p.cursor.vx *= 0.925;
|
||||
p.cursor.vy *= 0.925;
|
||||
p.cursor.x += p.cursor.vx * 2;
|
||||
p.cursor.y += p.cursor.vy * 2;
|
||||
p.cursor.x = Math.min(100, Math.max(-100, p.cursor.x));
|
||||
p.cursor.y = Math.min(100, Math.max(-100, p.cursor.y));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const moved = (point: Pt, withCursor: boolean) => ({
|
||||
x: Math.round((point.x + point.wave.x + (withCursor ? point.cursor.x : 0)) * 10) / 10,
|
||||
y: Math.round((point.y + point.wave.y + (withCursor ? point.cursor.y : 0)) * 10) / 10,
|
||||
});
|
||||
|
||||
const drawLines = () => {
|
||||
lines.forEach((points, lIndex) => {
|
||||
const first = moved(points[0], false);
|
||||
let d = `M ${first.x} ${first.y}`;
|
||||
points.forEach((p, pIndex) => {
|
||||
const isLast = pIndex === points.length - 1;
|
||||
const m = moved(p, !isLast);
|
||||
d += `L ${m.x} ${m.y}`;
|
||||
});
|
||||
paths[lIndex].setAttribute('d', d);
|
||||
});
|
||||
};
|
||||
|
||||
const tick = (time: number) => {
|
||||
mouse.sx += (mouse.x - mouse.sx) * 0.1;
|
||||
mouse.sy += (mouse.y - mouse.sy) * 0.1;
|
||||
const dx = mouse.x - mouse.lx;
|
||||
const dy = mouse.y - mouse.ly;
|
||||
const d = Math.hypot(dx, dy);
|
||||
mouse.v = d;
|
||||
mouse.vs += (d - mouse.vs) * 0.1;
|
||||
mouse.vs = Math.min(100, mouse.vs);
|
||||
mouse.lx = mouse.x; mouse.ly = mouse.y;
|
||||
mouse.a = Math.atan2(dy, dx);
|
||||
movePoints(time);
|
||||
drawLines();
|
||||
raf = requestAnimationFrame(tick);
|
||||
};
|
||||
|
||||
setSize();
|
||||
setLines();
|
||||
window.addEventListener('resize', onResize);
|
||||
window.addEventListener('mousemove', onMouseMove);
|
||||
window.addEventListener('touchmove', onTouchMove, { passive: true });
|
||||
raf = requestAnimationFrame(tick);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(raf);
|
||||
window.removeEventListener('resize', onResize);
|
||||
window.removeEventListener('mousemove', onMouseMove);
|
||||
window.removeEventListener('touchmove', onTouchMove);
|
||||
paths.forEach((p) => p.remove());
|
||||
paths = [];
|
||||
lines = [];
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div ref={hostRef} aria-hidden className="login-waves pointer-events-none absolute inset-0 overflow-hidden">
|
||||
<svg ref={svgRef} className="block size-full" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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="高对比模式" />
|
||||
|
||||
@@ -106,6 +106,7 @@ export const DEFAULT_APPEARANCE: UiAppearance = {
|
||||
radius: 0.75,
|
||||
density: 'cozy',
|
||||
reduceMotion: false,
|
||||
disableMotion: false,
|
||||
highContrast: false,
|
||||
sidebarDefaultCollapsed: false,
|
||||
timeFormat: '24h',
|
||||
@@ -304,7 +305,11 @@ function applyAppearance(a: UiAppearance, resolved: 'light' | 'dark'): void {
|
||||
root.setAttribute('data-palette', a.palette);
|
||||
root.setAttribute('data-sidebar-style', a.sidebarStyle);
|
||||
root.setAttribute('data-contrast', a.highContrast ? 'high' : 'normal');
|
||||
root.setAttribute('data-reduce-motion', a.reduceMotion ? '1' : '0');
|
||||
// 减弱动效 OR 关闭全部动效 both engage the reduce-motion CSS/Framer layer;
|
||||
// 关闭全部动效 additionally sets data-no-motion (kills CSS animations outright
|
||||
// and gates Framer entrance fades that reduce-motion leaves on).
|
||||
root.setAttribute('data-reduce-motion', (a.reduceMotion || a.disableMotion) ? '1' : '0');
|
||||
root.setAttribute('data-no-motion', a.disableMotion ? '1' : '0');
|
||||
|
||||
// Mode-independent vars go inline on :root.
|
||||
root.style.setProperty('--radius', `${a.radius}rem`);
|
||||
@@ -679,7 +684,7 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={value}>
|
||||
<MotionConfig reducedMotion={appearance.reduceMotion ? 'always' : 'user'}>
|
||||
<MotionConfig reducedMotion={(appearance.reduceMotion || appearance.disableMotion) ? 'always' : 'user'}>
|
||||
{children}
|
||||
</MotionConfig>
|
||||
</ThemeContext.Provider>
|
||||
|
||||
@@ -216,6 +216,17 @@ html[data-reduce-motion="1"] *::after {
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
|
||||
/* 关闭全部动效: harder than reduce — remove CSS animations outright (e.g. the
|
||||
pulsing status dots) rather than just collapsing their duration. Framer
|
||||
entrance fades are gated in components on `disableMotion`. */
|
||||
html[data-no-motion="1"] *:not(.animate-spin),
|
||||
html[data-no-motion="1"] *::before,
|
||||
html[data-no-motion="1"] *::after {
|
||||
/* Exclude .animate-spin: loading spinners encode "busy", not decoration —
|
||||
freezing them reads as a hang. Everything else (e.g. pulse dots) stops. */
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Native scrollbars — themed to match. Radix ScrollArea hides its own
|
||||
native bar and renders a custom thumb, so this only styles plain overflow
|
||||
@@ -238,6 +249,19 @@ html {
|
||||
}
|
||||
::-webkit-scrollbar-corner { background: transparent; }
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Login background — wavy SVG line field (see <LoginWaves>). Themed to the
|
||||
accent so it reads as a subtle decorative backdrop behind the login card.
|
||||
────────────────────────────────────────────── */
|
||||
.login-waves {
|
||||
color: color-mix(in oklab, var(--primary) 26%, transparent);
|
||||
}
|
||||
.login-waves path {
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1px;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────
|
||||
Custom range slider (via the <Slider> component, class `.slider`).
|
||||
The component sets `--slider-pct` for the WebKit filled track; Firefox
|
||||
|
||||
@@ -202,6 +202,7 @@ export interface UiAppearance {
|
||||
radius: number;
|
||||
density: Density;
|
||||
reduceMotion: boolean;
|
||||
disableMotion: boolean;
|
||||
highContrast: boolean;
|
||||
sidebarDefaultCollapsed: boolean;
|
||||
timeFormat: TimeFormat;
|
||||
|
||||
Reference in New Issue
Block a user