From 8edf7cbc9ed203a23b5f3603974bc00c4dc82bce Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Thu, 5 Feb 2026 15:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=89=8D=E7=AB=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=EF=BC=88Task=2010?= =?UTF-8?q?-11=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 完成前端基础设施:路由、API 封装、状态管理、布局组件 - 实现 LLM 配置管理:增删改查、启用禁用 - 实现数据源管理:支持 RSS/API/爬虫三种类型 - 实现推送渠道管理:支持邮件/钉钉/企业微信/Slack - 实现主题管理:关联数据源、渠道、LLM 配置 - 实现报告中心、资讯浏览、采集监控页面 Co-Authored-By: Claude Opus 4.5 --- frontend/.env.development | 1 + frontend/.env.production | 1 + frontend/src/App.vue | 37 +- frontend/src/api/request.ts | 103 +++++ frontend/src/api/types.ts | 127 ++++++ frontend/src/layouts/MainLayout.vue | 163 ++++++++ frontend/src/router/index.ts | 84 +++- frontend/src/stores/app.ts | 17 + frontend/src/views/Dashboard.vue | 276 +++++++++++++ frontend/src/views/articles/ArticleList.vue | 277 +++++++++++++ frontend/src/views/config/Channels.vue | 396 ++++++++++++++++++ frontend/src/views/config/LlmConfig.vue | 281 +++++++++++++ frontend/src/views/config/Sources.vue | 402 +++++++++++++++++++ frontend/src/views/config/Topics.vue | 396 ++++++++++++++++++ frontend/src/views/monitoring/Monitoring.vue | 306 ++++++++++++++ frontend/src/views/reports/ReportDetail.vue | 163 ++++++++ frontend/src/views/reports/ReportList.vue | 220 ++++++++++ 17 files changed, 3220 insertions(+), 30 deletions(-) create mode 100644 frontend/.env.development create mode 100644 frontend/.env.production create mode 100644 frontend/src/api/request.ts create mode 100644 frontend/src/api/types.ts create mode 100644 frontend/src/layouts/MainLayout.vue create mode 100644 frontend/src/stores/app.ts create mode 100644 frontend/src/views/Dashboard.vue create mode 100644 frontend/src/views/articles/ArticleList.vue create mode 100644 frontend/src/views/config/Channels.vue create mode 100644 frontend/src/views/config/LlmConfig.vue create mode 100644 frontend/src/views/config/Sources.vue create mode 100644 frontend/src/views/config/Topics.vue create mode 100644 frontend/src/views/monitoring/Monitoring.vue create mode 100644 frontend/src/views/reports/ReportDetail.vue create mode 100644 frontend/src/views/reports/ReportList.vue diff --git a/frontend/.env.development b/frontend/.env.development new file mode 100644 index 0000000..e4d05f7 --- /dev/null +++ b/frontend/.env.development @@ -0,0 +1 @@ +VITE_API_BASE_URL=http://localhost:3000/api/v1 diff --git a/frontend/.env.production b/frontend/.env.production new file mode 100644 index 0000000..2bf124d --- /dev/null +++ b/frontend/.env.production @@ -0,0 +1 @@ +VITE_API_BASE_URL=/api/v1 diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 58b0f21..06d8e15 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,30 +1,19 @@ - - - diff --git a/frontend/src/api/request.ts b/frontend/src/api/request.ts new file mode 100644 index 0000000..055d674 --- /dev/null +++ b/frontend/src/api/request.ts @@ -0,0 +1,103 @@ +import axios from 'axios' +import type { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios' +import { ElMessage } from 'element-plus' + +// API 响应类型 +export interface ApiResponse { + success: boolean + data: T + pagination?: { + total: number + page: number + limit: number + totalPages: number + } + message?: string + error?: string +} + +// 创建 axios 实例 +const service: AxiosInstance = axios.create({ + baseURL: import.meta.env.VITE_API_BASE_URL || '/api/v1', + timeout: 30000, +}) + +// 请求拦截器 +service.interceptors.request.use( + (config: InternalAxiosRequestConfig) => { + return config + }, + (error) => { + console.error('Request error:', error) + return Promise.reject(error) + } +) + +// 响应拦截器 +service.interceptors.response.use( + (response: AxiosResponse): any => { + const res = response.data + + // 如果响应格式不是标准格式,直接返回 + if (res.success === undefined) { + return res + } + + // 处理业务错误 + if (!res.success) { + ElMessage.error(res.error || '请求失败') + return Promise.reject(new Error(res.error || '请求失败')) + } + + // 返回包含 data 和 pagination 的完整响应 + return res + }, + (error) => { + console.error('Response error:', error) + + // 处理 HTTP 错误 + if (error.response) { + const status = error.response.status + switch (status) { + case 401: + ElMessage.error('未授权,请登录') + break + case 403: + ElMessage.error('拒绝访问') + break + case 404: + ElMessage.error('请求的资源不存在') + break + case 500: + ElMessage.error('服务器错误') + break + default: + ElMessage.error(error.response.data?.error || '请求失败') + } + } else if (error.request) { + ElMessage.error('网络错误,请检查网络连接') + } else { + ElMessage.error('请求配置错误') + } + + return Promise.reject(error) + } +) + +// 封装请求方法 +const request = { + get(url: string, config?: any): Promise> { + return service.get(url, config) + }, + post(url: string, data?: any, config?: any): Promise> { + return service.post(url, data, config) + }, + put(url: string, data?: any, config?: any): Promise> { + return service.put(url, data, config) + }, + delete(url: string, config?: any): Promise> { + return service.delete(url, config) + }, +} + +export default request diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts new file mode 100644 index 0000000..0c8aafa --- /dev/null +++ b/frontend/src/api/types.ts @@ -0,0 +1,127 @@ +// 分页参数 +export interface PaginationParams { + page?: number + limit?: number +} + +// 分页信息 +export interface Pagination { + total: number + page: number + limit: number + totalPages: number +} + +// 分页响应 +export interface PaginatedResponse { + success: boolean + data: T[] + pagination: Pagination +} + +// LLM 配置 +export interface LlmConfig { + id: number + name: string + baseUrl: string + model: string + apiKey: string + enabled: boolean + createdAt: string + updatedAt: string +} + +// 数据源 +export interface Source { + id: number + name: string + type: 'api' | 'playwright' | 'rss' + config: Record + cronExpression: string + enabled: boolean + lastCollectedAt: string | null + createdAt: string + updatedAt: string +} + +// 推送渠道 +export interface Channel { + id: number + name: string + type: 'email' | 'dingtalk' | 'wechat' | 'slack' + config: Record + enabled: boolean + createdAt: string + updatedAt: string +} + +// 主题 +export interface Topic { + id: number + name: string + description: string | null + processMode: 'aggregate' | 'summary' | 'deep_analysis' + llmConfigId: number | null + scheduleConfig: Record + enabled: boolean + createdAt: string + updatedAt: string + llmConfig?: LlmConfig + topicSources?: Array<{ source: Source }> + topicChannels?: Array<{ channel: Channel }> +} + +// 报告 +export interface Report { + id: number + topicId: number + title: string + content: string + periodStart: string + periodEnd: string + status: 'pending' | 'generating' | 'completed' | 'failed' + errorMessage: string | null + articleCount: number + createdAt: string + updatedAt: string + topic?: Topic +} + +// 资讯 +export interface Article { + id: number + sourceId: number + title: string + content: string | null + summary: string | null + url: string | null + publishedAt: string | null + collectedAt: string + createdAt: string + source?: Source +} + +// 采集日志 +export interface CollectionLog { + id: number + sourceId: number + status: 'success' | 'failed' | 'running' + errorMessage: string | null + articlesCount: number + startedAt: string + finishedAt: string | null + createdAt: string + source?: Source +} + +// 采集统计 +export interface CollectionStats { + id: number + name: string + type: string + enabled: boolean + totalArticles: number + totalCollections: number + lastCollectedAt: string | null + lastLog: CollectionLog | null +} diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue new file mode 100644 index 0000000..cdf0d68 --- /dev/null +++ b/frontend/src/layouts/MainLayout.vue @@ -0,0 +1,163 @@ + + + + + diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 18308d9..e7fe7af 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,13 +1,85 @@ import { createRouter, createWebHistory } from 'vue-router' +import type { RouteRecordRaw } from 'vue-router' + +const routes: RouteRecordRaw[] = [ + { + path: '/', + redirect: '/dashboard', + }, + { + path: '/', + component: () => import('@/layouts/MainLayout.vue'), + children: [ + { + path: 'dashboard', + name: 'Dashboard', + component: () => import('@/views/Dashboard.vue'), + meta: { title: '仪表盘' }, + }, + { + path: 'config/llm', + name: 'LlmConfig', + component: () => import('@/views/config/LlmConfig.vue'), + meta: { title: 'LLM 配置' }, + }, + { + path: 'config/sources', + name: 'Sources', + component: () => import('@/views/config/Sources.vue'), + meta: { title: '数据源管理' }, + }, + { + path: 'config/channels', + name: 'Channels', + component: () => import('@/views/config/Channels.vue'), + meta: { title: '推送渠道' }, + }, + { + path: 'config/topics', + name: 'Topics', + component: () => import('@/views/config/Topics.vue'), + meta: { title: '主题管理' }, + }, + { + path: 'reports', + name: 'Reports', + component: () => import('@/views/reports/ReportList.vue'), + meta: { title: '报告中心' }, + }, + { + path: 'reports/:id', + name: 'ReportDetail', + component: () => import('@/views/reports/ReportDetail.vue'), + meta: { title: '报告详情' }, + }, + { + path: 'articles', + name: 'Articles', + component: () => import('@/views/articles/ArticleList.vue'), + meta: { title: '资讯浏览' }, + }, + { + path: 'monitoring', + name: 'Monitoring', + component: () => import('@/views/monitoring/Monitoring.vue'), + meta: { title: '采集监控' }, + }, + ], + }, +] const router = createRouter({ history: createWebHistory(), - routes: [ - { - path: '/', - redirect: '/dashboard', - }, - ], + routes, +}) + +// 路由守卫 +router.beforeEach((to, _from, next) => { + // 设置页面标题 + if (to.meta.title) { + document.title = `${to.meta.title} - 资讯聚合系统` + } + next() }) export default router diff --git a/frontend/src/stores/app.ts b/frontend/src/stores/app.ts new file mode 100644 index 0000000..a6eb580 --- /dev/null +++ b/frontend/src/stores/app.ts @@ -0,0 +1,17 @@ +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useAppStore = defineStore('app', () => { + // 侧边栏折叠状态 + const sidebarCollapsed = ref(false) + + // 切换侧边栏 + const toggleSidebar = () => { + sidebarCollapsed.value = !sidebarCollapsed.value + } + + return { + sidebarCollapsed, + toggleSidebar, + } +}) diff --git a/frontend/src/views/Dashboard.vue b/frontend/src/views/Dashboard.vue new file mode 100644 index 0000000..6a1b8ae --- /dev/null +++ b/frontend/src/views/Dashboard.vue @@ -0,0 +1,276 @@ + + + + + diff --git a/frontend/src/views/articles/ArticleList.vue b/frontend/src/views/articles/ArticleList.vue new file mode 100644 index 0000000..b0dcd8f --- /dev/null +++ b/frontend/src/views/articles/ArticleList.vue @@ -0,0 +1,277 @@ + + + + + diff --git a/frontend/src/views/config/Channels.vue b/frontend/src/views/config/Channels.vue new file mode 100644 index 0000000..898b961 --- /dev/null +++ b/frontend/src/views/config/Channels.vue @@ -0,0 +1,396 @@ + + + + + diff --git a/frontend/src/views/config/LlmConfig.vue b/frontend/src/views/config/LlmConfig.vue new file mode 100644 index 0000000..a542f9b --- /dev/null +++ b/frontend/src/views/config/LlmConfig.vue @@ -0,0 +1,281 @@ + + + + + diff --git a/frontend/src/views/config/Sources.vue b/frontend/src/views/config/Sources.vue new file mode 100644 index 0000000..e119662 --- /dev/null +++ b/frontend/src/views/config/Sources.vue @@ -0,0 +1,402 @@ + + + + + diff --git a/frontend/src/views/config/Topics.vue b/frontend/src/views/config/Topics.vue new file mode 100644 index 0000000..7972430 --- /dev/null +++ b/frontend/src/views/config/Topics.vue @@ -0,0 +1,396 @@ + + + + + diff --git a/frontend/src/views/monitoring/Monitoring.vue b/frontend/src/views/monitoring/Monitoring.vue new file mode 100644 index 0000000..236ea56 --- /dev/null +++ b/frontend/src/views/monitoring/Monitoring.vue @@ -0,0 +1,306 @@ + + + + + diff --git a/frontend/src/views/reports/ReportDetail.vue b/frontend/src/views/reports/ReportDetail.vue new file mode 100644 index 0000000..9d24dd4 --- /dev/null +++ b/frontend/src/views/reports/ReportDetail.vue @@ -0,0 +1,163 @@ + + + + + diff --git a/frontend/src/views/reports/ReportList.vue b/frontend/src/views/reports/ReportList.vue new file mode 100644 index 0000000..dc5eb88 --- /dev/null +++ b/frontend/src/views/reports/ReportList.vue @@ -0,0 +1,220 @@ + + + + +