重构代理池系统:简化架构并增强核心功能
后端变更: - 移除 tasks_manager.py 和 core/auth.py,简化架构 - 新增 core/scheduler.py 验证调度器,替代原有任务管理 - 大幅优化 api_server.py:统一错误处理、增强参数验证、支持调度器控制 - validator.py 增强 SOCKS4/SOCKS5 代理验证支持 - config.py 清理废弃配置(WebSocket、API Key、认证开关) - SQLite 数据库操作性能优化 前端变更: - 移除任务管理页面 (CrawlerTasks) 和 WebSocket 相关代码 - 路由简化为 4 个核心页面:总览、代理列表、插件管理、设置 - 提取前端工具函数(clipboard、confirm、format)和 API 类型定义 - 优化 CSS 架构:完善 variables、utilities、element-plus 样式 - Dashboard、Plugins、ProxyList、Settings 页面 UI/UX 优化 - App.vue 响应式侧边栏和页面过渡动画优化 其他: - 移除 PowerShell 启动脚本,简化 Windows 批处理脚本 - 新增 README_SOCKS.md SOCKS 代理支持文档 - .env.example 和 .gitignore 更新
This commit is contained in:
@@ -1,55 +1,68 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<PageHeader title="插件管理" icon="🔌" />
|
||||
<PageHeader title="插件管理" :icon="Connection" />
|
||||
|
||||
<el-card class="plugins-card" shadow="hover" v-loading="pluginsStore.loading">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="card-title">📦 插件列表</span>
|
||||
<el-button type="primary" @click="handleRefresh" size="large">
|
||||
<span class="btn-icon">🔄</span>
|
||||
刷新列表
|
||||
</el-button>
|
||||
<div class="header-left">
|
||||
<span class="card-title">
|
||||
<el-icon class="header-icon"><Box /></el-icon>
|
||||
插件列表
|
||||
</span>
|
||||
<el-tag v-if="pluginsStore.totalCount > 0" size="small" type="info" class="count-tag">
|
||||
共 {{ pluginsStore.totalCount }} 个
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<el-button type="success" @click="handleCrawlAll" size="large" :loading="crawlingAll">
|
||||
<el-icon class="btn-icon"><Promotion /></el-icon>
|
||||
全部爬取
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleRefresh" size="large">
|
||||
<el-icon class="btn-icon"><Refresh /></el-icon>
|
||||
刷新列表
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table :data="pluginsStore.plugins" stripe>
|
||||
<el-table-column prop="name" label="插件名称" width="200">
|
||||
<el-table :data="pluginsStore.plugins">
|
||||
<el-table-column prop="name" label="插件名称" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="plugin-name">
|
||||
<span class="plugin-icon">🔌</span>
|
||||
<span>{{ row.name }}</span>
|
||||
<el-icon class="plugin-icon"><Connection /></el-icon>
|
||||
<span class="plugin-name-text">{{ row.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="description" label="描述" min-width="200">
|
||||
<el-table-column prop="description" label="描述" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<span class="plugin-description">{{ row.description }}</span>
|
||||
<span class="plugin-description">{{ row.description || '暂无描述' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="状态" width="120">
|
||||
<el-table-column label="状态" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
v-model="row.enabled"
|
||||
@change="(val) => handleToggle(row.id, val)"
|
||||
active-color="#FF6B9D"
|
||||
inactive-color="#dcdfe6"
|
||||
class="theme-switch"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="统计" width="200">
|
||||
<el-table-column label="统计" width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="plugin-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">成功</span>
|
||||
<span class="stat-value success">{{ row.success_count }}</span>
|
||||
<el-icon class="stat-icon success"><CircleCheck /></el-icon>
|
||||
<span class="stat-value success">{{ row.success_count || 0 }}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">失败</span>
|
||||
<span class="stat-value failed">{{ row.failure_count }}</span>
|
||||
<el-icon class="stat-icon failed"><CircleClose /></el-icon>
|
||||
<span class="stat-value failed">{{ row.failure_count || 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -61,49 +74,91 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<el-table-column label="操作" width="150" fixed="right" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleCrawl(row.id)"
|
||||
:loading="crawlingPlugin === row.id"
|
||||
:disabled="!row.enabled"
|
||||
>
|
||||
<span class="btn-icon">🚀</span>
|
||||
立即爬取
|
||||
<el-icon class="btn-icon"><Promotion /></el-icon>
|
||||
爬取
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-empty
|
||||
v-if="pluginsStore.isEmpty"
|
||||
description="暂无插件"
|
||||
:image-size="120"
|
||||
/>
|
||||
|
||||
<!-- 爬取结果提示 -->
|
||||
<el-alert
|
||||
v-if="lastCrawlResult"
|
||||
:title="lastCrawlResult.message"
|
||||
:type="lastCrawlResult.type"
|
||||
closable
|
||||
class="crawl-result"
|
||||
@close="lastCrawlResult = null"
|
||||
>
|
||||
<template v-if="lastCrawlResult.data">
|
||||
<div class="crawl-stats">
|
||||
<span v-if="lastCrawlResult.data.total_crawled !== undefined">
|
||||
爬取: {{ lastCrawlResult.data.total_crawled }}
|
||||
</span>
|
||||
<span v-if="lastCrawlResult.data.proxy_count !== undefined">
|
||||
爬取: {{ lastCrawlResult.data.proxy_count }}
|
||||
</span>
|
||||
<span v-if="lastCrawlResult.data.valid_count !== undefined" class="valid-count">
|
||||
有效: {{ lastCrawlResult.data.valid_count }}
|
||||
</span>
|
||||
<span v-if="lastCrawlResult.data.invalid_count !== undefined" class="invalid-count">
|
||||
无效: {{ lastCrawlResult.data.invalid_count }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
Connection,
|
||||
Refresh,
|
||||
Promotion,
|
||||
CircleCheck,
|
||||
CircleClose,
|
||||
Box
|
||||
} from '@element-plus/icons-vue'
|
||||
import { usePluginsStore } from '../stores/plugins'
|
||||
import { pluginsAPI } from '../api'
|
||||
import { formatTime } from '../utils/format'
|
||||
import PageHeader from '../components/PageHeader.vue'
|
||||
|
||||
const pluginsStore = usePluginsStore()
|
||||
const crawlingPlugin = ref(null)
|
||||
const crawlingAll = ref(false)
|
||||
const lastCrawlResult = ref(null)
|
||||
|
||||
function formatTime(timeStr) {
|
||||
if (!timeStr) return '从未运行'
|
||||
const date = new Date(timeStr)
|
||||
return date.toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
// ==================== 事件处理 ====================
|
||||
async function handleRefresh() {
|
||||
await pluginsStore.fetchPlugins()
|
||||
ElMessage.success('插件列表已刷新~')
|
||||
ElMessage.success('插件列表已刷新')
|
||||
}
|
||||
|
||||
async function handleToggle(pluginId, enabled) {
|
||||
const success = await pluginsStore.togglePlugin(pluginId, enabled)
|
||||
if (success) {
|
||||
ElMessage.success(enabled ? '插件已启用~' : '插件已禁用~')
|
||||
ElMessage.success(enabled ? '插件已启用' : '插件已禁用')
|
||||
} else {
|
||||
// 失败时刷新列表恢复状态
|
||||
await pluginsStore.fetchPlugins()
|
||||
}
|
||||
}
|
||||
@@ -111,15 +166,87 @@ async function handleToggle(pluginId, enabled) {
|
||||
async function handleCrawl(pluginId) {
|
||||
try {
|
||||
crawlingPlugin.value = pluginId
|
||||
const success = await pluginsStore.crawlPlugin(pluginId)
|
||||
if (success) {
|
||||
ElMessage.success('插件开始爬取啦~')
|
||||
lastCrawlResult.value = null
|
||||
|
||||
const response = await pluginsAPI.crawlPlugin(pluginId)
|
||||
|
||||
if (response.code === 200) {
|
||||
lastCrawlResult.value = {
|
||||
type: 'success',
|
||||
message: response.message,
|
||||
data: response.data
|
||||
}
|
||||
// 刷新插件统计
|
||||
await pluginsStore.fetchPlugins()
|
||||
} else {
|
||||
lastCrawlResult.value = {
|
||||
type: 'error',
|
||||
message: response.message || '爬取失败'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
lastCrawlResult.value = {
|
||||
type: 'error',
|
||||
message: '爬取过程出错'
|
||||
}
|
||||
} finally {
|
||||
crawlingPlugin.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCrawlAll() {
|
||||
try {
|
||||
// 确认是否爬取所有插件
|
||||
const enabledPlugins = pluginsStore.plugins.filter(p => p.enabled)
|
||||
if (enabledPlugins.length === 0) {
|
||||
ElMessage.warning('没有启用的插件')
|
||||
return
|
||||
}
|
||||
|
||||
await ElMessageBox.confirm(
|
||||
`确定要运行所有 ${enabledPlugins.length} 个启用的插件吗?这将爬取并验证所有代理。`,
|
||||
'批量爬取确认',
|
||||
{
|
||||
confirmButtonText: '开始爬取',
|
||||
cancelButtonText: '取消',
|
||||
type: 'info'
|
||||
}
|
||||
)
|
||||
|
||||
crawlingAll.value = true
|
||||
lastCrawlResult.value = null
|
||||
|
||||
const response = await pluginsAPI.crawlAll()
|
||||
|
||||
if (response.code === 200) {
|
||||
lastCrawlResult.value = {
|
||||
type: 'success',
|
||||
message: response.message,
|
||||
data: response.data
|
||||
}
|
||||
ElMessage.success('批量爬取完成')
|
||||
// 刷新插件统计
|
||||
await pluginsStore.fetchPlugins()
|
||||
} else {
|
||||
lastCrawlResult.value = {
|
||||
type: 'error',
|
||||
message: response.message || '批量爬取失败'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('批量爬取失败:', error)
|
||||
lastCrawlResult.value = {
|
||||
type: 'error',
|
||||
message: '批量爬取过程出错'
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
crawlingAll.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 生命周期 ====================
|
||||
onMounted(async () => {
|
||||
await pluginsStore.fetchPlugins()
|
||||
})
|
||||
@@ -127,21 +254,41 @@ onMounted(async () => {
|
||||
|
||||
<style scoped>
|
||||
.plugins-card {
|
||||
border-radius: var(--radius-xl);
|
||||
border-radius: var(--radius-lg);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
.plugins-card:hover {
|
||||
border-color: var(--border-light);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
margin-right: 8px;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.count-tag {
|
||||
background: var(--surface-2) !important;
|
||||
border-color: var(--border) !important;
|
||||
color: var(--text-muted) !important;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.plugin-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -149,12 +296,22 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.plugin-icon {
|
||||
font-size: 20px;
|
||||
color: var(--primary);
|
||||
filter: drop-shadow(0 0 6px rgba(146, 124, 255, 0.3));
|
||||
}
|
||||
|
||||
.plugin-name-text {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.plugin-description {
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.plugin-stats {
|
||||
@@ -164,13 +321,20 @@ onMounted(async () => {
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
.stat-icon {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stat-icon.success {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.stat-icon.failed {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
@@ -179,7 +343,7 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.stat-value.success {
|
||||
color: var(--green);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.stat-value.failed {
|
||||
@@ -187,12 +351,26 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.last-run {
|
||||
color: var(--text-secondary);
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
font-size: 20px;
|
||||
margin-right: 4px;
|
||||
.crawl-result {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.crawl-stats {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.valid-count {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.invalid-count {
|
||||
color: var(--danger);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user