first commit
This commit is contained in:
+586
@@ -0,0 +1,586 @@
|
||||
/**
|
||||
* 小红书采集器前端逻辑
|
||||
*/
|
||||
|
||||
// ========== 状态管理 ==========
|
||||
const state = {
|
||||
isRunning: false,
|
||||
mode: 'single',
|
||||
maxThreads: 3,
|
||||
totalUsers: 0,
|
||||
completedUsers: 0,
|
||||
failedUsers: 0,
|
||||
activeThreads: 0,
|
||||
usersStatus: {},
|
||||
threadStatus: {},
|
||||
eventSource: null,
|
||||
autoScrollLogs: true,
|
||||
logFilter: 'all',
|
||||
logs: []
|
||||
};
|
||||
|
||||
// ========== DOM 元素 ==========
|
||||
const elements = {
|
||||
startBtn: null,
|
||||
stopBtn: null,
|
||||
clearLogsBtn: null,
|
||||
exportDataBtn: null,
|
||||
themeToggle: null,
|
||||
themeIcon: null,
|
||||
modeRadios: null,
|
||||
threadControl: null,
|
||||
threadCount: null,
|
||||
progressBar: null,
|
||||
progressText: null,
|
||||
totalUsers: null,
|
||||
completedUsers: null,
|
||||
failedUsers: null,
|
||||
activeThreadsStat: null,
|
||||
activeThreads: null,
|
||||
userList: null,
|
||||
userCount: null,
|
||||
threadMonitorPanel: null,
|
||||
threadList: null,
|
||||
logContainer: null,
|
||||
logFilter: null,
|
||||
logSearch: null,
|
||||
screenshotPanel: null,
|
||||
screenshotImage: null,
|
||||
closeScreenshot: null
|
||||
};
|
||||
|
||||
// ========== 初始化 ==========
|
||||
function init() {
|
||||
// 获取 DOM 元素
|
||||
elements.startBtn = document.getElementById('startBtn');
|
||||
elements.stopBtn = document.getElementById('stopBtn');
|
||||
elements.clearLogsBtn = document.getElementById('clearLogsBtn');
|
||||
elements.exportDataBtn = document.getElementById('exportDataBtn');
|
||||
elements.themeToggle = document.getElementById('themeToggle');
|
||||
elements.themeIcon = document.getElementById('themeIcon');
|
||||
elements.modeRadios = document.querySelectorAll('input[name="mode"]');
|
||||
elements.threadControl = document.getElementById('threadControl');
|
||||
elements.threadCount = document.getElementById('threadCount');
|
||||
elements.progressBar = document.getElementById('progressBar');
|
||||
elements.progressText = document.getElementById('progressText');
|
||||
elements.totalUsers = document.getElementById('totalUsers');
|
||||
elements.completedUsers = document.getElementById('completedUsers');
|
||||
elements.failedUsers = document.getElementById('failedUsers');
|
||||
elements.activeThreadsStat = document.getElementById('activeThreadsStat');
|
||||
elements.activeThreads = document.getElementById('activeThreads');
|
||||
elements.userList = document.getElementById('userList');
|
||||
elements.userCount = document.getElementById('userCount');
|
||||
elements.threadMonitorPanel = document.getElementById('threadMonitorPanel');
|
||||
elements.threadList = document.getElementById('threadList');
|
||||
elements.logContainer = document.getElementById('logContainer');
|
||||
elements.logFilter = document.getElementById('logFilter');
|
||||
elements.logSearch = document.getElementById('logSearch');
|
||||
elements.screenshotPanel = document.getElementById('screenshotPanel');
|
||||
elements.screenshotImage = document.getElementById('screenshotImage');
|
||||
elements.closeScreenshot = document.getElementById('closeScreenshot');
|
||||
|
||||
// 加载主题
|
||||
loadTheme();
|
||||
|
||||
// 加载初始数据
|
||||
loadInitialData();
|
||||
|
||||
// 绑定事件
|
||||
bindEvents();
|
||||
|
||||
// 连接 SSE
|
||||
connectEventStream();
|
||||
}
|
||||
|
||||
// ========== 事件绑定 ==========
|
||||
function bindEvents() {
|
||||
// 启动按钮
|
||||
elements.startBtn.addEventListener('click', startScraping);
|
||||
|
||||
// 停止按钮
|
||||
elements.stopBtn.addEventListener('click', stopScraping);
|
||||
|
||||
// 清空日志
|
||||
elements.clearLogsBtn.addEventListener('click', clearLogs);
|
||||
|
||||
// 导出数据
|
||||
elements.exportDataBtn.addEventListener('click', exportData);
|
||||
|
||||
// 主题切换
|
||||
elements.themeToggle.addEventListener('click', toggleTheme);
|
||||
|
||||
// 模式切换
|
||||
elements.modeRadios.forEach(radio => {
|
||||
radio.addEventListener('change', (e) => {
|
||||
state.mode = e.target.value;
|
||||
updateModeUI();
|
||||
});
|
||||
});
|
||||
|
||||
// 线程数变化
|
||||
elements.threadCount.addEventListener('change', (e) => {
|
||||
state.maxThreads = parseInt(e.target.value);
|
||||
});
|
||||
|
||||
// 日志过滤
|
||||
elements.logFilter.addEventListener('change', (e) => {
|
||||
state.logFilter = e.target.value;
|
||||
renderLogs();
|
||||
});
|
||||
|
||||
// 日志搜索
|
||||
elements.logSearch.addEventListener('input', debounce((e) => {
|
||||
searchLogs(e.target.value);
|
||||
}, 300));
|
||||
|
||||
// 关闭截图
|
||||
elements.closeScreenshot.addEventListener('click', () => {
|
||||
elements.screenshotPanel.style.display = 'none';
|
||||
});
|
||||
|
||||
// 日志容器滚动监听(自动滚动控制)
|
||||
elements.logContainer.addEventListener('scroll', () => {
|
||||
const { scrollTop, scrollHeight, clientHeight } = elements.logContainer;
|
||||
state.autoScrollLogs = scrollTop + clientHeight >= scrollHeight - 10;
|
||||
});
|
||||
}
|
||||
|
||||
// ========== 加载初始数据 ==========
|
||||
async function loadInitialData() {
|
||||
try {
|
||||
// 加载状态
|
||||
const statusRes = await fetch('/api/status');
|
||||
const statusData = await statusRes.json();
|
||||
updateStatus(statusData);
|
||||
|
||||
// 加载用户列表
|
||||
const usersRes = await fetch('/api/users');
|
||||
const usersData = await usersRes.json();
|
||||
renderUserList(usersData.users);
|
||||
|
||||
// 加载历史日志
|
||||
const logsRes = await fetch('/api/logs?limit=100');
|
||||
const logsData = await logsRes.json();
|
||||
state.logs = logsData.logs;
|
||||
renderLogs();
|
||||
|
||||
} catch (error) {
|
||||
console.error('加载初始数据失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 启动采集 ==========
|
||||
async function startScraping() {
|
||||
try {
|
||||
const response = await fetch('/api/start', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
mode: state.mode,
|
||||
max_threads: state.maxThreads
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
state.isRunning = true;
|
||||
updateButtons();
|
||||
addLog('SUCCESS', data.message);
|
||||
} else {
|
||||
addLog('ERROR', data.detail || '启动失败');
|
||||
}
|
||||
} catch (error) {
|
||||
addLog('ERROR', `启动失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 停止采集 ==========
|
||||
async function stopScraping() {
|
||||
try {
|
||||
const response = await fetch('/api/stop', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
state.isRunning = false;
|
||||
updateButtons();
|
||||
addLog('WARNING', data.message);
|
||||
}
|
||||
} catch (error) {
|
||||
addLog('ERROR', `停止失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 清空日志 ==========
|
||||
async function clearLogs() {
|
||||
try {
|
||||
const response = await fetch('/api/logs/clear', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
state.logs = [];
|
||||
renderLogs();
|
||||
addLog('SUCCESS', '日志已清空');
|
||||
}
|
||||
} catch (error) {
|
||||
addLog('ERROR', `清空日志失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 导出数据 ==========
|
||||
async function exportData() {
|
||||
try {
|
||||
// 下载日志
|
||||
window.location.href = '/api/logs/download';
|
||||
addLog('SUCCESS', '正在下载日志文件...');
|
||||
} catch (error) {
|
||||
addLog('ERROR', `导出失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 搜索日志 ==========
|
||||
async function searchLogs(keyword) {
|
||||
if (!keyword) {
|
||||
// 加载所有日志
|
||||
const logsRes = await fetch('/api/logs?limit=100');
|
||||
const logsData = await logsRes.json();
|
||||
state.logs = logsData.logs;
|
||||
} else {
|
||||
// 搜索日志
|
||||
const searchRes = await fetch(`/api/logs/search?keyword=${encodeURIComponent(keyword)}&limit=100`);
|
||||
const searchData = await searchRes.json();
|
||||
state.logs = searchData.logs;
|
||||
}
|
||||
renderLogs();
|
||||
}
|
||||
|
||||
// ========== SSE 事件流 ==========
|
||||
function connectEventStream() {
|
||||
if (state.eventSource) {
|
||||
state.eventSource.close();
|
||||
}
|
||||
|
||||
state.eventSource = new EventSource('/api/events');
|
||||
|
||||
state.eventSource.onmessage = (event) => {
|
||||
if (event.data.startsWith(': heartbeat')) {
|
||||
return; // 忽略心跳
|
||||
}
|
||||
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
handleEvent(data);
|
||||
} catch (error) {
|
||||
console.error('解析事件失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
state.eventSource.onerror = (error) => {
|
||||
console.error('SSE 连接错误:', error);
|
||||
// 5秒后重连
|
||||
setTimeout(() => {
|
||||
if (!state.eventSource || state.eventSource.readyState === EventSource.CLOSED) {
|
||||
connectEventStream();
|
||||
}
|
||||
}, 5000);
|
||||
};
|
||||
}
|
||||
|
||||
// ========== 处理事件 ==========
|
||||
function handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case 'log':
|
||||
addLog(event.level, event.message, event.thread_id, event.timestamp, false);
|
||||
break;
|
||||
|
||||
case 'progress':
|
||||
updateProgress(event);
|
||||
break;
|
||||
|
||||
case 'user_status':
|
||||
updateUserStatus(event);
|
||||
break;
|
||||
|
||||
case 'thread_status':
|
||||
updateThreadStatus(event);
|
||||
break;
|
||||
|
||||
case 'screenshot':
|
||||
showScreenshot(event.path);
|
||||
break;
|
||||
|
||||
case 'finished':
|
||||
state.isRunning = false;
|
||||
updateButtons();
|
||||
addLog('SUCCESS', '所有采集任务完成');
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
addLog('ERROR', event.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 更新状态 ==========
|
||||
function updateStatus(data) {
|
||||
state.isRunning = data.is_running;
|
||||
state.totalUsers = data.total_users;
|
||||
state.completedUsers = data.completed_users;
|
||||
state.failedUsers = data.failed_users;
|
||||
state.activeThreads = data.active_threads;
|
||||
state.usersStatus = data.users_status || {};
|
||||
|
||||
updateButtons();
|
||||
updateProgress();
|
||||
renderUserListFromStatus();
|
||||
}
|
||||
|
||||
// ========== 更新进度 ==========
|
||||
function updateProgress(data) {
|
||||
if (data) {
|
||||
state.completedUsers = data.completed || state.completedUsers;
|
||||
state.failedUsers = data.failed || state.failedUsers;
|
||||
state.activeThreads = data.active_threads || state.activeThreads;
|
||||
}
|
||||
|
||||
const total = state.totalUsers;
|
||||
const completed = state.completedUsers;
|
||||
const failed = state.failedUsers;
|
||||
const progress = total > 0 ? Math.round(((completed + failed) / total) * 100) : 0;
|
||||
|
||||
elements.progressBar.style.width = `${progress}%`;
|
||||
elements.progressText.textContent = `${progress}%`;
|
||||
elements.totalUsers.textContent = total;
|
||||
elements.completedUsers.textContent = completed;
|
||||
elements.failedUsers.textContent = failed;
|
||||
elements.activeThreads.textContent = state.activeThreads;
|
||||
|
||||
// 多线程模式显示活跃线程
|
||||
if (state.mode === 'multi') {
|
||||
elements.activeThreadsStat.style.display = 'flex';
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 更新用户状态 ==========
|
||||
function updateUserStatus(data) {
|
||||
state.usersStatus[data.user_id] = {
|
||||
status: data.status,
|
||||
note_count: data.note_count,
|
||||
thread_id: data.thread_id
|
||||
};
|
||||
|
||||
renderUserListFromStatus();
|
||||
}
|
||||
|
||||
// ========== 更新线程状态 ==========
|
||||
function updateThreadStatus(data) {
|
||||
state.threadStatus[data.thread_id] = {
|
||||
status: data.status,
|
||||
current_user: data.current_user
|
||||
};
|
||||
|
||||
renderThreadList();
|
||||
}
|
||||
|
||||
// ========== 渲染用户列表 ==========
|
||||
function renderUserList(users) {
|
||||
if (!users || users.length === 0) {
|
||||
elements.userList.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<p>暂无用户数据</p>
|
||||
<p class="hint">请在 data/users.txt 中添加用户 ID</p>
|
||||
</div>
|
||||
`;
|
||||
elements.userCount.textContent = '0';
|
||||
return;
|
||||
}
|
||||
|
||||
elements.userCount.textContent = users.length;
|
||||
|
||||
elements.userList.innerHTML = users.map(user => {
|
||||
const status = user.status || 'pending';
|
||||
const noteCount = user.note_count || 0;
|
||||
|
||||
return `
|
||||
<div class="user-item" data-user-id="${user.id}">
|
||||
<div class="user-item-header">
|
||||
<span class="user-id">${user.id}</span>
|
||||
<div class="user-status">
|
||||
<span class="status-icon status-${status}"></span>
|
||||
<span>${getStatusText(status)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-meta">
|
||||
${noteCount > 0 ? `已采集 ${noteCount} 条笔记` : '等待采集'}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
// ========== 从状态渲染用户列表 ==========
|
||||
function renderUserListFromStatus() {
|
||||
const users = Object.keys(state.usersStatus).map(userId => ({
|
||||
id: userId,
|
||||
...state.usersStatus[userId]
|
||||
}));
|
||||
|
||||
renderUserList(users);
|
||||
}
|
||||
|
||||
// ========== 渲染线程列表 ==========
|
||||
function renderThreadList() {
|
||||
const threads = Object.entries(state.threadStatus);
|
||||
|
||||
if (threads.length === 0) {
|
||||
elements.threadList.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<p>暂无线程活动</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
elements.threadList.innerHTML = threads.map(([threadId, status]) => {
|
||||
const statusClass = status.status;
|
||||
const statusText = status.status === 'busy' ? '处理中' :
|
||||
status.status === 'idle' ? '空闲' : '错误';
|
||||
const currentUser = status.current_user || '-';
|
||||
|
||||
return `
|
||||
<div class="thread-item">
|
||||
<div class="thread-header">
|
||||
<span class="thread-name">${threadId}</span>
|
||||
<span class="thread-status ${statusClass}">${statusText}</span>
|
||||
</div>
|
||||
<div class="thread-current">${currentUser}</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
// ========== 添加日志 ==========
|
||||
function addLog(level, message, threadId = null, timestamp = null, save = true) {
|
||||
const logEntry = {
|
||||
timestamp: timestamp || new Date().toISOString(),
|
||||
level,
|
||||
message,
|
||||
thread_id: threadId
|
||||
};
|
||||
|
||||
state.logs.push(logEntry);
|
||||
|
||||
// 限制日志数量
|
||||
if (state.logs.length > 1000) {
|
||||
state.logs = state.logs.slice(-1000);
|
||||
}
|
||||
|
||||
renderLogs();
|
||||
}
|
||||
|
||||
// ========== 渲染日志 ==========
|
||||
function renderLogs() {
|
||||
let logs = state.logs;
|
||||
|
||||
// 过滤
|
||||
if (state.logFilter !== 'all') {
|
||||
logs = logs.filter(log => log.level === state.logFilter);
|
||||
}
|
||||
|
||||
elements.logContainer.innerHTML = logs.map(log => {
|
||||
const time = formatTime(log.timestamp);
|
||||
const thread = log.thread_id ? `<span class="log-thread">[${log.thread_id}]</span>` : '';
|
||||
|
||||
return `
|
||||
<div class="log-entry">
|
||||
<span class="log-time">${time}</span>
|
||||
<span class="log-level ${log.level}">${log.level}</span>
|
||||
<span class="log-message">${thread}${escapeHtml(log.message)}</span>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// 自动滚动到底部
|
||||
if (state.autoScrollLogs) {
|
||||
elements.logContainer.scrollTop = elements.logContainer.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 显示截图 ==========
|
||||
function showScreenshot(path) {
|
||||
elements.screenshotImage.src = path;
|
||||
elements.screenshotPanel.style.display = 'block';
|
||||
addLog('WARNING', `错误截图已生成: ${path}`);
|
||||
}
|
||||
|
||||
// ========== 更新按钮状态 ==========
|
||||
function updateButtons() {
|
||||
elements.startBtn.disabled = state.isRunning;
|
||||
elements.stopBtn.disabled = !state.isRunning;
|
||||
}
|
||||
|
||||
// ========== 更新模式 UI ==========
|
||||
function updateModeUI() {
|
||||
if (state.mode === 'multi') {
|
||||
elements.threadControl.style.display = 'flex';
|
||||
elements.threadMonitorPanel.style.display = 'block';
|
||||
document.querySelector('.main-content').classList.add('with-threads');
|
||||
} else {
|
||||
elements.threadControl.style.display = 'none';
|
||||
elements.threadMonitorPanel.style.display = 'none';
|
||||
document.querySelector('.main-content').classList.remove('with-threads');
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 主题相关 ==========
|
||||
function loadTheme() {
|
||||
const savedTheme = localStorage.getItem('theme') || 'light';
|
||||
if (savedTheme === 'dark') {
|
||||
document.body.classList.add('dark-theme');
|
||||
elements.themeIcon.textContent = '☀️';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
document.body.classList.toggle('dark-theme');
|
||||
const isDark = document.body.classList.contains('dark-theme');
|
||||
elements.themeIcon.textContent = isDark ? '☀️' : '🌙';
|
||||
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
||||
}
|
||||
|
||||
// ========== 工具函数 ==========
|
||||
function formatTime(isoString) {
|
||||
const date = new Date(isoString);
|
||||
return date.toLocaleTimeString('zh-CN', { hour12: false });
|
||||
}
|
||||
|
||||
function getStatusText(status) {
|
||||
const statusMap = {
|
||||
'pending': '待处理',
|
||||
'processing': '进行中',
|
||||
'completed': '已完成',
|
||||
'failed': '失败'
|
||||
};
|
||||
return statusMap[status] || status;
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function executedFunction(...args) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
|
||||
// ========== 启动 ==========
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
@@ -0,0 +1,620 @@
|
||||
/* 小红书采集器样式表 */
|
||||
|
||||
/* ========== CSS 变量 ========== */
|
||||
:root {
|
||||
--bg-primary: #f5f7fa;
|
||||
--bg-secondary: #ffffff;
|
||||
--bg-tertiary: #e8ecf1;
|
||||
--text-primary: #2c3e50;
|
||||
--text-secondary: #5a6c7d;
|
||||
--text-muted: #8b95a5;
|
||||
--border-color: #d1d9e6;
|
||||
--primary-color: #ff2442; /* 小红书红 */
|
||||
--primary-hover: #e01f3a;
|
||||
--success-color: #10b981;
|
||||
--warning-color: #f59e0b;
|
||||
--error-color: #ef4444;
|
||||
--info-color: #3b82f6;
|
||||
--debug-color: #8b95a5;
|
||||
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
||||
--radius-sm: 4px;
|
||||
--radius-md: 8px;
|
||||
--radius-lg: 12px;
|
||||
}
|
||||
|
||||
/* 深色主题 */
|
||||
body.dark-theme {
|
||||
--bg-primary: #1a1d23;
|
||||
--bg-secondary: #242830;
|
||||
--bg-tertiary: #2d333d;
|
||||
--text-primary: #e8eaed;
|
||||
--text-secondary: #9aa0a6;
|
||||
--text-muted: #5f6368;
|
||||
--border-color: #3c4043;
|
||||
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* ========== 基础重置 ========== */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.5;
|
||||
transition: background 0.3s, color 0.3s;
|
||||
}
|
||||
|
||||
/* ========== 布局 ========== */
|
||||
.container {
|
||||
max-width: 1600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ========== 头部 ========== */
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
padding: 20px;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.theme-toggle {
|
||||
background: var(--bg-tertiary);
|
||||
border: none;
|
||||
padding: 10px 16px;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
font-size: 20px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
background: var(--border-color);
|
||||
}
|
||||
|
||||
/* ========== 控制面板 ========== */
|
||||
.control-panel {
|
||||
background: var(--bg-secondary);
|
||||
padding: 20px;
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.control-group {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.control-group:not(:last-child) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/* ========== 按钮 ========== */
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: var(--primary-hover);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: var(--error-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: #dc2626;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--border-color);
|
||||
}
|
||||
|
||||
.btn-small {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* ========== 单选按钮组 ========== */
|
||||
.radio-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.label-text {
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.radio-group label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.radio-group input[type="radio"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ========== 下拉选择 ========== */
|
||||
.select, .select-small {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.select-small {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ========== 输入框 ========== */
|
||||
.input-small {
|
||||
padding: 4px 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
font-size: 12px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
/* ========== 线程控制 ========== */
|
||||
.thread-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.thread-control label {
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* ========== 进度卡片 ========== */
|
||||
.progress-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.progress-card {
|
||||
background: var(--bg-secondary);
|
||||
padding: 20px;
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.progress-card h3 {
|
||||
margin-bottom: 16px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 24px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--primary-color), #ff6b8a);
|
||||
border-radius: var(--radius-md);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: width 0.3s ease;
|
||||
min-width: 40px;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.progress-stats {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.stat-success {
|
||||
color: var(--success-color);
|
||||
}
|
||||
|
||||
.stat-error {
|
||||
color: var(--error-color);
|
||||
}
|
||||
|
||||
.stat-info {
|
||||
color: var(--info-color);
|
||||
}
|
||||
|
||||
/* ========== 主内容区 ========== */
|
||||
.main-content {
|
||||
display: grid;
|
||||
grid-template-columns: 300px 1fr;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.main-content.with-threads {
|
||||
grid-template-columns: 300px 250px 1fr;
|
||||
}
|
||||
|
||||
/* ========== 面板 ========== */
|
||||
.panel {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.panel-header h2 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
/* ========== 用户列表 ========== */
|
||||
.user-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.user-item {
|
||||
padding: 12px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.user-item:hover {
|
||||
background: var(--border-color);
|
||||
}
|
||||
|
||||
.user-item-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.user-id {
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.user-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.status-pending { background: var(--text-muted); }
|
||||
.status-processing { background: var(--info-color); }
|
||||
.status-completed { background: var(--success-color); }
|
||||
.status-failed { background: var(--error-color); }
|
||||
|
||||
.user-meta {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* ========== 线程监控 ========== */
|
||||
.thread-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.thread-item {
|
||||
padding: 12px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.thread-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.thread-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.thread-status {
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.thread-status.busy {
|
||||
background: var(--info-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.thread-status.error {
|
||||
background: var(--error-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.thread-current {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
/* ========== 日志面板 ========== */
|
||||
.log-controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.log-container {
|
||||
font-family: 'Consolas', 'Monaco', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.log-entry {
|
||||
padding: 6px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.log-entry:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.log-time {
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.log-level {
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
padding: 0 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 11px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-level.INFO {
|
||||
background: rgba(59, 130, 246, 0.15);
|
||||
color: var(--info-color);
|
||||
}
|
||||
|
||||
.log-level.SUCCESS {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: var(--success-color);
|
||||
}
|
||||
|
||||
.log-level.WARNING {
|
||||
background: rgba(245, 158, 11, 0.15);
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
.log-level.ERROR {
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: var(--error-color);
|
||||
}
|
||||
|
||||
.log-level.DEBUG {
|
||||
background: rgba(139, 149, 165, 0.15);
|
||||
color: var(--debug-color);
|
||||
}
|
||||
|
||||
.log-message {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.log-thread {
|
||||
color: var(--primary-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ========== 截图面板 ========== */
|
||||
.screenshot-panel {
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
overflow: hidden;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.screenshot-panel img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ========== 滚动条样式 ========== */
|
||||
.panel-body::-webkit-scrollbar,
|
||||
.log-container::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.panel-body::-webkit-scrollbar-track,
|
||||
.log-container::-webkit-scrollbar-track {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.panel-body::-webkit-scrollbar-thumb,
|
||||
.log-container::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.panel-body::-webkit-scrollbar-thumb:hover,
|
||||
.log-container::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ========== 响应式 ========== */
|
||||
@media (max-width: 1200px) {
|
||||
.main-content {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.main-content.with-threads {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.thread-monitor-panel {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.control-group {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.progress-stats {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user