Migrate project to pnpm monorepo
Restructure the repository into a pnpm workspace under packages/ (core, webui, runtime). Move source files for core and webui into packages/*, add package manifests for @snowluma/core and @snowluma/runtime, and remove the old launcher package.json. Update root package.json to be a monorepo controller (scripts delegate to pnpm filters, set packageManager and Node engine). Configure build outputs to emit into the repo-root dist/ (vite config changes) so the existing release pipeline continues to work. Add .npmrc with mirrors, expand .gitignore for monorepo layout, add tsconfig base and package-level tsconfigs, and add vitest config for the core package. Adjust injector native search paths and update tests import paths to the new package layout. Small CI/workflow comment added to clarify build behavior and README updated with monorepo structure and common commands.
This commit is contained in:
1 parent
6bba36bba6
commit
39f1672b29
122 files changed
+279
-85
No files matched your search
@@ -0,0 +1,251 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { Activity, LayoutDashboard, Settings, Sparkles, Terminal } from 'lucide-react';
|
||||
import { Sidebar } from './Sidebar';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
|
||||
type Page = '总览' | '配置' | '日志';
|
||||
|
||||
interface MainLayoutProps {
|
||||
activePage: Page;
|
||||
onNavigate: (page: Page) => void;
|
||||
status: string;
|
||||
onLogout: () => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const pageMeta: Record<Page, { title: string; subtitle: string; badge: string; icon: typeof LayoutDashboard }> = {
|
||||
'总览': { title: '总览', subtitle: '查看当前接入的 QQ 账号及服务运行状态', badge: '控制台视图', icon: LayoutDashboard },
|
||||
'配置': { title: '节点配置', subtitle: '管理 OneBot 协议端点与通信参数', badge: '协议编排', icon: Settings },
|
||||
'日志': { title: '日志', subtitle: '查看后端运行日志与实时事件流', badge: 'SSE 实时流', icon: Terminal },
|
||||
};
|
||||
|
||||
export function MainLayout({ activePage, onNavigate, status, onLogout, children }: MainLayoutProps) {
|
||||
const meta = pageMeta[activePage];
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
const PageIcon = meta.icon;
|
||||
const runtimeLabel = status === '已连接' ? '运行中' : status;
|
||||
|
||||
return (
|
||||
<div className="h-screen w-screen flex overflow-hidden font-(--font-sans)" style={{ background: 'var(--bg-body)' }}>
|
||||
{/* Full-screen ambient gradient — matches login page */}
|
||||
<div
|
||||
className="pointer-events-none fixed inset-0"
|
||||
style={{
|
||||
background: dark
|
||||
? 'linear-gradient(135deg, rgba(8,11,18,1) 0%, rgba(10,16,27,1) 42%, rgba(7,10,17,1) 100%)'
|
||||
: 'linear-gradient(135deg, #f8fbff 0%, #eef6ff 45%, #f9fafc 100%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Animated orbs */}
|
||||
<div className="pointer-events-none fixed inset-0 overflow-hidden">
|
||||
<motion.div
|
||||
className="absolute -left-24 -top-24 h-[60vh] w-[60vh] rounded-full"
|
||||
style={{
|
||||
background: dark
|
||||
? 'radial-gradient(circle, rgba(56,189,248,0.12) 0%, transparent 68%)'
|
||||
: 'radial-gradient(circle, rgba(56,189,248,0.18) 0%, transparent 70%)',
|
||||
filter: 'blur(42px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.08, 1] }}
|
||||
transition={{ duration: 10, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
<motion.div
|
||||
className="absolute -right-16 -bottom-32 h-[50vh] w-[50vh] rounded-full"
|
||||
style={{
|
||||
background: dark
|
||||
? 'radial-gradient(circle, rgba(129,140,248,0.10) 0%, transparent 68%)'
|
||||
: 'radial-gradient(circle, rgba(129,140,248,0.14) 0%, transparent 70%)',
|
||||
filter: 'blur(52px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.12, 1] }}
|
||||
transition={{ duration: 12, ease: 'easeInOut', repeat: Infinity, delay: 0.8 }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sidebar */}
|
||||
<Sidebar activePage={activePage} onNavigate={onNavigate} status={status} onLogout={onLogout} />
|
||||
|
||||
{/* Main content */}
|
||||
<div className="flex-1 flex flex-col min-h-0 p-3 pl-0 z-10 relative">
|
||||
<main
|
||||
className="flex-1 overflow-y-auto rounded-2xl relative"
|
||||
style={{
|
||||
background: dark
|
||||
? 'linear-gradient(135deg, rgba(8,13,22,0.72), rgba(14,20,32,0.82))'
|
||||
: 'linear-gradient(135deg, rgba(255,255,255,0.68), rgba(255,255,255,0.85))',
|
||||
border: '1px solid var(--glass-border)',
|
||||
backdropFilter: 'blur(38px) saturate(1.35)',
|
||||
WebkitBackdropFilter: 'blur(38px) saturate(1.35)',
|
||||
boxShadow: dark
|
||||
? '0 24px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.05)'
|
||||
: '0 20px 60px rgba(15,23,42,0.08), inset 0 1px 0 rgba(255,255,255,0.7)',
|
||||
}}
|
||||
>
|
||||
{/* Top highlight */}
|
||||
<div className="absolute inset-x-0 top-0 h-px bg-linear-to-r from-transparent via-white/8 to-transparent rounded-t-2xl" />
|
||||
|
||||
{/* Grid texture overlay */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-2xl"
|
||||
style={{
|
||||
backgroundImage: dark
|
||||
? 'linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)'
|
||||
: 'linear-gradient(90deg, rgba(15,23,42,0.03) 1px, transparent 1px), linear-gradient(rgba(15,23,42,0.03) 1px, transparent 1px)',
|
||||
backgroundSize: '36px 36px',
|
||||
maskImage: 'linear-gradient(180deg, rgba(0,0,0,0.35), transparent 60%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Accent glow in corner */}
|
||||
<motion.div
|
||||
className="pointer-events-none absolute right-[12%] top-[8%] h-32 w-32 rounded-full"
|
||||
style={{
|
||||
background: 'radial-gradient(circle, rgba(56,189,248,0.18), transparent 68%)',
|
||||
filter: 'blur(20px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.15, 1], opacity: [0.6, 1, 0.6] }}
|
||||
transition={{ duration: 6, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
|
||||
<div className="relative w-full min-h-full px-4 py-4 sm:px-6 sm:py-6 xl:px-8 2xl:px-10 flex flex-col">
|
||||
{/* Page header */}
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.header
|
||||
key={meta.title + '_header'}
|
||||
initial={{ opacity: 0, y: -10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 8 }}
|
||||
transition={{ duration: 0.25 }}
|
||||
className="mb-6"
|
||||
>
|
||||
<div
|
||||
className="relative overflow-hidden rounded-[1.75rem] border px-4 py-4 sm:px-5 sm:py-5 xl:px-6"
|
||||
style={{
|
||||
background: dark
|
||||
? 'linear-gradient(135deg, rgba(8,12,20,0.48), rgba(14,20,32,0.62))'
|
||||
: 'linear-gradient(135deg, rgba(255,255,255,0.5), rgba(255,255,255,0.72))',
|
||||
borderColor: 'var(--glass-border)',
|
||||
boxShadow: dark
|
||||
? '0 18px 48px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.04)'
|
||||
: '0 14px 40px rgba(15,23,42,0.05), inset 0 1px 0 rgba(255,255,255,0.5)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0"
|
||||
style={{
|
||||
backgroundImage: dark
|
||||
? 'linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px)'
|
||||
: 'linear-gradient(90deg, rgba(15,23,42,0.03) 1px, transparent 1px), linear-gradient(rgba(15,23,42,0.03) 1px, transparent 1px)',
|
||||
backgroundSize: '34px 34px',
|
||||
maskImage: 'linear-gradient(90deg, rgba(0,0,0,0.45), transparent 85%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
<motion.div
|
||||
className="pointer-events-none absolute -right-8 -top-10 h-28 w-28 rounded-full"
|
||||
style={{
|
||||
background: 'radial-gradient(circle, rgba(56,189,248,0.16), transparent 68%)',
|
||||
filter: 'blur(18px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.12, 1], opacity: [0.45, 0.78, 0.45] }}
|
||||
transition={{ duration: 6, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
|
||||
<div className="relative flex items-center justify-between gap-6">
|
||||
<div className="flex min-w-0 items-center gap-4">
|
||||
{/* Icon */}
|
||||
<div
|
||||
className="relative flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border"
|
||||
style={{
|
||||
borderColor: 'color-mix(in srgb, var(--accent) 26%, transparent)',
|
||||
background: dark
|
||||
? 'linear-gradient(135deg, rgba(56,189,248,0.16), rgba(129,140,248,0.14))'
|
||||
: 'linear-gradient(135deg, rgba(56,189,248,0.16), rgba(129,140,248,0.12))',
|
||||
boxShadow: '0 8px 22px color-mix(in srgb, var(--accent) 16%, transparent)',
|
||||
}}
|
||||
>
|
||||
<PageIcon size={20} strokeWidth={2.2} style={{ color: 'var(--accent)' }} />
|
||||
</div>
|
||||
|
||||
{/* Title block */}
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2.5 flex-wrap">
|
||||
<h1 className="text-xl font-bold tracking-[-0.03em]" style={{ color: 'var(--text-primary)' }}>
|
||||
{meta.title}
|
||||
</h1>
|
||||
<span
|
||||
className="inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||||
style={{
|
||||
color: 'var(--accent)',
|
||||
background: 'var(--accent-subtle)',
|
||||
border: '1px solid color-mix(in srgb, var(--accent) 22%, transparent)',
|
||||
}}
|
||||
>
|
||||
<Sparkles size={10} className="mr-1" />
|
||||
{meta.badge}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-0.5 text-sm" style={{ color: 'var(--text-secondary)' }}>
|
||||
{meta.subtitle}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<motion.div
|
||||
whileHover={{ y: -1.5 }}
|
||||
className="hidden sm:flex shrink-0 overflow-hidden rounded-2xl border px-4 py-3 items-center gap-3"
|
||||
style={{
|
||||
borderColor: dark ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.82)',
|
||||
background: dark ? 'rgba(255,255,255,0.03)' : 'rgba(255,255,255,0.52)',
|
||||
backdropFilter: 'blur(18px)',
|
||||
WebkitBackdropFilter: 'blur(18px)',
|
||||
}}
|
||||
>
|
||||
<Activity size={14} style={{ color: 'var(--accent)', flexShrink: 0 }} />
|
||||
<div>
|
||||
<div className="text-[11px] font-semibold uppercase tracking-widest mb-0.5" style={{ color: 'var(--text-tertiary)' }}>运行状态</div>
|
||||
<div className="text-sm font-semibold" style={{ color: 'var(--accent)' }}>{runtimeLabel}</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.header>
|
||||
</AnimatePresence>
|
||||
|
||||
{/* Page content */}
|
||||
<div className="flex-1 flex flex-col">
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key={activePage}
|
||||
initial={{ opacity: 0, y: 12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -12 }}
|
||||
transition={{ duration: 0.25, ease: [0.16, 1, 0.3, 1] }}
|
||||
className="flex-1"
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
|
||||
<motion.footer
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.3, delay: 0.08 }}
|
||||
className="mt-8 flex items-center justify-center border-t pt-5 text-[11px] tracking-wide"
|
||||
style={{
|
||||
color: 'var(--text-tertiary)',
|
||||
borderColor: 'var(--border-subtle)',
|
||||
}}
|
||||
>
|
||||
© {new Date().getFullYear()} SnowLuma. All rights reserved.
|
||||
</motion.footer>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
import { LayoutDashboard, Settings, LogOut, Sun, Moon, Monitor, Terminal } from 'lucide-react';
|
||||
import { Avatar } from '@heroui/react';
|
||||
import { StatusBadge } from '../ui/StatusBadge';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useTheme, type ThemeMode } from '../../contexts/ThemeContext';
|
||||
|
||||
type Page = '总览' | '配置' | '日志';
|
||||
|
||||
interface SidebarProps {
|
||||
activePage: Page;
|
||||
onNavigate: (page: Page) => void;
|
||||
status: string;
|
||||
onLogout: () => void;
|
||||
}
|
||||
|
||||
const navItems: { page: Page; label: string; icon: typeof LayoutDashboard }[] = [
|
||||
{ page: '总览', label: '总览', icon: LayoutDashboard },
|
||||
{ page: '配置', label: '配置', icon: Settings },
|
||||
{ page: '日志', label: '日志', icon: Terminal },
|
||||
];
|
||||
|
||||
const THEME_OPTIONS: { mode: ThemeMode; icon: typeof Sun; label: string }[] = [
|
||||
{ mode: 'system', icon: Monitor, label: '跟随系统' },
|
||||
{ mode: 'light', icon: Sun, label: '浅色' },
|
||||
{ mode: 'dark', icon: Moon, label: '深色' },
|
||||
];
|
||||
|
||||
export function Sidebar({ activePage, onNavigate, status, onLogout }: SidebarProps) {
|
||||
const { resolved, mode, setMode } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
|
||||
return (
|
||||
<aside
|
||||
className="w-55 shrink-0 flex flex-col z-40 m-3 rounded-2xl overflow-hidden relative"
|
||||
style={{
|
||||
background: dark
|
||||
? 'linear-gradient(135deg, rgba(8,13,22,0.78), rgba(14,20,32,0.88))'
|
||||
: 'linear-gradient(135deg, rgba(255,255,255,0.72), rgba(255,255,255,0.9))',
|
||||
border: '1px solid var(--glass-border)',
|
||||
backdropFilter: 'blur(38px) saturate(1.35)',
|
||||
WebkitBackdropFilter: 'blur(38px) saturate(1.35)',
|
||||
boxShadow: dark
|
||||
? '0 24px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.05)'
|
||||
: '0 20px 60px rgba(15,23,42,0.08), inset 0 1px 0 rgba(255,255,255,0.7)',
|
||||
}}
|
||||
>
|
||||
{/* Top highlight */}
|
||||
<div className="absolute inset-x-0 top-0 h-px bg-linear-to-r from-transparent via-white/8 to-transparent" />
|
||||
|
||||
{/* Grid texture overlay */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0"
|
||||
style={{
|
||||
backgroundImage: dark
|
||||
? 'linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)'
|
||||
: 'linear-gradient(90deg, rgba(15,23,42,0.03) 1px, transparent 1px), linear-gradient(rgba(15,23,42,0.03) 1px, transparent 1px)',
|
||||
backgroundSize: '36px 36px',
|
||||
maskImage: 'linear-gradient(180deg, rgba(0,0,0,0.3), transparent 70%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Accent glow at top-left */}
|
||||
<motion.div
|
||||
className="pointer-events-none absolute -left-6 -top-6 h-24 w-24 rounded-full"
|
||||
style={{
|
||||
background: 'radial-gradient(circle, rgba(56,189,248,0.2), transparent 68%)',
|
||||
filter: 'blur(14px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.15, 1], opacity: [0.5, 0.8, 0.5] }}
|
||||
transition={{ duration: 7, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
|
||||
{/* Logo */}
|
||||
<div className="relative h-16 px-5 flex items-center gap-2" style={{ borderBottom: '1px solid var(--border-subtle)' }}>
|
||||
<div className="relative shrink-0">
|
||||
<div
|
||||
className="absolute -inset-1.5 rounded-full blur-lg"
|
||||
style={{ background: 'linear-gradient(135deg, rgba(56,189,248,0.2), rgba(129,140,248,0.18))' }}
|
||||
/>
|
||||
<div
|
||||
className="relative rounded-full border p-0.5"
|
||||
style={{
|
||||
borderColor: 'var(--glass-border)',
|
||||
background: dark ? 'rgba(8,12,19,0.7)' : 'rgba(255,255,255,0.8)',
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
className="rounded-full"
|
||||
style={{ width: 32, height: 32, borderRadius: '50%', overflow: 'hidden', flexShrink: 0 }}
|
||||
>
|
||||
<Avatar.Image src="/logo.png" alt="SnowLuma" className="object-cover" />
|
||||
<Avatar.Fallback>SL</Avatar.Fallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</div>
|
||||
<span className="text-sm font-bold tracking-tight" style={{ color: 'var(--text-primary)' }}>
|
||||
SnowLuma
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex-1 px-3 pt-4 flex flex-col gap-1.5">
|
||||
{navItems.map(({ page, label, icon: Icon }) => {
|
||||
const isActive = activePage === page;
|
||||
return (
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
key={page}
|
||||
onClick={() => onNavigate(page)}
|
||||
className="flex items-center gap-2.5 h-9 px-3 rounded-xl text-sm font-medium cursor-pointer relative overflow-hidden"
|
||||
style={{
|
||||
color: isActive ? 'var(--accent)' : 'var(--text-secondary)',
|
||||
background: isActive ? 'var(--accent-subtle)' : 'transparent',
|
||||
transition: 'var(--transition-fast)',
|
||||
}}
|
||||
onMouseEnter={e => { if (!isActive) (e.currentTarget.style.background = 'var(--bg-hover)'); }}
|
||||
onMouseLeave={e => { if (!isActive) (e.currentTarget.style.background = 'transparent'); }}
|
||||
>
|
||||
{isActive && (
|
||||
<motion.div
|
||||
layoutId="sidebarActive"
|
||||
className="absolute inset-0 rounded-xl"
|
||||
style={{
|
||||
background: 'var(--accent-subtle)',
|
||||
border: '1px solid color-mix(in srgb, var(--accent) 24%, transparent)',
|
||||
boxShadow: 'inset 0 1px 0 rgba(255,255,255,0.06)',
|
||||
}}
|
||||
initial={false}
|
||||
transition={{ type: 'spring', stiffness: 400, damping: 30 }}
|
||||
/>
|
||||
)}
|
||||
<Icon
|
||||
size={16}
|
||||
strokeWidth={isActive ? 2.2 : 1.8}
|
||||
className="relative z-10 shrink-0"
|
||||
style={{ color: isActive ? 'var(--accent)' : undefined }}
|
||||
/>
|
||||
<span className="relative z-10">{label}</span>
|
||||
</motion.button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Bottom */}
|
||||
<div className="relative p-3 flex flex-col gap-2" style={{ borderTop: '1px solid var(--border-subtle)' }}>
|
||||
<div className="flex items-center justify-between px-1">
|
||||
<StatusBadge status={status} />
|
||||
<div className="flex items-center gap-0.5">
|
||||
{THEME_OPTIONS.map(({ mode: m, icon: Icon, label }) => {
|
||||
const active = mode === m;
|
||||
return (
|
||||
<button
|
||||
key={m}
|
||||
title={label}
|
||||
onClick={() => setMode(m)}
|
||||
className="relative flex size-7 cursor-pointer items-center justify-center rounded-lg transition-colors duration-200"
|
||||
style={{ color: active ? 'var(--accent)' : 'var(--text-tertiary)' }}
|
||||
>
|
||||
{active && (
|
||||
<motion.div
|
||||
layoutId="sidebar-theme-pill"
|
||||
className="absolute inset-0 rounded-lg"
|
||||
style={{ background: 'var(--accent-subtle)' }}
|
||||
transition={{ type: 'spring', stiffness: 400, damping: 30 }}
|
||||
/>
|
||||
)}
|
||||
<Icon size={13} className="relative z-10" />
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
onClick={onLogout}
|
||||
className="flex items-center justify-center gap-2 h-8 rounded-lg text-xs font-medium cursor-pointer"
|
||||
style={{
|
||||
color: 'var(--text-tertiary)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
transition: 'var(--transition-fast)',
|
||||
}}
|
||||
onMouseEnter={e => { e.currentTarget.style.color = 'var(--color-danger)'; e.currentTarget.style.borderColor = 'rgba(248,113,113,0.2)'; e.currentTarget.style.background = 'rgba(248,113,113,0.06)'; }}
|
||||
onMouseLeave={e => { e.currentTarget.style.color = 'var(--text-tertiary)'; e.currentTarget.style.borderColor = 'var(--border-subtle)'; e.currentTarget.style.background = 'transparent'; }}
|
||||
>
|
||||
<LogOut size={13} strokeWidth={2} />
|
||||
登出
|
||||
</motion.button>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
|
||||
interface TopBarProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
}
|
||||
|
||||
export function TopBar({ title, subtitle }: TopBarProps) {
|
||||
const { resolved, mode, setMode } = useTheme();
|
||||
const cycleTheme = () => setMode(mode === 'system' ? 'light' : mode === 'light' ? 'dark' : 'system');
|
||||
|
||||
return (
|
||||
<header className="h-14 shrink-0 flex items-center justify-between px-6 border-b border-zinc-200/60 dark:border-white/6 bg-white/60 dark:bg-zinc-900/60 backdrop-blur-xl">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-zinc-900 dark:text-zinc-100 tracking-tight">{title}</h1>
|
||||
{subtitle && <p className="text-xs text-zinc-400 dark:text-zinc-500 mt-0.5">{subtitle}</p>}
|
||||
</div>
|
||||
<button
|
||||
onClick={cycleTheme}
|
||||
className="size-8 flex items-center justify-center rounded-lg text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-200 hover:bg-zinc-100 dark:hover:bg-white/8 transition-all duration-150 cursor-pointer"
|
||||
>
|
||||
{resolved === 'light' ? <Moon size={16} /> : <Sun size={16} />}
|
||||
</button>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import { MousePointerClick } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { SectionCard } from '../ui/SectionCard';
|
||||
import { EndpointRow } from '../ui/EndpointRow';
|
||||
import { FieldInput } from '../ui/FieldInput';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
import type { QQInfo, OneBotConfig } from '../../types';
|
||||
|
||||
interface ConfigPageProps {
|
||||
qqList: QQInfo[];
|
||||
selectedUin: string | null;
|
||||
config: OneBotConfig | null;
|
||||
saveStatus: string;
|
||||
onSelectAccount: (uin: string) => void;
|
||||
onSave: () => void;
|
||||
onConfigChange: (config: OneBotConfig) => void;
|
||||
}
|
||||
|
||||
function qqAvatarUrl(uin: string): string {
|
||||
return `/avatar/${encodeURIComponent(uin)}`;
|
||||
}
|
||||
|
||||
export function ConfigPage({
|
||||
qqList, selectedUin, config, saveStatus,
|
||||
onSelectAccount, onSave, onConfigChange,
|
||||
}: ConfigPageProps) {
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 xl:flex-row xl:items-start">
|
||||
{/* Account list panel */}
|
||||
<div className="w-full shrink-0 xl:sticky xl:top-0 xl:w-60 2xl:w-64">
|
||||
<div
|
||||
className="rounded-xl overflow-hidden"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.06)'
|
||||
: '0 8px 24px rgba(15,23,42,0.04), inset 0 1px 1px rgba(255,255,255,0.5)',
|
||||
}}
|
||||
>
|
||||
<div className="px-4 pt-4 pb-2">
|
||||
<span className="text-[11px] font-semibold uppercase tracking-widest" style={{ color: 'var(--text-secondary)' }}>
|
||||
在线连接
|
||||
</span>
|
||||
</div>
|
||||
<div className="px-2 pb-3 flex flex-col gap-0.5 sm:grid sm:grid-cols-2 sm:gap-1.5 xl:flex">
|
||||
{qqList.length === 0 ? (
|
||||
<p className="text-xs text-center py-6" style={{ color: 'var(--text-tertiary)' }}>暂无在线会话</p>
|
||||
) : qqList.map(q => {
|
||||
const isActive = selectedUin === q.uin;
|
||||
return (
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
key={q.uin}
|
||||
onClick={() => onSelectAccount(q.uin)}
|
||||
className="w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-left cursor-pointer"
|
||||
style={{
|
||||
background: isActive ? 'var(--accent-subtle)' : 'transparent',
|
||||
transition: 'var(--transition-fast)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="size-7 rounded-md flex items-center justify-center text-white text-[11px] font-bold shrink-0 overflow-hidden"
|
||||
style={{
|
||||
background: isActive
|
||||
? 'linear-gradient(135deg, var(--accent), #818cf8)'
|
||||
: 'var(--bg-input)',
|
||||
color: isActive ? '#fff' : 'var(--text-secondary)',
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={qqAvatarUrl(q.uin)}
|
||||
alt={q.nickname || q.uin}
|
||||
className="size-full object-cover"
|
||||
referrerPolicy="no-referrer"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div
|
||||
className="text-sm font-medium truncate"
|
||||
style={{ color: isActive ? 'var(--accent)' : 'var(--text-primary)' }}
|
||||
>
|
||||
{q.nickname}
|
||||
</div>
|
||||
<div
|
||||
className="text-[11px] truncate"
|
||||
style={{ color: 'var(--text-tertiary)', fontFamily: 'var(--font-mono)', fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
{q.uin}
|
||||
</div>
|
||||
</div>
|
||||
</motion.button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Editor panel */}
|
||||
<div className="flex-1 min-w-0">
|
||||
{!selectedUin ? (
|
||||
<div className="flex flex-col items-center justify-center h-64 gap-3">
|
||||
<MousePointerClick size={28} strokeWidth={1.2} style={{ color: 'var(--text-tertiary)', opacity: 0.5 }} />
|
||||
<p className="text-sm" style={{ color: 'var(--text-secondary)' }}>在左栏选择会话以配置通信节点</p>
|
||||
</div>
|
||||
) : !config ? (
|
||||
<div className="space-y-4 animate-pulse">
|
||||
<div className="h-8 rounded-lg w-48" style={{ background: 'var(--bg-card)' }} />
|
||||
<div className="h-32 rounded-xl" style={{ background: 'var(--bg-card)' }} />
|
||||
<div className="h-32 rounded-xl" style={{ background: 'var(--bg-card)' }} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<h2 className="text-base font-semibold tracking-tight" style={{ color: 'var(--text-primary)' }}>
|
||||
OneBot 协议端点
|
||||
</h2>
|
||||
<code
|
||||
className="text-xs mt-1 block"
|
||||
style={{ color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)', fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
UIN {selectedUin}
|
||||
</code>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5">
|
||||
{saveStatus && (
|
||||
<span
|
||||
className="text-xs font-medium px-2.5 py-1 rounded-full"
|
||||
style={{
|
||||
color: saveStatus === '保存成功' ? 'var(--color-success)' : saveStatus === '保存中...' ? 'var(--text-secondary)' : 'var(--color-danger)',
|
||||
background: saveStatus === '保存成功' ? 'rgba(52,211,153,0.1)' : saveStatus === '保存中...' ? 'var(--bg-card)' : 'rgba(248,113,113,0.1)',
|
||||
border: `1px solid ${saveStatus === '保存成功' ? 'rgba(52,211,153,0.2)' : saveStatus === '保存中...' ? 'var(--border-subtle)' : 'rgba(248,113,113,0.2)'}`,
|
||||
}}
|
||||
>
|
||||
{saveStatus}
|
||||
</span>
|
||||
)}
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.02 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
onClick={onSave}
|
||||
className="h-8 px-4 rounded-lg text-white text-xs font-medium cursor-pointer"
|
||||
style={{
|
||||
background: 'linear-gradient(135deg, var(--accent), #818cf8)',
|
||||
boxShadow: '0 2px 12px var(--accent-glow)',
|
||||
transition: 'var(--transition-fast)',
|
||||
}}
|
||||
>
|
||||
保存设定
|
||||
</motion.button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* HTTP Servers */}
|
||||
<SectionCard title="HTTP 服务监听" onAdd={() => { const c = { ...config }; c.httpServers = [...c.httpServers, { port: 3000, host: '0.0.0.0', path: '/' }]; onConfigChange(c); }}>
|
||||
{config.httpServers.length === 0 ? null : config.httpServers.map((s, idx) => (
|
||||
<EndpointRow key={idx} onRemove={() => { const c = { ...config }; c.httpServers = c.httpServers.filter((_, i) => i !== idx); onConfigChange(c); }}>
|
||||
<FieldInput label="端口" value={s.port} isNum flex="w-28" onChange={v => { const c = { ...config }; c.httpServers = c.httpServers.map((item, i) => i === idx ? { ...item, port: v as number } : item); onConfigChange(c); }} />
|
||||
<FieldInput label="授权 Token" placeholder="不填则无密码" value={s.accessToken || ''} onChange={v => { const c = { ...config }; c.httpServers = c.httpServers.map((item, i) => i === idx ? { ...item, accessToken: v as string } : item); onConfigChange(c); }} />
|
||||
</EndpointRow>
|
||||
))}
|
||||
</SectionCard>
|
||||
|
||||
{/* HTTP Post */}
|
||||
<SectionCard title="HTTP Post 推送端点" onAdd={() => { const c = { ...config }; c.httpPostEndpoints = [...c.httpPostEndpoints, { url: 'http://127.0.0.1:5700' }]; onConfigChange(c); }}>
|
||||
{config.httpPostEndpoints.length === 0 ? null : config.httpPostEndpoints.map((s, idx) => (
|
||||
<EndpointRow key={idx} onRemove={() => { const c = { ...config }; c.httpPostEndpoints = c.httpPostEndpoints.filter((_, i) => i !== idx); onConfigChange(c); }}>
|
||||
<FieldInput label="目标 URL" placeholder="http://..." grow value={s.url || ''} onChange={v => { const c = { ...config }; c.httpPostEndpoints = c.httpPostEndpoints.map((item, i) => i === idx ? { ...item, url: v as string } : item); onConfigChange(c); }} />
|
||||
<FieldInput label="授权 Token" placeholder="可选" value={s.accessToken || ''} onChange={v => { const c = { ...config }; c.httpPostEndpoints = c.httpPostEndpoints.map((item, i) => i === idx ? { ...item, accessToken: v as string } : item); onConfigChange(c); }} />
|
||||
</EndpointRow>
|
||||
))}
|
||||
</SectionCard>
|
||||
|
||||
{/* WS Servers */}
|
||||
<SectionCard title="WebSocket 服务监听" onAdd={() => { const c = { ...config }; c.wsServers = [...c.wsServers, { port: 3001, host: '0.0.0.0', path: '/' }]; onConfigChange(c); }}>
|
||||
{config.wsServers.length === 0 ? null : config.wsServers.map((s, idx) => (
|
||||
<EndpointRow key={idx} onRemove={() => { const c = { ...config }; c.wsServers = c.wsServers.filter((_, i) => i !== idx); onConfigChange(c); }}>
|
||||
<FieldInput label="端口" value={s.port} isNum flex="w-28" onChange={v => { const c = { ...config }; c.wsServers = c.wsServers.map((item, i) => i === idx ? { ...item, port: v as number } : item); onConfigChange(c); }} />
|
||||
<FieldInput label="授权 Token" placeholder="不填则无密码" value={s.accessToken || ''} onChange={v => { const c = { ...config }; c.wsServers = c.wsServers.map((item, i) => i === idx ? { ...item, accessToken: v as string } : item); onConfigChange(c); }} />
|
||||
</EndpointRow>
|
||||
))}
|
||||
</SectionCard>
|
||||
|
||||
{/* WS Clients */}
|
||||
<SectionCard title="WebSocket 客户端(反向连出)" onAdd={() => { const c = { ...config }; c.wsClients = [...c.wsClients, { url: 'ws://127.0.0.1:8080/ws', reconnectIntervalMs: 5000 }]; onConfigChange(c); }}>
|
||||
{config.wsClients.length === 0 ? null : config.wsClients.map((c2, idx) => (
|
||||
<EndpointRow key={idx} onRemove={() => { const c = { ...config }; c.wsClients = c.wsClients.filter((_, i) => i !== idx); onConfigChange(c); }}>
|
||||
<FieldInput label="目标 URL" placeholder="ws://..." grow value={c2.url || ''} onChange={v => { const c = { ...config }; c.wsClients = c.wsClients.map((item, i) => i === idx ? { ...item, url: v as string } : item); onConfigChange(c); }} />
|
||||
<FieldInput label="授权 Token" placeholder="可选" value={c2.accessToken || ''} onChange={v => { const c = { ...config }; c.wsClients = c.wsClients.map((item, i) => i === idx ? { ...item, accessToken: v as string } : item); onConfigChange(c); }} />
|
||||
</EndpointRow>
|
||||
))}
|
||||
</SectionCard>
|
||||
|
||||
{/* Music Sign URL */}
|
||||
<SectionCard title="音乐签名 URL" onAdd={() => {}}>
|
||||
<div className="px-5 py-4">
|
||||
<FieldInput label="签名服务地址" placeholder="留空则不启用" value={config.musicSignUrl || ''} onChange={v => onConfigChange({ ...config, musicSignUrl: (v as string) || undefined })} />
|
||||
</div>
|
||||
</SectionCard>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,473 @@
|
||||
import { useState, useMemo, useRef, useCallback } from 'react';
|
||||
import { Avatar } from '@heroui/react';
|
||||
import { Sun, Moon, Monitor, Eye, EyeOff, ArrowRight, KeyRound } from 'lucide-react';
|
||||
import { motion, AnimatePresence, useMotionValue, useSpring, useTransform } from 'framer-motion';
|
||||
import { useTheme, type ThemeMode } from '../../contexts/ThemeContext';
|
||||
|
||||
interface LoginPageProps {
|
||||
onLogin: (password: string) => Promise<{ success: boolean; error?: string }>;
|
||||
}
|
||||
|
||||
const THEME_OPTIONS: { mode: ThemeMode; icon: typeof Sun; label: string }[] = [
|
||||
{ mode: 'system', icon: Monitor, label: '跟随系统' },
|
||||
{ mode: 'light', icon: Sun, label: '浅色' },
|
||||
{ mode: 'dark', icon: Moon, label: '深色' },
|
||||
];
|
||||
|
||||
const SPARKLES = Array.from({ length: 12 }, (_, i) => ({
|
||||
id: i,
|
||||
x: (i * 31 + 9) % 100,
|
||||
y: (i * 47 + 13) % 100,
|
||||
size: 2 + (i % 2),
|
||||
delay: (i * 0.35) % 4,
|
||||
duration: 3.5 + (i % 3),
|
||||
}));
|
||||
|
||||
const BRAND_TAGS = ['OneBot v11', '多账号', '实时面板'];
|
||||
|
||||
export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
const [password, setPassword] = useState('');
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [shakeKey, setShakeKey] = useState(0);
|
||||
const { mode, resolved, setMode } = useTheme();
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const logoSrc = useMemo(() => '/logo.png', []);
|
||||
|
||||
const mouseX = useMotionValue(0);
|
||||
const mouseY = useMotionValue(0);
|
||||
const smoothX = useSpring(mouseX, { stiffness: 60, damping: 20 });
|
||||
const smoothY = useSpring(mouseY, { stiffness: 60, damping: 20 });
|
||||
|
||||
const shellRotateX = useTransform(smoothY, [-0.5, 0.5], [4, -4]);
|
||||
const shellRotateY = useTransform(smoothX, [-0.5, 0.5], [-5, 5]);
|
||||
|
||||
const orb1X = useTransform(smoothX, [-0.5, 0.5], [-45, 45]);
|
||||
const orb1Y = useTransform(smoothY, [-0.5, 0.5], [-28, 28]);
|
||||
const orb2X = useTransform(smoothX, [-0.5, 0.5], [35, -35]);
|
||||
const orb2Y = useTransform(smoothY, [-0.5, 0.5], [30, -30]);
|
||||
const accentX = useTransform(smoothX, [-0.5, 0.5], [-16, 16]);
|
||||
const accentY = useTransform(smoothY, [-0.5, 0.5], [-12, 12]);
|
||||
|
||||
const handleMouseMove = useCallback((e: React.MouseEvent) => {
|
||||
const rect = containerRef.current?.getBoundingClientRect();
|
||||
if (!rect) return;
|
||||
mouseX.set((e.clientX - rect.left) / rect.width - 0.5);
|
||||
mouseY.set((e.clientY - rect.top) / rect.height - 0.5);
|
||||
}, [mouseX, mouseY]);
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
mouseX.set(0);
|
||||
mouseY.set(0);
|
||||
}, [mouseX, mouseY]);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
setLoading(true);
|
||||
const result = await onLogin(password);
|
||||
setLoading(false);
|
||||
if (!result.success && result.error) {
|
||||
setError(result.error);
|
||||
setShakeKey(k => k + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const darkMode = resolved === 'dark';
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="relative min-h-screen overflow-hidden"
|
||||
style={{ background: 'var(--bg-body)' }}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
>
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0"
|
||||
style={{
|
||||
background: darkMode
|
||||
? 'linear-gradient(135deg, rgba(8,11,18,1) 0%, rgba(10,16,27,1) 42%, rgba(7,10,17,1) 100%)'
|
||||
: 'linear-gradient(135deg, #f8fbff 0%, #eef6ff 45%, #f9fafc 100%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="pointer-events-none absolute inset-0 overflow-hidden">
|
||||
{SPARKLES.map(s => (
|
||||
<motion.div
|
||||
key={s.id}
|
||||
className="absolute rounded-full"
|
||||
style={{
|
||||
width: s.size,
|
||||
height: s.size,
|
||||
left: `${s.x}%`,
|
||||
top: `${s.y}%`,
|
||||
background: darkMode
|
||||
? `rgba(${s.id % 2 === 0 ? '56,189,248' : '129,140,248'},0.38)`
|
||||
: `rgba(${s.id % 2 === 0 ? '14,165,233' : '99,102,241'},0.26)`,
|
||||
}}
|
||||
animate={{ y: [0, -16, 0], opacity: [0.18, 0.55, 0.18], scale: [1, 1.25, 1] }}
|
||||
transition={{ duration: s.duration, delay: s.delay, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
))}
|
||||
|
||||
<motion.div
|
||||
className="absolute -left-24 -top-24 h-120 w-120 rounded-full"
|
||||
style={{
|
||||
x: orb1X,
|
||||
y: orb1Y,
|
||||
background: darkMode
|
||||
? 'radial-gradient(circle, rgba(56,189,248,0.16) 0%, transparent 68%)'
|
||||
: 'radial-gradient(circle, rgba(56,189,248,0.22) 0%, transparent 70%)',
|
||||
filter: 'blur(42px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.08, 1] }}
|
||||
transition={{ duration: 10, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
<motion.div
|
||||
className="absolute -right-16 -bottom-32 h-112 w-md rounded-full"
|
||||
style={{
|
||||
x: orb2X,
|
||||
y: orb2Y,
|
||||
background: darkMode
|
||||
? 'radial-gradient(circle, rgba(129,140,248,0.14) 0%, transparent 68%)'
|
||||
: 'radial-gradient(circle, rgba(129,140,248,0.16) 0%, transparent 70%)',
|
||||
filter: 'blur(52px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.12, 1] }}
|
||||
transition={{ duration: 12, ease: 'easeInOut', repeat: Infinity, delay: 0.8 }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="relative z-10 flex min-h-screen items-center justify-center px-5 py-10 sm:px-8 lg:px-12">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 24, scale: 0.97 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={{ duration: 0.55, ease: [0.16, 1, 0.3, 1] }}
|
||||
style={{ rotateX: shellRotateX, rotateY: shellRotateY, transformPerspective: 1200 }}
|
||||
className="relative w-full max-w-6xl"
|
||||
>
|
||||
<div
|
||||
className="absolute -inset-5 -z-10 rounded-4xl blur-3xl"
|
||||
style={{ background: 'linear-gradient(135deg, rgba(56,189,248,0.12), rgba(129,140,248,0.14), rgba(34,211,238,0.08))' }}
|
||||
/>
|
||||
|
||||
<div
|
||||
className="relative overflow-hidden rounded-4xl border"
|
||||
style={{
|
||||
background: darkMode
|
||||
? 'linear-gradient(135deg, rgba(8,13,22,0.78), rgba(14,20,32,0.88))'
|
||||
: 'linear-gradient(135deg, rgba(255,255,255,0.72), rgba(255,255,255,0.9))',
|
||||
borderColor: 'var(--glass-border)',
|
||||
backdropFilter: 'blur(38px) saturate(1.35)',
|
||||
WebkitBackdropFilter: 'blur(38px) saturate(1.35)',
|
||||
boxShadow: darkMode
|
||||
? '0 38px 120px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05)'
|
||||
: '0 32px 90px rgba(15,23,42,0.12), inset 0 1px 0 rgba(255,255,255,0.7)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="absolute inset-0"
|
||||
style={{
|
||||
backgroundImage: darkMode
|
||||
? 'linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px)'
|
||||
: 'linear-gradient(90deg, rgba(15,23,42,0.04) 1px, transparent 1px), linear-gradient(rgba(15,23,42,0.04) 1px, transparent 1px)',
|
||||
backgroundSize: '36px 36px',
|
||||
maskImage: 'linear-gradient(180deg, rgba(0,0,0,0.45), transparent 82%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
<motion.div
|
||||
className="pointer-events-none absolute right-[18%] top-[14%] h-28 w-28 rounded-full"
|
||||
style={{
|
||||
x: accentX,
|
||||
y: accentY,
|
||||
background: 'radial-gradient(circle, rgba(56,189,248,0.28), transparent 68%)',
|
||||
filter: 'blur(18px)',
|
||||
}}
|
||||
animate={{ scale: [1, 1.12, 1] }}
|
||||
transition={{ duration: 6, ease: 'easeInOut', repeat: Infinity }}
|
||||
/>
|
||||
|
||||
<div className="relative grid min-h-168 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]">
|
||||
<div className="relative flex flex-col justify-center gap-12 p-6 sm:p-10 lg:p-14 xl:p-16">
|
||||
<div className="max-w-2xl">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 14 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.45, delay: 0.08 }}
|
||||
className="flex items-center gap-4"
|
||||
>
|
||||
<motion.div whileHover={{ scale: 1.03 }} className="relative shrink-0">
|
||||
<div
|
||||
className="absolute -inset-2 rounded-full blur-xl"
|
||||
style={{ background: 'linear-gradient(135deg, rgba(56,189,248,0.25), rgba(129,140,248,0.22))' }}
|
||||
/>
|
||||
<div
|
||||
className="relative rounded-full border p-1"
|
||||
style={{
|
||||
borderColor: 'var(--glass-border)',
|
||||
background: darkMode ? 'rgba(8,12,19,0.7)' : 'rgba(255,255,255,0.8)',
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
className="size-16 rounded-full"
|
||||
style={{ width: 64, height: 64, borderRadius: '50%', overflow: 'hidden', flexShrink: 0 }}
|
||||
>
|
||||
<Avatar.Image src={logoSrc} alt="SnowLuma" className="object-cover" />
|
||||
<Avatar.Fallback>SL</Avatar.Fallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
<div>
|
||||
<div className="text-sm font-medium" style={{ color: 'var(--accent)' }}>
|
||||
SnowLuma 控制台
|
||||
</div>
|
||||
<h1
|
||||
className="mt-1 text-4xl font-semibold tracking-[-0.04em] sm:text-5xl"
|
||||
style={{ color: 'var(--text-primary)' }}
|
||||
>
|
||||
SnowLuma
|
||||
</h1>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
<motion.p
|
||||
initial={{ opacity: 0, y: 16 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.45, delay: 0.16 }}
|
||||
className="mt-8 max-w-xl text-base leading-8"
|
||||
style={{ color: 'var(--text-secondary)' }}
|
||||
>
|
||||
基于 OneBot v11 标准实现的高性能 QQ 协议网关。
|
||||
</motion.p>
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 16 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.45, delay: 0.22 }}
|
||||
className="mt-8 flex flex-wrap gap-2"
|
||||
>
|
||||
{BRAND_TAGS.map(tag => (
|
||||
<span
|
||||
key={tag}
|
||||
className="rounded-full px-3.5 py-1.5 text-xs font-medium"
|
||||
style={{
|
||||
color: 'var(--accent)',
|
||||
background: 'var(--accent-subtle)',
|
||||
border: '1px solid color-mix(in srgb, var(--accent) 30%, transparent)',
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</motion.div>
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-6 left-6 sm:bottom-10 sm:left-10 lg:bottom-14 lg:left-14 xl:bottom-16 xl:left-16 pointer-events-none">
|
||||
<motion.p
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
transition={{ duration: 0.6, delay: 0.4 }}
|
||||
className="text-[11px] tracking-wide"
|
||||
style={{ color: 'var(--text-tertiary)' }}
|
||||
>
|
||||
© {new Date().getFullYear()} SnowLuma. All rights reserved.
|
||||
</motion.p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="relative flex items-center px-5 pb-5 pt-0 sm:px-8 sm:pb-8 lg:border-l lg:px-12 lg:py-12"
|
||||
style={{ borderColor: 'var(--glass-border)' }}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, x: 18 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ duration: 0.5, delay: 0.18 }}
|
||||
className="relative w-full max-w-md mx-auto rounded-[1.75rem] p-7 sm:p-8 overflow-hidden"
|
||||
style={{
|
||||
background: darkMode ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: darkMode
|
||||
? '0 24px 64px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.08)'
|
||||
: '0 24px 54px rgba(15,23,42,0.06), inset 0 1px 1px rgba(255,255,255,0.6)',
|
||||
border: '1px solid',
|
||||
borderColor: darkMode ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.8)',
|
||||
}}
|
||||
>
|
||||
{/* Subtle animated background glow for the card */}
|
||||
<motion.div
|
||||
className="absolute -top-32 -right-32 w-64 h-64 rounded-full pointer-events-none z-0"
|
||||
style={{
|
||||
background: 'var(--accent)',
|
||||
opacity: 0.15,
|
||||
filter: 'blur(60px)'
|
||||
}}
|
||||
animate={{ scale: [1, 1.2, 1], opacity: [0.1, 0.2, 0.1] }}
|
||||
transition={{ duration: 8, repeat: Infinity, ease: 'easeInOut' }}
|
||||
/>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-xs font-medium uppercase tracking-widest" style={{ color: 'var(--accent)' }}>
|
||||
安全登录
|
||||
</div>
|
||||
{/* <h2 className="mt-1 text-2xl font-semibold tracking-[-0.03em]" style={{ color: 'var(--text-primary)' }}>
|
||||
验证访问令牌
|
||||
</h2> */}
|
||||
</div>
|
||||
<div className="flex items-center gap-0.5">
|
||||
{THEME_OPTIONS.map(({ mode: m, icon: Icon, label }) => {
|
||||
const active = mode === m;
|
||||
return (
|
||||
<button
|
||||
key={m}
|
||||
title={label}
|
||||
onClick={() => setMode(m)}
|
||||
className="relative flex size-8 cursor-pointer items-center justify-center rounded-xl transition-colors duration-200"
|
||||
style={{ color: active ? 'var(--accent)' : 'var(--text-tertiary)' }}
|
||||
>
|
||||
{active && (
|
||||
<motion.div
|
||||
layoutId="theme-pill"
|
||||
className="absolute inset-0 rounded-xl"
|
||||
style={{ background: 'var(--accent-subtle)' }}
|
||||
transition={{ type: 'spring', stiffness: 400, damping: 30 }}
|
||||
/>
|
||||
)}
|
||||
<Icon size={14} className="relative z-10" />
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<motion.form
|
||||
initial={{ opacity: 0, y: 12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.45, delay: 0.26 }}
|
||||
onSubmit={handleSubmit}
|
||||
className="relative z-10 mt-6 flex flex-col gap-5"
|
||||
>
|
||||
<motion.div
|
||||
key={shakeKey}
|
||||
className="relative flex items-center justify-between overflow-hidden rounded-2xl"
|
||||
style={{
|
||||
background: darkMode ? 'rgba(0,0,0,0.2)' : 'rgba(255,255,255,0.6)',
|
||||
boxShadow: 'inset 0 2px 4px rgba(0,0,0,0.05)',
|
||||
border: '1px solid',
|
||||
borderColor: darkMode ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.04)',
|
||||
transition: 'all 0.3s ease',
|
||||
}}
|
||||
whileFocus={{ borderColor: 'var(--accent)', boxShadow: '0 0 0 2px var(--accent-subtle)' }}
|
||||
animate={shakeKey > 0 ? { x: [0, -8, 8, -6, 6, -3, 3, 0] } : {}}
|
||||
transition={{ duration: 0.45, ease: 'easeInOut' }}
|
||||
>
|
||||
<div className="flex h-14 flex-1 items-center px-4">
|
||||
<div
|
||||
className="mr-3 shrink-0"
|
||||
style={{ color: 'var(--text-tertiary)', transition: 'color 0.3s' }}
|
||||
>
|
||||
<KeyRound size={16} />
|
||||
</div>
|
||||
<input
|
||||
type={showPwd ? 'text' : 'password'}
|
||||
placeholder="输入访问令牌"
|
||||
value={password}
|
||||
onChange={e => setPassword(e.target.value)}
|
||||
autoFocus
|
||||
className="h-full w-full bg-transparent text-sm font-medium outline-none placeholder:font-normal"
|
||||
style={{
|
||||
color: 'var(--text-primary)',
|
||||
}}
|
||||
onFocus={e => {
|
||||
const icon = e.target.previousElementSibling as HTMLElement;
|
||||
if (icon) icon.style.color = 'var(--accent)';
|
||||
}}
|
||||
onBlur={e => {
|
||||
const icon = e.target.previousElementSibling as HTMLElement;
|
||||
if (icon) icon.style.color = 'var(--text-tertiary)';
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
onClick={() => setShowPwd(v => !v)}
|
||||
className="flex h-14 w-12 shrink-0 cursor-pointer items-center justify-center transition-colors hover:bg-black/5 dark:hover:bg-white/5"
|
||||
style={{ color: 'var(--text-tertiary)' }}
|
||||
>
|
||||
{showPwd ? <EyeOff size={15} /> : <Eye size={15} />}
|
||||
</button>
|
||||
</motion.div>
|
||||
|
||||
<AnimatePresence>
|
||||
{error && (
|
||||
<motion.p
|
||||
key="err"
|
||||
initial={{ opacity: 0, y: -6, scale: 0.97 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
exit={{ opacity: 0, y: -4, scale: 0.97 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="rounded-2xl px-4 py-3 text-center text-xs"
|
||||
style={{
|
||||
color: 'var(--color-danger)',
|
||||
background: 'rgba(248,113,113,0.08)',
|
||||
border: '1px solid rgba(248,113,113,0.18)',
|
||||
}}
|
||||
>
|
||||
{error}
|
||||
</motion.p>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.015, borderColor: 'var(--accent)', color: 'var(--accent)' }}
|
||||
whileTap={{ scale: 0.985 }}
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="relative mt-2 flex h-13 cursor-pointer items-center justify-center overflow-hidden rounded-2xl text-sm font-medium disabled:cursor-not-allowed disabled:opacity-75"
|
||||
style={{
|
||||
background: darkMode ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.02)',
|
||||
border: '1px solid',
|
||||
borderColor: darkMode ? 'rgba(255, 255, 255, 0.08)' : 'rgba(0, 0, 0, 0.06)',
|
||||
color: 'var(--text-primary)',
|
||||
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
}}
|
||||
>
|
||||
<span className="relative z-10 flex items-center justify-center gap-2 tracking-wide">
|
||||
{loading ? (
|
||||
<>
|
||||
<motion.span
|
||||
animate={{ rotate: 360 }}
|
||||
transition={{ duration: 0.8, ease: 'linear', repeat: Infinity }}
|
||||
className="inline-block size-4 rounded-full border-2 border-t-transparent"
|
||||
style={{ borderColor: 'currentColor', borderTopColor: 'transparent' }}
|
||||
/>
|
||||
验证中…
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
进入控制台
|
||||
<ArrowRight size={16} strokeWidth={2} />
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
</motion.button>
|
||||
</motion.form>
|
||||
</motion.div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { RefreshCw, Terminal } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
|
||||
interface LogEntry {
|
||||
id: number;
|
||||
time: string;
|
||||
level: 'debug' | 'info' | 'success' | 'warn' | 'error';
|
||||
scope: string;
|
||||
message: string;
|
||||
line: string;
|
||||
}
|
||||
|
||||
interface LogsPageProps {
|
||||
fetchApi: (url: string, options?: RequestInit) => Promise<Response>;
|
||||
}
|
||||
|
||||
const levelColor: Record<LogEntry['level'], string> = {
|
||||
debug: 'var(--text-tertiary)',
|
||||
info: 'var(--accent)',
|
||||
success: 'var(--color-success)',
|
||||
warn: '#f59e0b',
|
||||
error: 'var(--color-danger)',
|
||||
};
|
||||
|
||||
export function LogsPage({ fetchApi }: LogsPageProps) {
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
const [logs, setLogs] = useState<LogEntry[]>([]);
|
||||
const [streamStatus, setStreamStatus] = useState('连接中');
|
||||
const endRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const token = useMemo(() => localStorage.getItem('snowluma_token') || '', []);
|
||||
|
||||
async function loadLogs() {
|
||||
const res = await fetchApi('/api/logs?limit=500');
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
setLogs(data.list || []);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadLogs().catch(console.error);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) return;
|
||||
const url = `/api/logs/stream?token=${encodeURIComponent(token)}`;
|
||||
const source = new EventSource(url);
|
||||
source.onopen = () => setStreamStatus('实时连接');
|
||||
source.onerror = () => setStreamStatus('重连中');
|
||||
source.onmessage = event => {
|
||||
try {
|
||||
const entry = JSON.parse(event.data) as LogEntry | { type: string };
|
||||
if ('type' in entry) return;
|
||||
setLogs(prev => [...prev.filter(item => item.id !== entry.id), entry].slice(-500));
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
return () => source.close();
|
||||
}, [token]);
|
||||
|
||||
useEffect(() => {
|
||||
endRef.current?.scrollIntoView({ block: 'end' });
|
||||
}, [logs]);
|
||||
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-4">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="rounded-xl p-4"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
}}
|
||||
>
|
||||
<div className="mb-4 flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className="flex size-9 items-center justify-center rounded-lg"
|
||||
style={{ background: 'var(--accent-subtle)', color: 'var(--accent)' }}
|
||||
>
|
||||
<Terminal size={17} strokeWidth={2} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold" style={{ color: 'var(--text-primary)' }}>运行日志</h2>
|
||||
<p className="mt-0.5 text-xs" style={{ color: 'var(--text-secondary)' }}>{streamStatus} · 最近 {logs.length} 条</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => loadLogs().catch(console.error)}
|
||||
className="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-3 text-xs font-medium"
|
||||
style={{
|
||||
color: 'var(--text-secondary)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
background: 'transparent',
|
||||
}}
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
刷新
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="h-[58vh] overflow-auto rounded-xl p-3 text-xs"
|
||||
style={{
|
||||
background: dark ? 'rgba(0,0,0,0.22)' : 'rgba(255,255,255,0.42)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
fontFamily: 'var(--font-mono)',
|
||||
}}
|
||||
>
|
||||
{logs.length === 0 ? (
|
||||
<div className="flex h-full items-center justify-center" style={{ color: 'var(--text-tertiary)' }}>暂无日志</div>
|
||||
) : logs.map(log => (
|
||||
<div key={log.id} className="flex gap-2 whitespace-pre-wrap py-0.5 leading-5">
|
||||
<span className="shrink-0" style={{ color: 'var(--text-tertiary)' }}>{new Date(log.time).toLocaleTimeString()}</span>
|
||||
<span className="w-14 shrink-0 font-semibold" style={{ color: levelColor[log.level] }}>{log.level.toUpperCase()}</span>
|
||||
<span className="w-24 shrink-0 truncate" style={{ color: 'var(--text-secondary)' }}>[{log.scope}]</span>
|
||||
<span style={{ color: 'var(--text-primary)' }}>{log.message}</span>
|
||||
</div>
|
||||
))}
|
||||
<div ref={endRef} />
|
||||
</div>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
import { Users, Activity, Cpu, RefreshCw, Loader2, CheckCircle2, AlertCircle, Unplug } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { StatCard } from '../ui/StatCard';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
import type { QQInfo, HookProcessInfo } from '../../types';
|
||||
|
||||
interface OverviewPageProps {
|
||||
qqList: QQInfo[];
|
||||
status: string;
|
||||
processList: HookProcessInfo[];
|
||||
processLoadingPid: number | null;
|
||||
processUnloadingPid: number | null;
|
||||
processActionStatus: string;
|
||||
onRefreshProcesses: () => void;
|
||||
onLoadProcess: (pid: number) => void;
|
||||
onUnloadProcess: (pid: number) => void;
|
||||
}
|
||||
|
||||
const processStatusLabel: Record<HookProcessInfo['status'], string> = {
|
||||
available: '可加载',
|
||||
loading: '加载中',
|
||||
loaded: '等待登录',
|
||||
online: '已在线',
|
||||
error: '错误',
|
||||
disconnected: '已断开',
|
||||
};
|
||||
|
||||
function processStatusColor(status: HookProcessInfo['status']): string {
|
||||
if (status === 'online') return 'var(--color-success)';
|
||||
if (status === 'error' || status === 'disconnected') return 'var(--color-danger)';
|
||||
if (status === 'loading' || status === 'loaded') return 'var(--accent)';
|
||||
return 'var(--text-secondary)';
|
||||
}
|
||||
|
||||
function qqAvatarUrl(uin: string): string {
|
||||
return `/avatar/${encodeURIComponent(uin)}`;
|
||||
}
|
||||
|
||||
export function OverviewPage({
|
||||
qqList,
|
||||
status,
|
||||
processList,
|
||||
processLoadingPid,
|
||||
processUnloadingPid,
|
||||
processActionStatus,
|
||||
onRefreshProcesses,
|
||||
onLoadProcess,
|
||||
onUnloadProcess,
|
||||
}: OverviewPageProps) {
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Stat cards */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<StatCard
|
||||
label="接入账号"
|
||||
value={String(qqList.length)}
|
||||
icon={<Users size={18} strokeWidth={2} />}
|
||||
/>
|
||||
<StatCard
|
||||
label="服务状态"
|
||||
value={status === '已连接' ? '运行中' : status}
|
||||
icon={<Activity size={18} strokeWidth={2} />}
|
||||
accent={status === '已连接' ? 'success' : 'danger'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.05, duration: 0.3 }}
|
||||
className="rounded-xl p-4"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.06)'
|
||||
: '0 8px 24px rgba(15,23,42,0.04), inset 0 1px 1px rgba(255,255,255,0.5)',
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3 mb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className="size-9 rounded-lg flex items-center justify-center"
|
||||
style={{ background: 'var(--accent-subtle)', color: 'var(--accent)' }}
|
||||
>
|
||||
<Cpu size={17} strokeWidth={2} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-sm font-semibold" style={{ color: 'var(--text-primary)' }}>
|
||||
选择 QQ 进程
|
||||
</h2>
|
||||
<p className="text-xs mt-0.5" style={{ color: 'var(--text-secondary)' }}>
|
||||
加载 SnowLuma 后会监听登录状态,登录成功后自动接入原有 OneBot 流程
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onRefreshProcesses}
|
||||
className="h-8 px-3 rounded-lg text-xs font-medium inline-flex items-center gap-1.5 cursor-pointer"
|
||||
style={{
|
||||
color: 'var(--text-secondary)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
background: 'transparent',
|
||||
}}
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
刷新
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{processActionStatus && (
|
||||
<div
|
||||
className="mb-3 rounded-lg px-3 py-2 text-xs"
|
||||
style={{
|
||||
color: 'var(--accent)',
|
||||
background: 'var(--accent-subtle)',
|
||||
border: '1px solid color-mix(in srgb, var(--accent) 20%, transparent)',
|
||||
}}
|
||||
>
|
||||
{processActionStatus}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{processList.length > 0 ? (
|
||||
<div className="grid grid-cols-1 xl:grid-cols-2 gap-3">
|
||||
{processList.map((proc, idx) => {
|
||||
const loading = processLoadingPid === proc.pid || proc.status === 'loading';
|
||||
const unloading = processUnloadingPid === proc.pid;
|
||||
const busy = loading || unloading;
|
||||
const online = proc.status === 'online';
|
||||
const canUnload = proc.injected || proc.status === 'loaded' || online || proc.status === 'disconnected';
|
||||
const disabled = busy;
|
||||
const actionLabel = canUnload
|
||||
? unloading ? '卸载中' : '卸载'
|
||||
: loading ? '加载中' : '加载';
|
||||
const action = canUnload ? () => onUnloadProcess(proc.pid) : () => onLoadProcess(proc.pid);
|
||||
return (
|
||||
<motion.div
|
||||
key={proc.pid}
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.08 + idx * 0.03, duration: 0.22 }}
|
||||
className="flex items-center gap-3 rounded-xl p-3 overflow-hidden"
|
||||
style={{
|
||||
background: dark ? 'rgba(255,255,255,0.03)' : 'rgba(255,255,255,0.46)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.05)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="size-10 rounded-lg flex items-center justify-center shrink-0"
|
||||
style={{ background: 'var(--accent-subtle)', color: 'var(--accent)' }}
|
||||
>
|
||||
{online ? <CheckCircle2 size={18} /> : proc.status === 'error' ? <AlertCircle size={18} /> : <Cpu size={18} />}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<span className="text-sm font-semibold truncate" style={{ color: 'var(--text-primary)' }}>
|
||||
{proc.name || 'QQ.exe'}
|
||||
</span>
|
||||
<span
|
||||
className="text-[11px] px-1.5 py-0.5 rounded-md shrink-0"
|
||||
style={{
|
||||
color: processStatusColor(proc.status),
|
||||
background: dark ? 'rgba(255,255,255,0.04)' : 'rgba(255,255,255,0.6)',
|
||||
}}
|
||||
>
|
||||
{processStatusLabel[proc.status]}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-xs mt-0.5 truncate" style={{ color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)' }}>
|
||||
PID {proc.pid}{proc.uin && proc.uin !== '0' ? ` · UIN ${proc.uin}` : ''}
|
||||
</div>
|
||||
{proc.path && (
|
||||
<div className="text-[11px] mt-0.5 truncate" title={proc.path} style={{ color: 'var(--text-tertiary)' }}>
|
||||
{proc.path}
|
||||
</div>
|
||||
)}
|
||||
{proc.error && (
|
||||
<div className="text-[11px] mt-1 truncate" title={proc.error} style={{ color: 'var(--color-danger)' }}>
|
||||
{proc.error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={action}
|
||||
disabled={disabled}
|
||||
className="h-8 px-3 rounded-lg text-xs font-semibold inline-flex items-center gap-1.5 shrink-0"
|
||||
style={{
|
||||
color: disabled ? 'var(--text-tertiary)' : canUnload ? 'var(--color-danger)' : 'white',
|
||||
background: disabled ? 'var(--bg-hover)' : canUnload ? 'rgba(248,113,113,0.08)' : 'linear-gradient(135deg, var(--accent), #818cf8)',
|
||||
cursor: disabled ? 'default' : 'pointer',
|
||||
border: canUnload ? '1px solid rgba(248,113,113,0.2)' : '1px solid transparent',
|
||||
boxShadow: disabled || canUnload ? 'none' : '0 8px 18px var(--accent-glow)',
|
||||
}}
|
||||
>
|
||||
{busy && <Loader2 size={13} className="animate-spin" />}
|
||||
{!busy && canUnload && <Unplug size={13} />}
|
||||
{actionLabel}
|
||||
</button>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className="flex flex-col items-center justify-center py-10 rounded-xl gap-2"
|
||||
style={{
|
||||
border: '1px dashed',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.08)',
|
||||
}}
|
||||
>
|
||||
<Cpu size={30} strokeWidth={1.5} style={{ color: 'var(--text-tertiary)' }} />
|
||||
<p className="text-sm font-medium" style={{ color: 'var(--text-secondary)' }}>未检测到可加载 QQ 主进程</p>
|
||||
</div>
|
||||
)}
|
||||
</motion.div>
|
||||
|
||||
{/* Account list */}
|
||||
{qqList.length > 0 && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.1, duration: 0.3 }}
|
||||
>
|
||||
<h2 className="text-sm font-semibold mb-4" style={{ color: 'var(--text-primary)' }}>
|
||||
在线会话
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3">
|
||||
{qqList.map((q, idx) => (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.1 + idx * 0.04, duration: 0.25 }}
|
||||
whileHover={{ y: -2 }}
|
||||
key={q.uin}
|
||||
className="flex items-center gap-3 p-4 rounded-xl cursor-default group overflow-hidden"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.06)'
|
||||
: '0 8px 24px rgba(15,23,42,0.04), inset 0 1px 1px rgba(255,255,255,0.5)',
|
||||
transition: 'var(--transition-base)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="size-10 rounded-lg flex items-center justify-center text-white text-sm font-bold shrink-0 overflow-hidden"
|
||||
style={{
|
||||
background: 'linear-gradient(135deg, var(--accent), #818cf8)',
|
||||
boxShadow: '0 0 12px var(--accent-glow)',
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={qqAvatarUrl(q.uin)}
|
||||
alt={q.nickname || q.uin}
|
||||
className="size-full object-cover"
|
||||
referrerPolicy="no-referrer"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-sm font-semibold truncate" style={{ color: 'var(--text-primary)' }}>
|
||||
{q.nickname}
|
||||
</div>
|
||||
<div
|
||||
className="text-xs mt-0.5 truncate"
|
||||
style={{ color: 'var(--text-secondary)', fontFamily: 'var(--font-mono)', fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
{q.uin}
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
className="size-2 rounded-full shrink-0 animate-pulse"
|
||||
style={{ background: 'var(--color-success)', boxShadow: '0 0 8px rgba(52,211,153,0.5)' }}
|
||||
/>
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
{qqList.length === 0 && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0 }} animate={{ opacity: 1 }}
|
||||
className="flex flex-col items-center justify-center py-16 rounded-xl gap-3"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px dashed',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.08)',
|
||||
}}
|
||||
>
|
||||
<Users size={36} strokeWidth={1.5} style={{ color: 'var(--text-tertiary)' }} />
|
||||
<p className="text-sm font-medium" style={{ color: 'var(--text-secondary)' }}>暂无在线会话</p>
|
||||
</motion.div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { X } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
|
||||
interface EndpointRowProps {
|
||||
onRemove: () => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function EndpointRow({ onRemove, children }: EndpointRowProps) {
|
||||
return (
|
||||
<div
|
||||
className="flex items-end gap-3 px-5 py-4"
|
||||
style={{ borderBottom: '1px solid var(--border-subtle)', transition: 'var(--transition-fast)' }}
|
||||
>
|
||||
{children}
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.1 }}
|
||||
whileTap={{ scale: 0.9 }}
|
||||
onClick={onRemove}
|
||||
className="size-7 shrink-0 flex items-center justify-center rounded-lg cursor-pointer mb-0.5"
|
||||
style={{ color: 'var(--text-tertiary)', transition: 'var(--transition-fast)' }}
|
||||
onMouseEnter={e => { e.currentTarget.style.color = 'var(--color-danger)'; e.currentTarget.style.background = 'rgba(248,113,113,0.08)'; }}
|
||||
onMouseLeave={e => { e.currentTarget.style.color = 'var(--text-tertiary)'; e.currentTarget.style.background = 'transparent'; }}
|
||||
>
|
||||
<X size={14} />
|
||||
</motion.button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
interface FieldInputProps {
|
||||
label: string;
|
||||
placeholder?: string;
|
||||
value?: string | number;
|
||||
isNum?: boolean;
|
||||
flex?: string;
|
||||
grow?: boolean;
|
||||
onChange: (v: string | number) => void;
|
||||
}
|
||||
|
||||
export function FieldInput({ label, placeholder, value, isNum, flex, grow, onChange }: FieldInputProps) {
|
||||
return (
|
||||
<div className={`flex flex-col gap-1.5 ${grow ? 'flex-1' : flex || ''}`}>
|
||||
<label className="text-xs font-medium pl-0.5" style={{ color: 'var(--text-secondary)' }}>{label}</label>
|
||||
<input
|
||||
type={isNum ? 'number' : 'text'}
|
||||
placeholder={placeholder}
|
||||
value={value ?? ''}
|
||||
onChange={e => onChange(isNum ? (parseInt(e.target.value) || 0) : e.target.value)}
|
||||
className="h-9 px-3 rounded-lg text-sm outline-none"
|
||||
style={{
|
||||
background: 'rgba(0,0,0,0.12)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
boxShadow: 'inset 0 2px 4px rgba(0,0,0,0.05)',
|
||||
color: 'var(--text-primary)',
|
||||
transition: 'all 0.3s ease',
|
||||
...(isNum ? { fontVariantNumeric: 'tabular-nums', fontFamily: 'var(--font-mono, monospace)' } : {}),
|
||||
}}
|
||||
onFocus={e => { e.target.style.borderColor = 'var(--border-focus)'; e.target.style.boxShadow = '0 0 0 2px var(--accent-subtle)'; }}
|
||||
onBlur={e => { e.target.style.borderColor = 'var(--border-subtle)'; e.target.style.boxShadow = 'inset 0 2px 4px rgba(0,0,0,0.05)'; }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
|
||||
interface SectionCardProps {
|
||||
title: string;
|
||||
onAdd: () => void;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function SectionCard({ title, onAdd, children }: SectionCardProps) {
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
return (
|
||||
<div
|
||||
className="rounded-xl overflow-hidden relative"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.06)'
|
||||
: '0 8px 24px rgba(15,23,42,0.04), inset 0 1px 1px rgba(255,255,255,0.5)',
|
||||
transition: 'var(--transition-base)',
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
<div
|
||||
className="flex items-center justify-between px-5 py-3"
|
||||
style={{ borderBottom: '1px solid var(--border-subtle)' }}
|
||||
>
|
||||
<h3 className="text-sm font-medium" style={{ color: 'var(--text-primary)' }}>{title}</h3>
|
||||
<motion.button
|
||||
whileHover={{ scale: 1.1 }}
|
||||
whileTap={{ scale: 0.9 }}
|
||||
onClick={onAdd}
|
||||
className="size-7 flex items-center justify-center rounded-lg cursor-pointer"
|
||||
style={{ color: 'var(--text-secondary)', transition: 'var(--transition-fast)' }}
|
||||
>
|
||||
<Plus size={14} />
|
||||
</motion.button>
|
||||
</div>
|
||||
|
||||
{/* Body */}
|
||||
<div>
|
||||
{!children ? (
|
||||
<p className="text-xs px-5 py-6 text-center" style={{ color: 'var(--text-tertiary)' }}>未配置,点击 + 新增</p>
|
||||
) : children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { useTheme } from '../../contexts/ThemeContext';
|
||||
|
||||
interface StatCardProps {
|
||||
label: string;
|
||||
value: string;
|
||||
icon?: ReactNode;
|
||||
accent?: 'default' | 'success' | 'warning' | 'danger';
|
||||
}
|
||||
|
||||
const accentColors: Record<string, { icon: string; value: string; glow: string }> = {
|
||||
default: { icon: 'var(--accent)', value: 'var(--text-primary)', glow: 'var(--accent-glow)' },
|
||||
success: { icon: 'var(--color-success)', value: 'var(--color-success)', glow: 'rgba(52,211,153,0.1)' },
|
||||
warning: { icon: 'var(--color-warning)', value: 'var(--color-warning)', glow: 'rgba(251,191,36,0.1)' },
|
||||
danger: { icon: 'var(--color-danger)', value: 'var(--color-danger)', glow: 'rgba(248,113,113,0.1)' },
|
||||
};
|
||||
|
||||
export function StatCard({ label, value, icon, accent = 'default' }: StatCardProps) {
|
||||
const colors = accentColors[accent];
|
||||
const { resolved } = useTheme();
|
||||
const dark = resolved === 'dark';
|
||||
return (
|
||||
<motion.div
|
||||
whileHover={{ y: -2 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="relative rounded-xl p-5 group overflow-hidden"
|
||||
style={{
|
||||
background: dark ? 'rgba(8,12,19,0.4)' : 'rgba(255,255,255,0.4)',
|
||||
border: '1px solid',
|
||||
borderColor: dark ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.8)',
|
||||
backdropFilter: 'blur(32px) saturate(1.2)',
|
||||
WebkitBackdropFilter: 'blur(32px) saturate(1.2)',
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.06)'
|
||||
: '0 8px 24px rgba(15,23,42,0.04), inset 0 1px 1px rgba(255,255,255,0.5)',
|
||||
transition: 'var(--transition-base)',
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<span className="text-xs font-medium uppercase tracking-wider" style={{ color: 'var(--text-secondary)' }}>
|
||||
{label}
|
||||
</span>
|
||||
{icon && (
|
||||
<div
|
||||
className="size-8 rounded-lg flex items-center justify-center"
|
||||
style={{ background: colors.glow, color: colors.icon }}
|
||||
>
|
||||
{icon}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className="text-2xl font-bold tracking-tight"
|
||||
style={{ color: colors.value, fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
{value}
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
interface StatusBadgeProps {
|
||||
status: string;
|
||||
}
|
||||
|
||||
export function StatusBadge({ status }: StatusBadgeProps) {
|
||||
const isOnline = status === '已连接';
|
||||
const isConnecting = status === '连接中';
|
||||
|
||||
const dotColor = isOnline
|
||||
? 'var(--color-success)'
|
||||
: isConnecting
|
||||
? 'var(--color-warning)'
|
||||
: 'var(--text-tertiary)';
|
||||
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium"
|
||||
style={{ color: dotColor, background: `color-mix(in srgb, ${dotColor} 10%, transparent)`, border: `1px solid color-mix(in srgb, ${dotColor} 20%, transparent)` }}
|
||||
>
|
||||
<span
|
||||
className={`size-1.5 rounded-full shrink-0 ${isOnline ? 'animate-pulse' : ''}`}
|
||||
style={{ background: dotColor }}
|
||||
/>
|
||||
{status}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user