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,469 @@
|
||||
.layout {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 240px;
|
||||
background: var(--bg-sidebar);
|
||||
border-right: 1px solid var(--border-subtle);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24px 0 0 0;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.brand {
|
||||
padding: 0 24px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.brand h1 {
|
||||
font-size: 1.3rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
background: linear-gradient(90deg, var(--color-primary), #818cf8);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.nav-menu {
|
||||
flex: 1;
|
||||
padding: 0 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
padding: 10px 16px;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 16px;
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s;
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.btn-ghost:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: var(--color-danger);
|
||||
border-color: var(--color-danger);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
padding: 4px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: var(--bg-body);
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 32px;
|
||||
background: var(--bg-card);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.search-input {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 8px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-main);
|
||||
width: 260px;
|
||||
font-size: 0.85rem;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-muted);
|
||||
}
|
||||
.status-dot.on { background: #10b981; }
|
||||
.status-dot.off { background: var(--color-danger); }
|
||||
|
||||
.main-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.overview-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.overview-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.card-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
}
|
||||
.status-ok {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
/* Config Layout */
|
||||
.config-layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.list-pane {
|
||||
width: 280px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.pane-title {
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.qq-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.qq-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.qq-item:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.qq-item.active {
|
||||
background: var(--bg-hover);
|
||||
border-color: var(--border-active);
|
||||
}
|
||||
|
||||
.qq-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--color-primary), #818cf8);
|
||||
}
|
||||
|
||||
.qq-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.qq-nik {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.qq-uin {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.editor-pane {
|
||||
flex: 1;
|
||||
min-height: 500px;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.editor-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 32px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.editor-title h2 {
|
||||
font-size: 1.25rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.editor-subtitle {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.editor-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.save-status {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.save-status.ok { color: #10b981; }
|
||||
|
||||
.cfg-section {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.cfg-section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.cfg-section-header h4 {
|
||||
font-size: 1rem;
|
||||
color: var(--text-main);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.cfg-section-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.endpoint-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 16px;
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.input-group input {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-main);
|
||||
font-family: monospace;
|
||||
font-size: 0.85rem;
|
||||
transition: border-color 0.2s;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-group input:focus {
|
||||
border-color: var(--border-focus);
|
||||
}
|
||||
|
||||
.endpoint-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
/* Login Screen Override */
|
||||
.login-screen {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
background: var(--bg-body);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 380px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 1.5rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 12px;
|
||||
background: linear-gradient(90deg, var(--color-primary), #818cf8);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.login-desc {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.login-submit-btn {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.login-error {
|
||||
color: var(--color-danger);
|
||||
font-size: 0.8rem;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// Token layer only — component styles live in Tailwind classes inside TSX
|
||||
@use './styles/variables';
|
||||
@@ -0,0 +1,231 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { ThemeProvider } from './contexts/ThemeContext';
|
||||
import { MainLayout } from './components/layout/MainLayout';
|
||||
import { LoginPage } from './components/pages/LoginPage';
|
||||
import { OverviewPage } from './components/pages/OverviewPage';
|
||||
import { ConfigPage } from './components/pages/ConfigPage';
|
||||
import { LogsPage } from './components/pages/LogsPage';
|
||||
import type { QQInfo, OneBotConfig, HookProcessInfo } from './types';
|
||||
|
||||
const fetchApi = async (url: string, options: RequestInit = {}) => {
|
||||
const token = localStorage.getItem('snowluma_token');
|
||||
const headers = new Headers(options.headers || {});
|
||||
if (token) headers.set('Authorization', `Bearer ${token}`);
|
||||
return fetch(url, { ...options, headers });
|
||||
};
|
||||
|
||||
function App() {
|
||||
const [status, setStatus] = useState('连接中');
|
||||
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(
|
||||
import.meta.env.VITE_SKIP_AUTH === 'true' ? true : null
|
||||
);
|
||||
const [activePage, setActivePage] = useState<'总览' | '配置' | '日志'>('总览');
|
||||
const [qqList, setQqList] = useState<QQInfo[]>([]);
|
||||
const [processList, setProcessList] = useState<HookProcessInfo[]>([]);
|
||||
const [processLoadingPid, setProcessLoadingPid] = useState<number | null>(null);
|
||||
const [processUnloadingPid, setProcessUnloadingPid] = useState<number | null>(null);
|
||||
const [processActionStatus, setProcessActionStatus] = useState('');
|
||||
const [selectedUin, setSelectedUin] = useState<string | null>(null);
|
||||
const [config, setConfig] = useState<OneBotConfig | null>(null);
|
||||
const [saveStatus, setSaveStatus] = useState('');
|
||||
|
||||
function checkStatus() {
|
||||
fetchApi('/api/status')
|
||||
.then(async (res) => {
|
||||
if (res.status === 401) { setIsAuthenticated(false); setStatus('需要认证'); return; }
|
||||
if (res.ok) {
|
||||
setIsAuthenticated(true);
|
||||
const data = await res.json();
|
||||
setStatus(data.status === 'running' ? '已连接' : '已断开');
|
||||
fetchQqList();
|
||||
fetchProcesses();
|
||||
return;
|
||||
}
|
||||
// Any other non-ok status (502, 500, etc.)
|
||||
setIsAuthenticated(false);
|
||||
setStatus('已断开');
|
||||
})
|
||||
.catch(() => { setStatus('已断开'); setIsAuthenticated(false); });
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (import.meta.env.VITE_SKIP_AUTH !== 'true') checkStatus();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated !== true) return;
|
||||
fetchQqList();
|
||||
fetchProcesses();
|
||||
const timer = window.setInterval(() => {
|
||||
fetchQqList();
|
||||
fetchProcesses();
|
||||
}, 3000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [isAuthenticated]);
|
||||
|
||||
const handleLogin = async (password: string) => {
|
||||
try {
|
||||
const res = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok && data.success) {
|
||||
localStorage.setItem('snowluma_token', data.token);
|
||||
setIsAuthenticated(true);
|
||||
checkStatus();
|
||||
return { success: true };
|
||||
}
|
||||
return { success: false, error: '认证失败,请检查控制台日志' };
|
||||
} catch {
|
||||
return { success: false, error: '内部错误,请检查后端运行状态' };
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem('snowluma_token');
|
||||
setIsAuthenticated(false);
|
||||
setStatus('需要认证');
|
||||
setQqList([]);
|
||||
setProcessList([]);
|
||||
setConfig(null);
|
||||
};
|
||||
|
||||
async function fetchQqList() {
|
||||
try {
|
||||
const res = await fetchApi('/api/qq-list');
|
||||
if (res.ok) { const data = await res.json(); setQqList(data.list || []); }
|
||||
} catch (err) { console.error(err); }
|
||||
}
|
||||
|
||||
async function fetchProcesses() {
|
||||
try {
|
||||
const res = await fetchApi('/api/processes');
|
||||
if (res.ok) { const data = await res.json(); setProcessList(data.list || []); }
|
||||
} catch (err) { console.error(err); }
|
||||
}
|
||||
|
||||
const loadProcess = async (pid: number) => {
|
||||
setProcessLoadingPid(pid);
|
||||
setProcessActionStatus('正在手动映射加载 SnowLuma...');
|
||||
try {
|
||||
const res = await fetchApi(`/api/processes/${pid}/load`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setProcessActionStatus(res.ok && data.success ? '已开始监听登录状态' : data.message || '加载失败');
|
||||
await fetchProcesses();
|
||||
await fetchQqList();
|
||||
} catch {
|
||||
setProcessActionStatus('网络错误,加载失败');
|
||||
} finally {
|
||||
setProcessLoadingPid(null);
|
||||
setTimeout(() => setProcessActionStatus(''), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
const unloadProcess = async (pid: number) => {
|
||||
setProcessUnloadingPid(pid);
|
||||
setProcessActionStatus('正在卸载 SnowLuma...');
|
||||
try {
|
||||
const res = await fetchApi(`/api/processes/${pid}/unload`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setProcessActionStatus(res.ok && data.success ? '已卸载 SnowLuma' : data.message || '卸载失败');
|
||||
await fetchProcesses();
|
||||
await fetchQqList();
|
||||
} catch {
|
||||
setProcessActionStatus('网络错误,卸载失败');
|
||||
} finally {
|
||||
setProcessUnloadingPid(null);
|
||||
setTimeout(() => setProcessActionStatus(''), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
const loadConfig = async (uin: string) => {
|
||||
setSelectedUin(uin);
|
||||
setSaveStatus('');
|
||||
setConfig(null);
|
||||
try {
|
||||
const res = await fetchApi(`/api/config/${uin}`);
|
||||
if (res.ok) { const data = await res.json(); setConfig(data.config); }
|
||||
} catch (err) { console.error(err); }
|
||||
};
|
||||
|
||||
const saveConfig = async () => {
|
||||
if (!selectedUin || !config) return;
|
||||
setSaveStatus('保存中...');
|
||||
try {
|
||||
const res = await fetchApi(`/api/config/${selectedUin}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config),
|
||||
});
|
||||
setSaveStatus(res.ok ? '保存成功' : '保存出错');
|
||||
setTimeout(() => setSaveStatus(''), 3000);
|
||||
} catch {
|
||||
setSaveStatus('网络错误');
|
||||
}
|
||||
};
|
||||
|
||||
// Loading state
|
||||
if (isAuthenticated === null) {
|
||||
return (
|
||||
<div className="h-screen flex items-center justify-center" style={{ background: 'var(--bg-body)' }}>
|
||||
<div className="size-5 border-2 rounded-full animate-spin" style={{ borderColor: 'var(--border-subtle)', borderTopColor: 'var(--accent)' }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Login
|
||||
if (isAuthenticated === false) {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<LoginPage onLogin={handleLogin} />
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
// Main app
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<MainLayout activePage={activePage} onNavigate={setActivePage} status={status} onLogout={handleLogout}>
|
||||
{activePage === '总览' && (
|
||||
<OverviewPage
|
||||
qqList={qqList}
|
||||
status={status}
|
||||
processList={processList}
|
||||
processLoadingPid={processLoadingPid}
|
||||
processUnloadingPid={processUnloadingPid}
|
||||
processActionStatus={processActionStatus}
|
||||
onRefreshProcesses={fetchProcesses}
|
||||
onLoadProcess={loadProcess}
|
||||
onUnloadProcess={unloadProcess}
|
||||
/>
|
||||
)}
|
||||
{activePage === '配置' && (
|
||||
<ConfigPage
|
||||
qqList={qqList}
|
||||
selectedUin={selectedUin}
|
||||
config={config}
|
||||
saveStatus={saveStatus}
|
||||
onSelectAccount={loadConfig}
|
||||
onSave={saveConfig}
|
||||
onConfigChange={setConfig}
|
||||
/>
|
||||
)}
|
||||
{activePage === '日志' && (
|
||||
<LogsPage fetchApi={fetchApi} />
|
||||
)}
|
||||
</MainLayout>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="usLine truncated
|
||||
|
After Width: | Height: | Size: 8.5 KiB |
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'system';
|
||||
|
||||
interface ThemeContextValue {
|
||||
mode: ThemeMode;
|
||||
resolved: 'light' | 'dark';
|
||||
setMode: (mode: ThemeMode) => void;
|
||||
}
|
||||
|
||||
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
||||
|
||||
function getSystemTheme(): 'light' | 'dark' {
|
||||
return window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
const [mode, setModeState] = useState<ThemeMode>(() => {
|
||||
const saved = localStorage.getItem('snowluma_theme') as ThemeMode | null;
|
||||
if (saved === 'light' || saved === 'dark' || saved === 'system') return saved;
|
||||
return 'system';
|
||||
});
|
||||
|
||||
const [systemTheme, setSystemTheme] = useState<'light' | 'dark'>(getSystemTheme);
|
||||
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const handler = (e: MediaQueryListEvent) => setSystemTheme(e.matches ? 'dark' : 'light');
|
||||
mq.addEventListener('change', handler);
|
||||
return () => mq.removeEventListener('change', handler);
|
||||
}, []);
|
||||
|
||||
const resolved: 'light' | 'dark' = mode === 'system' ? systemTheme : mode;
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
root.className = resolved;
|
||||
root.setAttribute('data-theme', resolved);
|
||||
root.style.colorScheme = resolved;
|
||||
}, [resolved]);
|
||||
|
||||
const setMode = (m: ThemeMode) => {
|
||||
setModeState(m);
|
||||
localStorage.setItem('snowluma_theme', m);
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemeContext value={{ mode, resolved, setMode }}>
|
||||
{children}
|
||||
</ThemeContext>
|
||||
);
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
const ctx = useContext(ThemeContext);
|
||||
if (!ctx) throw new Error('useTheme must be used within ThemeProvider');
|
||||
return ctx;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
/* ── Global Reset & Base ── */
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
}
|
||||
|
||||
/* ── HeroUI Avatar base ── */
|
||||
.avatar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
border-radius: 9999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.avatar__image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
aspect-ratio: 1 / 1;
|
||||
}
|
||||
.avatar__fallback {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
|
||||
line-height: 1.5;
|
||||
color: var(--text-primary);
|
||||
background-color: var(--bg-body);
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
}
|
||||
|
||||
#root {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ── Scrollbar ── */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 3px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
/* ── Selection ── */
|
||||
::selection {
|
||||
background: rgba(56, 189, 248, 0.25);
|
||||
color: #f1f5f9;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import './App.scss'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
// Responsive breakpoint mixins
|
||||
@mixin sm {
|
||||
@media (min-width: 640px) { @content; }
|
||||
}
|
||||
|
||||
@mixin md {
|
||||
@media (min-width: 768px) { @content; }
|
||||
}
|
||||
|
||||
@mixin lg {
|
||||
@media (min-width: 1024px) { @content; }
|
||||
}
|
||||
|
||||
// Flex shortcuts
|
||||
@mixin flex-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@mixin flex-between {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
@mixin flex-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
// SnowLuma – Refined dark-first glassmorphism design system
|
||||
// Palette: deep navy base, cool slate surfaces, cyan/indigo accent pair
|
||||
|
||||
:root {
|
||||
// Typography
|
||||
--font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
|
||||
|
||||
// Radii
|
||||
--radius-xs: 6px;
|
||||
--radius-sm: 8px;
|
||||
--radius-md: 12px;
|
||||
--radius-lg: 16px;
|
||||
--radius-xl: 20px;
|
||||
--radius-2xl: 24px;
|
||||
--radius-full: 9999px;
|
||||
|
||||
// Transitions
|
||||
--transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
// Dark theme (default)
|
||||
:root,
|
||||
[data-theme='dark'],
|
||||
.dark {
|
||||
--bg-body: #080b12;
|
||||
--bg-surface: rgba(15, 19, 28, 0.85);
|
||||
--bg-card: rgba(20, 26, 38, 0.7);
|
||||
--bg-card-hover: rgba(28, 35, 50, 0.8);
|
||||
--bg-input: rgba(12, 16, 24, 0.8);
|
||||
--bg-hover: rgba(99, 179, 237, 0.06);
|
||||
--bg-active: rgba(99, 179, 237, 0.12);
|
||||
|
||||
--border-subtle: rgba(255, 255, 255, 0.06);
|
||||
--border-medium: rgba(255, 255, 255, 0.1);
|
||||
--border-focus: rgba(56, 189, 248, 0.5);
|
||||
|
||||
--text-primary: #f1f5f9;
|
||||
--text-secondary: #94a3b8;
|
||||
--text-tertiary: #475569;
|
||||
--text-accent: #7dd3fc;
|
||||
|
||||
--accent: #38bdf8;
|
||||
--accent-hover: #7dd3fc;
|
||||
--accent-subtle: rgba(56, 189, 248, 0.1);
|
||||
--accent-glow: rgba(56, 189, 248, 0.15);
|
||||
|
||||
--color-success: #34d399;
|
||||
--color-warning: #fbbf24;
|
||||
--color-danger: #f87171;
|
||||
|
||||
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||
--shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
--shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.5);
|
||||
--shadow-glow: 0 0 40px rgba(56, 189, 248, 0.08);
|
||||
--shadow-focus: 0 0 0 3px rgba(56, 189, 248, 0.2);
|
||||
|
||||
--glass-bg: rgba(15, 19, 28, 0.75);
|
||||
--glass-border: rgba(255, 255, 255, 0.08);
|
||||
--glass-highlight: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
// Light theme
|
||||
[data-theme='light'],
|
||||
.light {
|
||||
--bg-body: #f8fafc;
|
||||
--bg-surface: rgba(255, 255, 255, 0.85);
|
||||
--bg-card: rgba(255, 255, 255, 0.9);
|
||||
--bg-card-hover: rgba(248, 250, 252, 1);
|
||||
--bg-input: rgba(241, 245, 249, 0.9);
|
||||
--bg-hover: rgba(14, 165, 233, 0.05);
|
||||
--bg-active: rgba(14, 165, 233, 0.1);
|
||||
|
||||
--border-subtle: rgba(0, 0, 0, 0.06);
|
||||
--border-medium: rgba(0, 0, 0, 0.1);
|
||||
--border-focus: rgba(14, 165, 233, 0.5);
|
||||
|
||||
--text-primary: #0f172a;
|
||||
--text-secondary: #64748b;
|
||||
--text-tertiary: #94a3b8;
|
||||
--text-accent: #0284c7;
|
||||
|
||||
--accent: #0ea5e9;
|
||||
--accent-hover: #0284c7;
|
||||
--accent-subtle: rgba(14, 165, 233, 0.08);
|
||||
--accent-glow: rgba(14, 165, 233, 0.1);
|
||||
|
||||
--color-success: #10b981;
|
||||
--color-warning: #f59e0b;
|
||||
--color-danger: #ef4444;
|
||||
|
||||
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
--shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
|
||||
--shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
|
||||
--shadow-glow: 0 0 40px rgba(14, 165, 233, 0.05);
|
||||
--shadow-focus: 0 0 0 3px rgba(14, 165, 233, 0.15);
|
||||
|
||||
--glass-bg: rgba(255, 255, 255, 0.8);
|
||||
--glass-border: rgba(255, 255, 255, 0.6);
|
||||
--glass-highlight: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
// Config styles — now handled via Tailwind + CSS vars in components
|
||||
|
||||
&.active {
|
||||
background: var(--color-primary-subtle);
|
||||
border-color: var(--border-focus);
|
||||
|
||||
.qq-nik {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.qq-avatar {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--color-primary) 0%, #818cf8 100%);
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 2px 8px rgba(14, 165, 233, 0.28);
|
||||
}
|
||||
|
||||
.qq-info {
|
||||
@include flex-col;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.qq-nik {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
transition: color 0.15s;
|
||||
}
|
||||
|
||||
.qq-uin {
|
||||
font-size: 0.72rem;
|
||||
color: var(--text-muted);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
// ---- Editor Pane ----
|
||||
.editor-pane {
|
||||
flex: 1;
|
||||
min-height: 500px;
|
||||
padding: 28px !important;
|
||||
border-radius: var(--radius-lg) !important;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
@include flex-col;
|
||||
@include flex-center;
|
||||
height: 100%;
|
||||
min-height: 380px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
opacity: 0.5;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.editor-header {
|
||||
@include flex-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.editor-title {
|
||||
h2 {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 6px;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-subtitle {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
font-family: var(--font-mono);
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-xs);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.editor-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.save-status {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
padding: 4px 10px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: var(--bg-input);
|
||||
|
||||
&.ok {
|
||||
color: var(--color-success);
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Config Sections ----
|
||||
.editor-sections {
|
||||
@include flex-col;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cfg-section {
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-subtle);
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.cfg-section-header {
|
||||
@include flex-between;
|
||||
padding: 13px 18px;
|
||||
background: var(--bg-input);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
|
||||
h4 {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-main);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.cfg-section-body {
|
||||
@include flex-col;
|
||||
gap: 0;
|
||||
|
||||
.text-muted {
|
||||
padding: 16px 18px;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
}
|
||||
|
||||
.endpoint-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 12px;
|
||||
padding: 14px 18px;
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.endpoint-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
@include flex-col;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
|
||||
label {
|
||||
font-size: 0.73rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
input {
|
||||
background: var(--bg-input);
|
||||
border: 1.5px solid var(--border-subtle);
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-main);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.85rem;
|
||||
transition: var(--transition-fast);
|
||||
outline: none;
|
||||
width: 100%;
|
||||
|
||||
&::placeholder {
|
||||
color: var(--text-placeholder);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border-color: var(--border-focus);
|
||||
box-shadow: var(--shadow-focus);
|
||||
background: var(--bg-card-solid);
|
||||
}
|
||||
|
||||
&[type='number'] {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.card-label {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.card-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
|
||||
&.status-ok {
|
||||
color: #10b981;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Config Layout ----
|
||||
.config-layout {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.list-pane {
|
||||
width: 280px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.pane-title {
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.qq-list {
|
||||
@include flex-col;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.qq-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--bg-hover);
|
||||
border-color: var(--border-active);
|
||||
}
|
||||
}
|
||||
|
||||
.qq-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--color-primary), #818cf8);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.qq-info {
|
||||
@include flex-col;
|
||||
}
|
||||
|
||||
.qq-nik {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.qq-uin {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
// ---- Editor Pane ----
|
||||
.editor-pane {
|
||||
flex: 1;
|
||||
min-height: 500px;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
@include flex-col;
|
||||
@include flex-center;
|
||||
height: 100%;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.editor-header {
|
||||
@include flex-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 32px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.editor-title {
|
||||
h2 {
|
||||
font-size: 1.25rem;
|
||||
color: var(--text-main);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-subtitle {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.editor-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.save-status {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
|
||||
&.ok {
|
||||
color: #10b981;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Config Sections ----
|
||||
.cfg-section {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.cfg-section-header {
|
||||
@include flex-between;
|
||||
margin-bottom: 16px;
|
||||
|
||||
h4 {
|
||||
font-size: 1rem;
|
||||
color: var(--text-main);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.cfg-section-body {
|
||||
@include flex-col;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.endpoint-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 16px;
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.endpoint-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
@include flex-col;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
|
||||
label {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
input {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 8px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-main);
|
||||
font-family: monospace;
|
||||
font-size: 0.85rem;
|
||||
transition: border-color 0.2s;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: var(--border-focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Layout styles — now handled via Tailwind + CSS vars in components
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 12px;
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
@include flex-col;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
// ---- Main Content ----
|
||||
.content {
|
||||
flex: 1;
|
||||
@include flex-col;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 64px;
|
||||
flex-shrink: 0;
|
||||
@include flex-between;
|
||||
padding: 0 32px;
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
-webkit-backdrop-filter: var(--glass-blur);
|
||||
border-bottom: 1px solid var(--glass-border);
|
||||
box-shadow: var(--shadow-xs);
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
@include flex-center;
|
||||
gap: 8px;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.main-scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 28px 32px;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-subtle);
|
||||
border-radius: var(--radius-full);
|
||||
|
||||
&:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
// Shared styles — now handled via Tailwind + CSS vars in components
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(14, 165, 233, 0.28);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-primary-hover);
|
||||
box-shadow: 0 4px 16px rgba(14, 165, 233, 0.38);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--text-muted);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
border-color: var(--border-active);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--color-danger);
|
||||
border-radius: var(--radius-sm);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-danger);
|
||||
border-color: var(--color-danger);
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
padding: 4px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
// ---- Login Screen ----
|
||||
.login-screen {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
background: var(--bg-body);
|
||||
background-image: var(--glass-body-gradient);
|
||||
@include flex-center;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 400px;
|
||||
@include flex-col;
|
||||
align-items: center;
|
||||
padding: 48px 40px;
|
||||
border-radius: var(--radius-xl);
|
||||
background: var(--bg-card);
|
||||
backdrop-filter: blur(20px) saturate(1.8);
|
||||
-webkit-backdrop-filter: blur(20px) saturate(1.8);
|
||||
border: 1px solid var(--glass-border);
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 1.6rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
margin-bottom: 10px;
|
||||
background: linear-gradient(135deg, var(--color-primary) 0%, #818cf8 100%);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.login-desc {
|
||||
font-size: 0.83rem;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.65;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
width: 100%;
|
||||
@include flex-col;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.login-submit-btn {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.login-error {
|
||||
color: var(--color-danger);
|
||||
font-size: 0.8rem;
|
||||
text-align: center;
|
||||
padding: 8px 12px;
|
||||
background: rgba(239, 68, 68, 0.08);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
|
||||
// Search input (header)
|
||||
.search-input {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 8px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-main);
|
||||
width: 260px;
|
||||
font-size: 0.85rem;
|
||||
transition: border-color 0.2s;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
// Generic card
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
// Muted helper
|
||||
.text-muted {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
// ---- Shared Button System ----
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s;
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
|
||||
&:hover { background: var(--color-primary-hover); }
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--text-muted);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-main);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: transparent;
|
||||
border-color: var(--border-subtle);
|
||||
color: var(--color-danger);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-danger);
|
||||
border-color: var(--color-danger);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
padding: 4px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
// ---- Login Screen ----
|
||||
.login-screen {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
background: var(--bg-body);
|
||||
@include flex-center;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 380px;
|
||||
@include flex-col;
|
||||
align-items: center;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 12px;
|
||||
background: linear-gradient(90deg, var(--color-primary), #818cf8);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.login-desc {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
width: 100%;
|
||||
@include flex-col;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.login-submit-btn {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.login-error {
|
||||
color: var(--color-danger);
|
||||
font-size: 0.8rem;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@use 'variables';
|
||||
@use 'mixins';
|
||||
@use 'components/layout';
|
||||
@use 'components/config';
|
||||
@use 'components/shared';
|
||||
@@ -0,0 +1,57 @@
|
||||
export interface QQInfo {
|
||||
uin: string;
|
||||
nickname: string;
|
||||
}
|
||||
|
||||
export interface HookProcessInfo {
|
||||
pid: number;
|
||||
name: string;
|
||||
path: string;
|
||||
injected: boolean;
|
||||
connected: boolean;
|
||||
loggedIn: boolean;
|
||||
uin: string;
|
||||
status: 'available' | 'loading' | 'loaded' | 'online' | 'error' | 'disconnected';
|
||||
error: string;
|
||||
method: string;
|
||||
}
|
||||
|
||||
export interface HttpServerEndpoint {
|
||||
name?: string;
|
||||
host?: string;
|
||||
port?: number;
|
||||
path?: string;
|
||||
accessToken?: string;
|
||||
}
|
||||
|
||||
export interface WsServerEndpoint {
|
||||
name?: string;
|
||||
host?: string;
|
||||
port?: number;
|
||||
path?: string;
|
||||
role?: string;
|
||||
accessToken?: string;
|
||||
}
|
||||
|
||||
export interface WsClientEndpoint {
|
||||
name?: string;
|
||||
url?: string;
|
||||
role?: string;
|
||||
reconnectIntervalMs?: number;
|
||||
accessToken?: string;
|
||||
}
|
||||
|
||||
export interface HttpPostEndpoint {
|
||||
name?: string;
|
||||
url?: string;
|
||||
accessToken?: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
|
||||
export interface OneBotConfig {
|
||||
httpServers: HttpServerEndpoint[];
|
||||
httpPostEndpoints: HttpPostEndpoint[];
|
||||
wsServers: WsServerEndpoint[];
|
||||
wsClients: WsClientEndpoint[];
|
||||
musicSignUrl?: string;
|
||||
}
|
||||
Reference in new issue
Block a user