- 完成前端基础设施:路由、API 封装、状态管理、布局组件 - 实现 LLM 配置管理:增删改查、启用禁用 - 实现数据源管理:支持 RSS/API/爬虫三种类型 - 实现推送渠道管理:支持邮件/钉钉/企业微信/Slack - 实现主题管理:关联数据源、渠道、LLM 配置 - 实现报告中心、资讯浏览、采集监控页面 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
277 lines
7.2 KiB
Vue
277 lines
7.2 KiB
Vue
<template>
|
|
<div class="dashboard">
|
|
<el-row :gutter="20">
|
|
<el-col :span="6">
|
|
<el-card shadow="hover">
|
|
<div class="stat-item">
|
|
<el-icon class="stat-icon" :size="40" color="#409eff"><Connection /></el-icon>
|
|
<div class="stat-info">
|
|
<div class="stat-value">{{ stats.sources }}</div>
|
|
<div class="stat-label">数据源</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
|
|
<el-col :span="6">
|
|
<el-card shadow="hover">
|
|
<div class="stat-item">
|
|
<el-icon class="stat-icon" :size="40" color="#67c23a"><Collection /></el-icon>
|
|
<div class="stat-info">
|
|
<div class="stat-value">{{ stats.topics }}</div>
|
|
<div class="stat-label">主题</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
|
|
<el-col :span="6">
|
|
<el-card shadow="hover">
|
|
<div class="stat-item">
|
|
<el-icon class="stat-icon" :size="40" color="#e6a23c"><Document /></el-icon>
|
|
<div class="stat-info">
|
|
<div class="stat-value">{{ stats.reports }}</div>
|
|
<div class="stat-label">报告</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
|
|
<el-col :span="6">
|
|
<el-card shadow="hover">
|
|
<div class="stat-item">
|
|
<el-icon class="stat-icon" :size="40" color="#f56c6c"><Reading /></el-icon>
|
|
<div class="stat-info">
|
|
<div class="stat-value">{{ stats.articles }}</div>
|
|
<div class="stat-label">资讯</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-row :gutter="20" style="margin-top: 20px">
|
|
<el-col :span="12">
|
|
<el-card>
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span>最近报告</span>
|
|
<el-button type="primary" link @click="$router.push('/reports')">
|
|
查看更多
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
<el-empty v-if="recentReports.length === 0" description="暂无报告" />
|
|
<div v-else class="report-list">
|
|
<div
|
|
v-for="report in recentReports"
|
|
:key="report.id"
|
|
class="report-item"
|
|
@click="$router.push(`/reports/${report.id}`)"
|
|
>
|
|
<div class="report-title">{{ report.title }}</div>
|
|
<div class="report-meta">
|
|
<el-tag :type="getStatusType(report.status)" size="small">
|
|
{{ getStatusText(report.status) }}
|
|
</el-tag>
|
|
<span class="report-time">
|
|
{{ formatTime(report.createdAt) }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
|
|
<el-col :span="12">
|
|
<el-card>
|
|
<template #header>
|
|
<div class="card-header">
|
|
<span>采集状态</span>
|
|
<el-button type="primary" link @click="$router.push('/monitoring')">
|
|
查看详情
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
<el-empty v-if="collectionStats.length === 0" description="暂无数据" />
|
|
<div v-else class="collection-list">
|
|
<div
|
|
v-for="stat in collectionStats"
|
|
:key="stat.id"
|
|
class="collection-item"
|
|
>
|
|
<div class="collection-name">{{ stat.name }}</div>
|
|
<div class="collection-meta">
|
|
<el-tag
|
|
:type="stat.lastLog?.status === 'success' ? 'success' : (stat.lastLog ? 'danger' : 'info')"
|
|
size="small"
|
|
>
|
|
{{ stat.lastLog?.status === 'success' ? '成功' : (stat.lastLog ? '失败' : '未采集') }}
|
|
</el-tag>
|
|
<span class="collection-time">
|
|
{{ stat.lastCollectedAt ? formatTime(stat.lastCollectedAt) : '从未采集' }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
</el-col>
|
|
</el-row>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, onMounted } from 'vue'
|
|
import { Connection, Collection, Document, Reading } from '@element-plus/icons-vue'
|
|
import request from '@/api/request'
|
|
import type { Report, CollectionStats } from '@/api/types'
|
|
|
|
const stats = ref({
|
|
sources: 0,
|
|
topics: 0,
|
|
reports: 0,
|
|
articles: 0,
|
|
})
|
|
|
|
const recentReports = ref<Report[]>([])
|
|
const collectionStats = ref<CollectionStats[]>([])
|
|
|
|
const loadStats = async () => {
|
|
try {
|
|
const [sourcesRes, topicsRes, reportsRes, articlesRes] = await Promise.all([
|
|
request.get('/sources', { params: { limit: 1 } }),
|
|
request.get('/topics', { params: { limit: 1 } }),
|
|
request.get('/reports', { params: { limit: 1 } }),
|
|
request.get('/articles', { params: { limit: 1 } }),
|
|
])
|
|
|
|
stats.value = {
|
|
sources: sourcesRes.pagination?.total || 0,
|
|
topics: topicsRes.pagination?.total || 0,
|
|
reports: reportsRes.pagination?.total || 0,
|
|
articles: articlesRes.pagination?.total || 0,
|
|
}
|
|
} catch (error) {
|
|
console.error('加载统计数据失败', error)
|
|
}
|
|
}
|
|
|
|
const loadRecentReports = async () => {
|
|
try {
|
|
const res = await request.get('/reports', { params: { limit: 5 } })
|
|
recentReports.value = res.data || []
|
|
} catch (error) {
|
|
console.error('加载最近报告失败', error)
|
|
}
|
|
}
|
|
|
|
const loadCollectionStats = async () => {
|
|
try {
|
|
const res = await request.get('/collection-logs/stats')
|
|
collectionStats.value = (res.data || []).slice(0, 5)
|
|
} catch (error) {
|
|
console.error('加载采集状态失败', error)
|
|
}
|
|
}
|
|
|
|
const getStatusType = (status: string) => {
|
|
const map: Record<string, 'info' | 'warning' | 'success' | 'danger'> = {
|
|
pending: 'info',
|
|
generating: 'warning',
|
|
completed: 'success',
|
|
failed: 'danger',
|
|
}
|
|
return map[status] || 'info'
|
|
}
|
|
|
|
const getStatusText = (status: string) => {
|
|
const map: Record<string, string> = {
|
|
pending: '待处理',
|
|
generating: '生成中',
|
|
completed: '已完成',
|
|
failed: '失败',
|
|
}
|
|
return map[status] || status
|
|
}
|
|
|
|
const formatTime = (time: string | null) => {
|
|
if (!time) return '未知'
|
|
return new Date(time).toLocaleString('zh-CN')
|
|
}
|
|
|
|
onMounted(() => {
|
|
loadStats()
|
|
loadRecentReports()
|
|
loadCollectionStats()
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.stat-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
}
|
|
|
|
.stat-icon {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.stat-info {
|
|
flex: 1;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
color: #303133;
|
|
}
|
|
|
|
.stat-label {
|
|
margin-top: 5px;
|
|
color: #909399;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.report-item,
|
|
.collection-item {
|
|
padding: 12px 0;
|
|
border-bottom: 1px solid #ebeef5;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.report-item:last-child,
|
|
.collection-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.report-item:hover,
|
|
.collection-item:hover {
|
|
background-color: #f5f7fa;
|
|
margin: 0 -20px;
|
|
padding: 12px 20px;
|
|
}
|
|
|
|
.report-title,
|
|
.collection-name {
|
|
font-weight: 500;
|
|
margin-bottom: 8px;
|
|
color: #303133;
|
|
}
|
|
|
|
.report-meta,
|
|
.collection-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
font-size: 12px;
|
|
color: #909399;
|
|
}
|
|
</style>
|