- 完成前端基础设施:路由、API 封装、状态管理、布局组件 - 实现 LLM 配置管理:增删改查、启用禁用 - 实现数据源管理:支持 RSS/API/爬虫三种类型 - 实现推送渠道管理:支持邮件/钉钉/企业微信/Slack - 实现主题管理:关联数据源、渠道、LLM 配置 - 实现报告中心、资讯浏览、采集监控页面 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
278 lines
8.0 KiB
Vue
278 lines
8.0 KiB
Vue
<template>
|
|
<div class="article-list">
|
|
<div class="page-header">
|
|
<h2>资讯浏览</h2>
|
|
</div>
|
|
|
|
<el-card class="filter-card">
|
|
<el-form :inline="true" :model="filters">
|
|
<el-form-item label="数据源">
|
|
<el-select v-model="filters.sourceId" placeholder="全部数据源" clearable style="width: 180px">
|
|
<el-option
|
|
v-for="item in sources"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="主题">
|
|
<el-select v-model="filters.topicId" placeholder="全部主题" clearable style="width: 180px">
|
|
<el-option
|
|
v-for="item in topics"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="日期范围">
|
|
<el-date-picker
|
|
v-model="filters.dateRange"
|
|
type="daterange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期"
|
|
value-format="YYYY-MM-DD"
|
|
style="width: 260px"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @click="loadData">查询</el-button>
|
|
<el-button @click="resetFilters">重置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-card>
|
|
|
|
<el-card style="margin-top: 20px">
|
|
<el-table :data="tableData" v-loading="loading" stripe>
|
|
<el-table-column prop="id" label="ID" width="80" />
|
|
<el-table-column prop="title" label="标题" min-width="250" show-overflow-tooltip />
|
|
<el-table-column label="数据源" width="150">
|
|
<template #default="{ row }">
|
|
<el-tag size="small">{{ row.source?.name || '-' }}</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="url" label="链接" width="100">
|
|
<template #default="{ row }">
|
|
<el-link v-if="row.url" :href="row.url" target="_blank" type="primary">查看</el-link>
|
|
<span v-else>-</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="publishedAt" label="发布时间" width="180">
|
|
<template #default="{ row }">
|
|
{{ row.publishedAt ? formatTime(row.publishedAt) : '-' }}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="collectedAt" label="采集时间" width="180">
|
|
<template #default="{ row }">
|
|
{{ formatTime(row.collectedAt) }}
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" width="120" fixed="right">
|
|
<template #default="{ row }">
|
|
<el-button type="primary" link @click="handleView(row)">详情</el-button>
|
|
<el-button type="danger" link @click="handleDelete(row)">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<div class="pagination-wrapper">
|
|
<el-pagination
|
|
v-model:current-page="pagination.page"
|
|
v-model:page-size="pagination.limit"
|
|
:total="pagination.total"
|
|
:page-sizes="[10, 20, 50, 100]"
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
@size-change="loadData"
|
|
@current-change="loadData"
|
|
/>
|
|
</div>
|
|
</el-card>
|
|
|
|
<!-- 详情对话框 -->
|
|
<el-dialog v-model="detailVisible" title="资讯详情" width="700px">
|
|
<template v-if="currentArticle">
|
|
<el-descriptions :column="2" border>
|
|
<el-descriptions-item label="标题" :span="2">{{ currentArticle.title }}</el-descriptions-item>
|
|
<el-descriptions-item label="数据源">{{ currentArticle.source?.name || '-' }}</el-descriptions-item>
|
|
<el-descriptions-item label="链接">
|
|
<el-link v-if="currentArticle.url" :href="currentArticle.url" target="_blank" type="primary">
|
|
{{ currentArticle.url }}
|
|
</el-link>
|
|
<span v-else>-</span>
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="发布时间">
|
|
{{ currentArticle.publishedAt ? formatTime(currentArticle.publishedAt) : '-' }}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="采集时间">{{ formatTime(currentArticle.collectedAt) }}</el-descriptions-item>
|
|
</el-descriptions>
|
|
|
|
<el-divider />
|
|
|
|
<div v-if="currentArticle.summary" class="article-section">
|
|
<h4>摘要</h4>
|
|
<p>{{ currentArticle.summary }}</p>
|
|
</div>
|
|
|
|
<div v-if="currentArticle.content" class="article-section">
|
|
<h4>内容</h4>
|
|
<div class="article-content">{{ currentArticle.content }}</div>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted } from 'vue'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import request from '@/api/request'
|
|
import type { Article, Source, Topic } from '@/api/types'
|
|
|
|
const loading = ref(false)
|
|
const tableData = ref<Article[]>([])
|
|
const sources = ref<Source[]>([])
|
|
const topics = ref<Topic[]>([])
|
|
const detailVisible = ref(false)
|
|
const currentArticle = ref<Article | null>(null)
|
|
|
|
const pagination = reactive({
|
|
page: 1,
|
|
limit: 20,
|
|
total: 0,
|
|
})
|
|
|
|
const filters = reactive({
|
|
sourceId: null as number | null,
|
|
topicId: null as number | null,
|
|
dateRange: null as [string, string] | null,
|
|
})
|
|
|
|
const loadData = async () => {
|
|
loading.value = true
|
|
try {
|
|
const params: Record<string, any> = {
|
|
page: pagination.page,
|
|
limit: pagination.limit,
|
|
}
|
|
if (filters.sourceId) params.sourceId = filters.sourceId
|
|
if (filters.topicId) params.topicId = filters.topicId
|
|
if (filters.dateRange) {
|
|
params.startDate = filters.dateRange[0]
|
|
params.endDate = filters.dateRange[1]
|
|
}
|
|
|
|
const res = await request.get('/articles', { params })
|
|
tableData.value = res.data || []
|
|
pagination.total = res.pagination?.total || 0
|
|
} catch (error) {
|
|
console.error('加载数据失败', error)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
const loadOptions = async () => {
|
|
try {
|
|
const [sourceRes, topicRes] = await Promise.all([
|
|
request.get('/sources', { params: { limit: 100 } }),
|
|
request.get('/topics', { params: { limit: 100 } }),
|
|
])
|
|
sources.value = sourceRes.data || []
|
|
topics.value = topicRes.data || []
|
|
} catch (error) {
|
|
console.error('加载选项失败', error)
|
|
}
|
|
}
|
|
|
|
const resetFilters = () => {
|
|
filters.sourceId = null
|
|
filters.topicId = null
|
|
filters.dateRange = null
|
|
loadData()
|
|
}
|
|
|
|
const handleView = async (row: Article) => {
|
|
try {
|
|
const res = await request.get(`/articles/${row.id}`)
|
|
currentArticle.value = res.data
|
|
detailVisible.value = true
|
|
} catch (error) {
|
|
console.error('获取详情失败', error)
|
|
}
|
|
}
|
|
|
|
const handleDelete = async (row: Article) => {
|
|
try {
|
|
await ElMessageBox.confirm(`确定要删除资讯 "${row.title}" 吗?`, '提示', {
|
|
type: 'warning',
|
|
})
|
|
await request.delete(`/articles/${row.id}`)
|
|
ElMessage.success('删除成功')
|
|
loadData()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel') {
|
|
console.error('删除失败', error)
|
|
}
|
|
}
|
|
}
|
|
|
|
const formatTime = (time: string) => {
|
|
return new Date(time).toLocaleString('zh-CN')
|
|
}
|
|
|
|
onMounted(() => {
|
|
loadData()
|
|
loadOptions()
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.article-list {
|
|
height: 100%;
|
|
}
|
|
|
|
.page-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.page-header h2 {
|
|
margin: 0;
|
|
font-size: 20px;
|
|
color: #303133;
|
|
}
|
|
|
|
.filter-card :deep(.el-form-item) {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.pagination-wrapper {
|
|
margin-top: 20px;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.article-section {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.article-section h4 {
|
|
margin-bottom: 10px;
|
|
color: #303133;
|
|
}
|
|
|
|
.article-content {
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
padding: 15px;
|
|
background-color: #fafafa;
|
|
border-radius: 4px;
|
|
line-height: 1.8;
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|