Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(web): AI Content Generation with Auto-Publish Integration (#330)
布莱恩·奥夫托·杰森张49ee80cf50c4
diff --git a/project/web/@types/resources.d.ts b/project/web/@types/resources.d.tsindex 9bc5cd63..1fd0c0f2 100644--- a/project/web/@types/resources.d.ts+++ b/project/web/@types/resources.d.ts@@ -635,6 +635,120 @@ interface Resources {"milestoneProgress": "里程碑进度","recentWeek": "最近一周"},+ "dataMonitoring": {+ "title": "笔记传播监测",+ "description": "按分钟级频率监测笔记的点赞、收藏、评论、转发等传播数据,有效验证笔记传播效果",+ "tabs": {+ "byLink": "按笔记链接",+ "byAccount": "按小红书账号"+ },+ "actions": {+ "add": "去添加",+ "comingSoon": "即将开放",+ "viewDetail": "查看详情"+ },+ "addModal": {+ "title": "添加笔记监测",+ "inputPlaceholder": "请输入小红书笔记链接",+ "linkPlaceholder": "https://www.xiaohongshu.com/explore/...",+ "linkRequired": "请输入笔记链接",+ "confirm": "确定",+ "cancel": "取消",+ "addSuccess": "添加成功",+ "addFailed": "添加失败"+ },+ "list": {+ "empty": "暂无监测数据,点击上方按钮添加笔记链接",+ "untitled": "未命名笔记",+ "createdAt": "创建时间",+ "updatedAt": "更新时间",+ "error": "错误",+ "totalRecords": "共 {{count}} 条记录"+ },+ "stats": {+ "views": "阅读数",+ "likes": "点赞数",+ "comments": "评论数",+ "favorites": "收藏数",+ "shares": "分享数"+ },+ "status": {+ "pending": "等待中",+ "processing": "处理中",+ "completed": "已完成",+ "success": "成功",+ "failed": "失败",+ "enabled": "已启用",+ "disabled": "已禁用"+ },+ "detail": {+ "back": "返回",+ "backToList": "返回列表",+ "notFound": "未找到监测数据",+ "pause": "暂停监测",+ "resume": "恢复监测",+ "paused": "已暂停",+ "resumed": "已恢复",+ "export": "导出数据",+ "exportSuccess": "导出成功",+ "viewNote": "查看笔记",+ "pageTitle": "笔记监测详情",+ "startTime": "开始时间",+ "updateTime": "更新时间",+ "noteCover": "笔记封面",+ "viewOriginal": "查看原文",+ "dailyIncrement": "每日数据增量",+ "noData": "暂无数据",+ "taskId": "任务编号",+ "createdTime": "任务提交时间",+ "publishTime": "发布时间",+ "firstMonitoring": "首次监测时间",+ "monitoringDuration": "监测时长",+ "duration": "{{count}}天",+ "monitoringFrequency": "监测频率",+ "minutesPerTime": "分钟/次",+ "lastMonitoring": "最近一次监测",+ "completionRate": "监测完成度",+ "monitoringComplete": "监测已完成",+ "dataDetail": "数据详情",+ "downloadRecord": "下载记录",+ "exportResult": "导出结果",+ "postInfo": "笔记信息",+ "mediaPreview": "媒体预览",+ "dataHistory": "数据历史",+ "noHistory": "暂无历史数据",+ "status": {+ "active": "监测中",+ "paused": "已暂停"+ },+ "tabs": {+ "chart": "累计视图",+ "table": "增量视图"+ },+ "table": {+ "time": "时间",+ "date": "日期",+ "likeIncrement": "点赞增量",+ "favoriteIncrement": "收藏增量",+ "commentIncrement": "评论增量",+ "totalLikes": "即时点赞",+ "newLikes": "新增点赞",+ "totalComments": "即时评论",+ "newComments": "新增评论",+ "totalFavorites": "即时收藏",+ "newFavorites": "新增收藏",+ "total": "共 {{count}} 条",+ "totalDays": "共 {{count}} 天"+ }+ },+ "error": {+ "loadFailed": "加载失败",+ "addFailed": "添加失败",+ "toggleFailed": "操作失败",+ "exportFailed": "导出失败",+ "getDetailFailed": "获取详情失败"+ }+ },"engagement": {"title": "互动数据","columns": {diff --git a/project/web/AI_GENERATION_IMPLEMENTATION.md b/project/web/AI_GENERATION_IMPLEMENTATION.mdnew file mode 100644index 00000000..7d8678e4--- /dev/null+++ b/project/web/AI_GENERATION_IMPLEMENTATION.md@@ -0,0 +1,161 @@+# AI内容生成功能实现文档++## 功能概述++在首页输入框输入创作提示词,AI将自动生成完整的作品内容(标题、描述、标签和媒体文件),完成后自动跳转到accounts页面并打开发布弹窗填充数据。++## 实现内容++### 1. API接口 (`src/api/agent.ts`)++- **创建任务**: `POST /agent/tasks`+ - 请求: `{ prompt: string }`+ - 响应: `{ id: string }`++- **查询任务**: `GET /agent/tasks/{taskId}`+ - 返回任务详情,包括status、title、description、tags、medias等++- **任务状态枚举**:+ - `THINKING`: 思考中+ - `WAITING`: 等待+ - `GENERATING_CONTENT`: 内容生成中+ - `GENERATING_IMAGE`: 图片生成中+ - `GENERATING_VIDEO`: 视频生成中+ - `GENERATING_TEXT`: 文本生成中+ - `COMPLETED`: 完成+ - `FAILED`: 失败+ - `CANCELLED`: 已取消++### 2. 首页Hero组件 (`src/app/[lng]/page.tsx`)++#### 功能特性++1. **输入框**:+ - 替换原来的h1标题+ - 支持Enter键快捷生成+ - 禁用状态在生成过程中++2. **进度显示**:+ - 使用打字机效果逐字显示进度信息+ - 固定高度(200px)的可滚动区域+ - 状态变化时累计展示,不会覆盖之前的信息+ - description只显示一次++3. **状态轮询**:+ - 每2秒轮询一次任务状态+ - 最大轮询时间10分钟+ - 状态变化时即时更新显示++4. **完成跳转**:+ - 任务完成后自动跳转到accounts页面+ - 携带参数: taskId, title, description, tags, medias++### 3. Accounts页面 (`src/app/[lng]/accounts/accountCore.tsx`)++#### 功能特性++1. **参数接收**:+ - 监听URL参数 `aiGenerated=true`+ - 解析AI生成的数据(tags、medias等)++2. **自动打开发布弹窗**:+ - 等待账户列表加载完成+ - 默认选中第一个账户+ - 延迟500ms后打开弹窗++3. **数据填充**:+ - 标题填充到title字段+ - 描述+tags(以#开头)填充到des字段+ - tags追加格式: `\n\n#tag1 #tag2 #tag3`+ - 媒体文件处理:+ - VIDEO类型: 填充到video字段,清空images+ - IMAGE类型: 填充到images数组,支持多张图片+ - 延迟1秒后填充,确保PublishDialog完全初始化+ - 如果pubList未初始化,1秒后自动重试++### 4. 发布弹窗修复 (`src/components/PublishDialog/index.tsx`)++#### 修复问题++**问题**: 关闭发布弹窗后再打开无法选择账户++**原因**: 在弹窗关闭时调用了`clear()`方法,清空了所有数据包括`pubList`++**解决方案**:+- 弹窗关闭时不调用`clear()`+- 只清除选中状态(`pubListChoosed`)和步骤(`step`)+- 保留`pubList`以便下次打开时可以选择账户++### 5. 样式优化 (`src/app/[lng]/styles/difyHome.module.scss`)++添加光标闪烁动画:+```scss+@keyframes blink {+ 0%, 100% { opacity: 1; }+ 50% { opacity: 0; }+}+```++## 使用流程++1. **用户输入**: 在首页输入框输入创作提示词,如"创建一个关于火星的科普视频"++2. **任务创建**: 点击"生成作品"按钮,系统创建AI生成任务++3. **进度展示**:+ ```+ 💭 AI思考中...+ ✍️ 文本生成中...+ 🎬 视频生成中...+ 📄 你知道火星上曾经有液态水流淌吗...+ ✅ 生成完成!+ ```++4. **自动跳转**: 任务完成后自动跳转到accounts页面++5. **弹窗填充**:+ - 自动打开发布弹窗+ - 默认选中第一个账户+ - 填充标题、描述、标签和媒体文件++6. **发布作品**: 用户可以进一步编辑或直接发布++## 数据流转++```+首页输入+ → 创建任务(POST /agent/tasks)+ → 轮询状态(GET /agent/tasks/{taskId})+ → 进度展示(打字机效果)+ → 完成跳转(携带参数)+ → Accounts页面接收参数+ → 打开发布弹窗+ → 填充数据+ → 用户发布+```++## 关键技术点++1. **打字机效果**: 使用字符索引和setTimeout实现逐字显示+2. **状态轮询**: 递归调用setTimeout,避免固定间隔的setInterval+3. **数据填充延迟**: 使用setTimeout确保PublishDialog完全初始化+4. **重试机制**: pubList未初始化时自动重试+5. **状态管理**: 区分清除数据和重置状态,避免过度清除++## 注意事项++1. tags需要以`#`开头追加到description后面+2. medias是数组,需要区分VIDEO和IMAGE类型+3. 发布弹窗关闭时不能清空pubList+4. AI生成的媒体文件已有ossUrl,不需要再次上传+5. 需要等待账户列表加载完成后再处理AI生成数据++## 测试建议++1. 测试输入框的禁用和启用状态+2. 测试进度信息的打字机效果+3. 测试不同状态的正确显示+4. 测试失败和超时的错误处理+5. 测试多个媒体文件的正确填充+6. 测试弹窗关闭后再打开的账户选择功能+diff --git a/project/web/package.json b/project/web/package.jsonindex 2bfe3d9f..703528fd 100644--- a/project/web/package.json+++ b/project/web/package.json@@ -40,6 +40,7 @@"crypto-js": "^4.2.0","dayjs": "^1.11.13","echarts": "^6.0.0",+ "echarts-for-react": "^3.0.5","glob": "^11.0.3","i18next": "24.2.3","i18next-browser-languagedetector": "8.0.4",diff --git a/project/web/pnpm-lock.yaml b/project/web/pnpm-lock.yamlindex 3271f76d..f24ab892 100644--- a/project/web/pnpm-lock.yaml+++ b/project/web/pnpm-lock.yaml@@ -74,6 +74,9 @@ importers:echarts:specifier: ^6.0.0version: 6.0.0+ echarts-for-react:+ specifier: ^3.0.5+ version: 3.0.5([email protected])([email protected])glob:specifier: ^11.0.3version: 11.0.3@@ -2607,6 +2610,12 @@ packages:resolution: {integrity: sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==}+ resolution: {integrity: sha512-YpEI5Ty7O/2nvCfQ7ybNa+S90DwE8KYZWacGvJW4luUqywP7qStQ+pxDlYOmr4jGDu10mhEkiAuMKcUlT4W5vg==}+ peerDependencies:+ echarts: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0+ react: ^15.0.0 || >=16.0.0+resolution: {integrity: sha512-Tte/grDQRiETQP4xz3iZWSvoHrkCQtwqd6hs+mifXcjrCuo2iKWbajFObuLJVBlDIJlOzgQPd1hsaKt/3+OMkQ==}@@ -4921,6 +4930,9 @@ packages:resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}+ resolution: {integrity: sha512-2NCmWxY7A9pYKGXNBfteo4hy14gWu47rg5692peVMst6lQLPKrVjhY+UTEsPI5ceFRJSl3gVgMYaUi/hKuaiKw==}+resolution: {integrity: sha512-aNfiuwMEpfBM/CN6LY0ibyhxPfPbyFeBTYJKCvzkJ2GkUpazIt3H+QIPAMHwqQ7tMKaHz1Qj+rJJCqljnf4p3A==}@@ -8388,6 +8400,13 @@ snapshots:safer-buffer: 2.1.2optional: true+ dependencies:+ echarts: 6.0.0+ fast-deep-equal: 3.1.3+ react: 18.3.1+ size-sensor: 1.0.2+dependencies:tslib: 2.3.0@@ -11470,6 +11489,8 @@ snapshots:+ [email protected]: {}+diff --git a/project/web/src/api/agent.ts b/project/web/src/api/agent.tsnew file mode 100644index 00000000..57e40333--- /dev/null+++ b/project/web/src/api/agent.ts@@ -0,0 +1,75 @@+/*+ * @Description: AI Agent 内容生成任务接口+ */+import http from '@/utils/request'++// 任务状态枚举+export enum TaskStatus {+ Thinking = 'THINKING',+ Waiting = 'WAITING', // 等待+ GeneratingContent = 'GENERATING_CONTENT', // 内容生成中+ GeneratingImage = 'GENERATING_IMAGE', // 图片生成中+ GeneratingVideo = 'GENERATING_VIDEO', // 视频生成中+ GeneratingText = 'GENERATING_TEXT', // 文本生成中+ Completed = 'COMPLETED', // 完成+ Failed = 'FAILED', // 失败+ Cancelled = 'CANCELLED', // 取消+}++// 媒体类型+export enum MediaType {+ Video = 'VIDEO',+ Image = 'IMAGE',+}++// 媒体文件+export interface Media {+ type: MediaType+ url: string+ coverUrl?: string // 视频封面URL(可选)+}++// 任务详情+export interface TaskDetail {+ id: string+ userId: string+ prompt: string+ title: string+ description: string+ tags: string[]+ status: TaskStatus+ medias: Media[]+ errorMessage: string+ createdAt: string+}++// 创建任务请求参数+export interface CreateTaskParams {+ prompt: string+}++// 创建任务响应+export interface CreateTaskResponse {+ id: string+}++export const agentApi = {+ /**+ * 创建AI生成任务+ * @param params+ */+ async createTask(params: CreateTaskParams) {+ const res = await http.post<CreateTaskResponse>('agent/tasks', params)+ return res+ },++ /**+ * 获取任务详情+ * @param taskId 任务ID+ */+ async getTaskDetail(taskId: string) {+ const res = await http.get<TaskDetail>(`agent/tasks/${taskId}`)+ return res+ },+}+diff --git a/project/web/src/api/ai.ts b/project/web/src/api/ai.tsindex 6e7af0c2..fd084313 100644--- a/project/web/src/api/ai.ts+++ b/project/web/src/api/ai.ts@@ -117,7 +117,7 @@ export function getVideoGenerations(params?: {page?: numberpageSize?: number}) {- return http.get('ai/video/generations', { params })+ return http.get('ai/video/generations', params)}// 保留旧的接口以保持向后兼容性(可选)diff --git a/project/web/src/api/monitoring.ts b/project/web/src/api/monitoring.tsnew file mode 100644index 00000000..baa97459--- /dev/null+++ b/project/web/src/api/monitoring.ts@@ -0,0 +1,154 @@+/*+ * @Description: 数据监控 API+ */+import http from '@/utils/request'++// 媒体类型+export interface MediaItem {+ type: 'img' | 'video'+ url: string+ live_photo?: number+ imageUrl?: string+}++// 图片列表项+export interface ImageListItem {+ live_photo: number+ imageUrl: string+}++// 帖子详情+export interface PostDetail {+ id: string+ postId: string+ platform: string+ title: string+ desc: string+ cover: string+ mediaType: 'image' | 'video'+ url: string+ publishTime: number+ readCount: number+ commentCount: number+ likeCount: number+ forwardCount: number+ collectCount: number+}++// 增量数据+export interface DeltaData {+ followerCountIncrease: number+ followingCountIncrease: number+ viewCountIncrease: number+ likeCountIncrease: number+ commentCountIncrease: number+ favoriteCountIncrease: number+ shareCountIncrease: number+}++// 数据洞察+export interface Insight {+ _id: string+ platform: string+ businessDate: string+ postId: string+ uid: string+ createdAt: string+ updatedAt: string+ dailyDelta: DeltaData+ weeklyDelta: DeltaData+ monthlyDelta: DeltaData+}++// 监控列表项(简单信息)+export interface NoteMonitoringListItem {+ _id: string+ platform: string+ userId: string+ link: string+ status: 'pending' | 'processing' | 'completed' | 'failed'+ enabled: boolean+ createdAt: string+ updatedAt: string+ error?: string+}++// 监控详情(包含完整信息)+export interface NoteMonitoringItem extends NoteMonitoringListItem {+ uploadMediaList?: MediaItem[]+ postId?: string+ uid?: string+ postDetail?: PostDetail+ insights?: Insight[]+}++// 列表返回数据+export interface NoteMonitoringListResponse {+ items: NoteMonitoringListItem[]+ page: number+ pageSize: number+ total: number+ totalPages: number+}++export interface GetNoteMonitoringListParams {+ platform: string+ page?: number+ pageSize?: number+}++export interface AddNoteMonitoringParams {+ platform: string+ link: string+}++/**+ * 获取笔记监测列表+ */+export async function apiGetNoteMonitoringList(params: GetNoteMonitoringListParams) {+ const res = await http.post<NoteMonitoringListResponse>('statistics/posts/monitor/list', params)+ return res?.data || { items: [], page: 1, pageSize: 20, total: 0, totalPages: 0 }+}++/**+ * 添加笔记监测+ */+export async function apiAddNoteMonitoring(params: AddNoteMonitoringParams) {+ const res = await http.post<NoteMonitoringItem>('statistics/posts/monitor/create', params)+ return res?.data+}++/**+ * 获取笔记监测详情+ */+export async function apiGetNoteMonitoringDetail(id: string) {+ const res = await http.post<NoteMonitoringItem>(`statistics/posts/monitor/${id}`)+ return res?.data+}++/**+ * 暂停/恢复笔记监测(暂未实现)+ */+export async function apiToggleNoteMonitoring(id: string, enabled: boolean) {+ const res = await http.post<boolean>(`statistics/posts/monitor/${id}/toggle`, { enabled })+ return res?.data+}++/**+ * 删除笔记监测(暂未实现)+ */+export async function apiDeleteNoteMonitoring(id: string) {+ const res = await http.delete<boolean>(`statistics/posts/monitor/${id}`)+ return res?.data+}++/**+ * 导出监测数据(暂未实现)+ */+export async function apiExportNoteMonitoringData(id: string) {+ const res = await http.get<Blob>(`statistics/posts/monitor/${id}/export`, {+ responseType: 'blob',+ } as any)+ return res?.data+}+diff --git a/project/web/src/app/[lng]/accounts/accountCore.tsx b/project/web/src/app/[lng]/accounts/accountCore.tsxindex acfad7ff..25ccd5e6 100644--- a/project/web/src/app/[lng]/accounts/accountCore.tsx+++ b/project/web/src/app/[lng]/accounts/accountCore.tsx@@ -3,7 +3,7 @@import type { SocialAccount } from '@/api/types/account.type'import { NoSSR } from '@kwooshung/react-no-ssr'import Image from 'next/image'-import { useEffect, useState } from 'react'+import { useEffect, useState, useRef } from 'react'import { useShallow } from 'zustand/react/shallow'import AccountSidebar from '@/app/[lng]/accounts/components/AccountSidebar/AccountSidebar'import AddAccountModal from '@/app/[lng]/accounts/components/AddAccountModal'@@ -13,6 +13,8 @@ import { PlatType } from '@/app/config/platConfig'import { useTransClient } from '@/app/i18n/client'import rightArrow from '@/assets/images/jiantou.png'import VipContentModal from '@/components/modals/VipContentModal'+import PublishDialog from '@/components/PublishDialog'+import type { IPublishDialogRef } from '@/components/PublishDialog'import { useAccountStore } from '@/store/account'import { useUserStore } from '@/store/user'@@ -23,6 +25,13 @@ interface AccountPageCoreProps {platform?: stringspaceId?: stringshowVip?: string+ // AI生成的内容参数+ aiGenerated?: string+ taskId?: string+ title?: string+ description?: string+ tags?: string+ medias?: string}}@@ -52,11 +61,21 @@ export default function AccountPageCore({const [showWechatBrowserTip, setShowWechatBrowserTip] = useState(false)// VIP弹窗状态const [vipModalOpen, setVipModalOpen] = useState(false)+ // 发布弹窗状态+ const [publishDialogOpen, setPublishDialogOpen] = useState(false)+ const [defaultAccountId, setDefaultAccountId] = useState<string>()+ const [aiGeneratedData, setAiGeneratedData] = useState<any>(null)+ const publishDialogRef = useRef<IPublishDialogRef>(null)useEffect(() => {accountInit()}, [])+ // 获取所有账号列表(扁平化)+ const allAccounts = accountGroupList.reduce<SocialAccount[]>((acc, group) => {+ return [...acc, ...group.children]+ }, [])+// 处理URL参数useEffect(() => {// 处理显示VIP弹窗的参数@@ -70,6 +89,48 @@ export default function AccountPageCore({}}+ // Handle AI-generated content params+ if (searchParams?.aiGenerated === 'true' && searchParams?.taskId && allAccounts.length > 0) {+ try {+ const medias = searchParams.medias ? JSON.parse(decodeURIComponent(searchParams.medias)) : []+ const tags = searchParams.tags ? JSON.parse(decodeURIComponent(searchParams.tags)) : []++ const data = {+ taskId: searchParams.taskId,+ title: searchParams.title || '',+ description: searchParams.description || '',+ tags: tags,+ medias: medias,+ }++ setAiGeneratedData(data)++ // Set default to first account+ if (allAccounts[0]) {+ setDefaultAccountId(allAccounts[0].id)+ }++ // Open publish dialog+ setTimeout(() => {+ setPublishDialogOpen(true)+ }, 500)++ // Clear URL params+ if (typeof window !== 'undefined') {+ const url = new URL(window.location.href)+ url.searchParams.delete('aiGenerated')+ url.searchParams.delete('taskId')+ url.searchParams.delete('title')+ url.searchParams.delete('description')+ url.searchParams.delete('tags')+ url.searchParams.delete('medias')+ window.history.replaceState({}, '', url.toString())+ }+ } catch (error) {+ console.error('Failed to parse AI generated data:', error)+ }+ }+if (searchParams?.platform || searchParams?.spaceId) {// 验证平台类型是否有效const platform = searchParams.platform as PlatType@@ -86,7 +147,7 @@ export default function AccountPageCore({// 打开添加账号弹窗setAddAccountModalOpen(true)}- }, [searchParams])+ }, [searchParams, allAccounts.length])/*** 检测是否为微信浏览器@@ -201,6 +262,274 @@ export default function AccountPageCore({}}+ // Fill AI-generated data after publish dialog opens+ useEffect(() => {+ if (aiGeneratedData && publishDialogOpen && allAccounts.length > 0) {++ // Delay filling to ensure PublishDialog is fully initialized+ const timeoutId = setTimeout(() => {+ try {+ const { usePublishDialog } = require('@/components/PublishDialog/usePublishDialog')+ const store = usePublishDialog.getState()++ // If pubList is not initialized yet, retry after delay+ if (!store.pubList || store.pubList.length === 0) {+ setTimeout(() => {+ const retryStore = usePublishDialog.getState()+ if (retryStore.pubList && retryStore.pubList.length > 0) {+ fillAIData(retryStore)+ }+ }, 1000)+ return+ }++ fillAIData(store)+ } catch (error) {+ console.error('Failed to fill AI data:', error)+ }+ }, 1000)++ // Helper function to fill data+ const fillAIData = async (store: any) => {+ // Dynamic import generateUUID and VideoGrabFrame+ const { generateUUID } = require('@/utils')+ const { VideoGrabFrame } = require('@/components/PublishDialog/PublishDialog.util')++ // Build params - append tags to description+ let description = aiGeneratedData.description || ''+ if (aiGeneratedData.tags && aiGeneratedData.tags.length > 0) {+ const tagsText = aiGeneratedData.tags.map((tag: string) => `#${tag}`).join(' ')+ description = description + '\n\n' + tagsText+ }++ const params: any = {+ des: description,+ title: aiGeneratedData.title || '',+ }++ // Handle media files - support multiple medias+ const medias = aiGeneratedData.medias || []++ if (medias.length > 0) {+ // Check if there's a video+ const videoMedia = medias.find((m: any) => m.type === 'VIDEO')+ if (videoMedia) {++ try {+ let coverInfo++ // If API returned cover URL, use it directly+ if (videoMedia.coverUrl) {+ const { formatImg } = require('@/components/PublishDialog/PublishDialog.util')++ // Load cover image to get dimension info+ coverInfo = await new Promise((resolve) => {+ const img = document.createElement('img')+ img.crossOrigin = 'anonymous'+ img.onload = () => {+ resolve({+ id: generateUUID(),+ width: img.width,+ height: img.height,+ imgUrl: videoMedia.coverUrl,+ ossUrl: videoMedia.coverUrl,+ filename: `ai_${aiGeneratedData.taskId}_cover.jpg`,+ imgPath: '',+ size: 0,+ file: null as any,+ })+ }+ img.onerror = () => {+ resolve(null)+ }+ img.src = videoMedia.coverUrl+ })+ }++ // If no cover URL or cover load failed, try to extract from video+ if (!coverInfo) {+ try {+ const videoInfo = await VideoGrabFrame(videoMedia.url, 0)++ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: videoInfo.width,+ height: videoInfo.height,+ duration: videoInfo.duration,+ cover: videoInfo.cover,+ }+ } catch (extractError) {+ // Cross-origin video cannot extract cover, use placeholder+ // Create a cover using video URL as imgUrl (browser will auto-display first frame)+ const video = document.createElement('video')+ video.src = videoMedia.url+ video.crossOrigin = 'anonymous'++ await new Promise((resolve) => {+ video.addEventListener('loadedmetadata', () => {+ // Use video URL as cover imgUrl, browser video tag's poster will handle it automatically+ const placeholderCover: any = {+ id: generateUUID(),+ size: 0,+ file: null as any,+ imgUrl: videoMedia.url, // Use video URL, video tag will show first frame+ filename: `ai_${aiGeneratedData.taskId}_cover.jpg`,+ imgPath: '',+ width: video.videoWidth,+ height: video.videoHeight,+ ossUrl: '', // No separate cover URL+ }++ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: video.videoWidth,+ height: video.videoHeight,+ duration: Math.floor(video.duration),+ cover: placeholderCover,+ }+ video.remove()+ resolve(null)+ })+ video.addEventListener('error', () => {+ // Complete failure, use default values+ const defaultCover: any = {+ id: generateUUID(),+ size: 0,+ file: null as any,+ imgUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}_cover.jpg`,+ imgPath: '',+ width: 1920,+ height: 1080,+ ossUrl: '',+ }++ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: 1920,+ height: 1080,+ duration: 0,+ cover: defaultCover,+ }+ video.remove()+ resolve(null)+ })+ video.load()+ })+ }+ } else {+ // Use API-returned cover, but still need to get width/height/duration from video+ const video = document.createElement('video')+ video.src = videoMedia.url+ video.crossOrigin = 'anonymous'++ await new Promise((resolve) => {+ video.addEventListener('loadedmetadata', () => {+ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: video.videoWidth,+ height: video.videoHeight,+ duration: Math.floor(video.duration),+ cover: coverInfo,+ }+ video.remove()+ resolve(null)+ })+ video.addEventListener('error', () => {+ // If video metadata loading fails, use default dimensions+ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: 1920,+ height: 1080,+ duration: 0,+ cover: coverInfo,+ }+ video.remove()+ resolve(null)+ })+ video.load()+ })+ }++ params.images = []+ } catch (error) {+ console.error('Failed to process video:', error)+ // If all methods fail, use default cover+ const defaultCover: any = {+ id: generateUUID(),+ size: 0,+ file: null as any,+ imgUrl: '', // Empty, will show default icon+ filename: `ai_${aiGeneratedData.taskId}_cover.jpg`,+ imgPath: '',+ width: 1920,+ height: 1080,+ ossUrl: '',+ }++ params.video = {+ size: 0,+ file: null as any,+ videoUrl: videoMedia.url,+ ossUrl: videoMedia.url,+ filename: `ai_${aiGeneratedData.taskId}.mp4`,+ width: 1920,+ height: 1080,+ duration: 0,+ cover: defaultCover,+ }+ params.images = []+ }+ } else {+ // Process all images+ const imageMedias = medias.filter((m: any) => m.type === 'IMAGE')+ if (imageMedias.length > 0) {+ params.images = imageMedias.map((media: any, index: number) => ({+ id: generateUUID(),+ size: 0,+ file: null as any,+ imgUrl: media.url, // Use ossUrl as preview URL+ filename: `ai_${aiGeneratedData.taskId}_${index + 1}.jpg`,+ imgPath: '',+ width: 1920,+ height: 1080,+ ossUrl: media.url, // AI-generated images already have ossUrl+ }))+ params.video = undefined+ }+ }+ }++ // Fill data to first selected account+ if (store.pubListChoosed && store.pubListChoosed.length > 0) {+ store.setOnePubParams(params, store.pubListChoosed[0].account.id)+ }+ }++ return () => clearTimeout(timeoutId)+ }+ }, [aiGeneratedData, publishDialogOpen, allAccounts.length])+return (<NoSSR><div className={styles.accounts}>@@ -320,6 +649,26 @@ export default function AccountPageCore({open={vipModalOpen}onClose={() => setVipModalOpen(false)}/>++ {/* 发布作品弹窗 */}+ {allAccounts.length > 0 && (+ <PublishDialog+ ref={publishDialogRef}+ open={publishDialogOpen}+ onClose={() => {+ setPublishDialogOpen(false)+ setAiGeneratedData(null)+ setDefaultAccountId(undefined)+ }}+ accounts={allAccounts}+ defaultAccountId={defaultAccountId}+ onPubSuccess={() => {+ setPublishDialogOpen(false)+ setAiGeneratedData(null)+ setDefaultAccountId(undefined)+ }}+ />+ )}</div></NoSSR>)diff --git a/project/web/src/app/[lng]/data-monitoring/[id]/detailPage.module.scss b/project/web/src/app/[lng]/data-monitoring/[id]/detailPage.module.scssnew file mode 100644index 00000000..963bf01c--- /dev/null+++ b/project/web/src/app/[lng]/data-monitoring/[id]/detailPage.module.scss@@ -0,0 +1,222 @@+.loadingContainer,+.errorContainer {+ display: flex;+ flex-direction: column;+ justify-content: center;+ align-items: center;+ min-height: calc(100vh - 64px);+ gap: 16px;+}++.detailPage {+ padding: 24px;+ max-width: 1200px;+ margin: 0 auto;+ min-height: calc(100vh - 64px);++ .pageHeader {+ margin-bottom: 24px;++ .pageTitle {+ font-size: 24px;+ font-weight: 600;+ color: #1a1a1a;+ margin: 0;+ display: flex;+ align-items: center;+ gap: 12px;++ .backIcon {+ cursor: pointer;+ font-size: 20px;+ color: #8c8c8c;+ transition: color 0.2s;++ &:hover {+ color: #1890ff;+ }+ }+ }+ }++ .taskInfoCard {+ margin-bottom: 16px;+ border-radius: 8px;+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);++ :global(.ant-card-body) {+ padding: 16px 24px;+ }++ .taskInfo {+ display: flex;+ align-items: center;+ gap: 32px;+ flex-wrap: wrap;++ .infoItem {+ display: flex;+ align-items: center;+ gap: 8px;++ .label {+ font-size: 14px;+ color: #8c8c8c;+ }++ .value {+ font-size: 14px;+ color: #262626;+ font-weight: 500;+ }+ }+ }+ }++ .noteCard {+ margin-bottom: 16px;+ border-radius: 8px;+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);++ .noteContent {+ display: flex;+ gap: 24px;++ .noteImage {+ flex-shrink: 0;++ :global(.ant-image) {+ display: block;+ }+ }++ .noteDetails {+ flex: 1;+ min-width: 0;++ .noteTitle {+ font-size: 20px;+ font-weight: 600;+ color: #1a1a1a;+ margin: 0 0 12px 0;+ line-height: 1.4;+ }++ .noteTags {+ display: flex;+ align-items: center;+ gap: 12px;+ margin-bottom: 16px;++ .viewLink {+ color: #1890ff;+ font-size: 14px;+ text-decoration: none;++ &:hover {+ text-decoration: underline;+ }+ }+ }++ .noteDesc {+ font-size: 14px;+ color: #595959;+ line-height: 1.6;+ margin-bottom: 20px;+ white-space: pre-wrap;+ word-break: break-word;+ overflow: auto;+ }++ .noteStats {+ display: flex;+ gap: 32px;+ padding-top: 16px;+ border-top: 1px solid #f0f0f0;++ .statItem {+ display: flex;+ align-items: center;+ gap: 6px;++ .statIcon {+ font-size: 16px;+ color: #1890ff;+ }++ .statLabel {+ font-size: 14px;+ color: #8c8c8c;+ }++ .statValue {+ font-size: 16px;+ font-weight: 600;+ color: #262626;+ }+ }+ }+ }+ }+ }++ .incrementCard {+ border-radius: 8px;+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);++ .cardTitle {+ font-size: 18px;+ font-weight: 600;+ color: #1a1a1a;+ margin: 0 0 20px 0;+ }++ :global {+ .ant-table {+ font-size: 14px;+ }++ .ant-table-thead > tr > th {+ background-color: #fafafa;+ font-weight: 600;+ color: #262626;+ }++ .ant-table-tbody > tr:hover > td {+ background-color: #f5f7fa;+ }+ }+ }+}++// 响应式设计+@media (max-width: 768px) {+ .detailPage {+ padding: 16px;++ .noteCard {+ .noteContent {+ flex-direction: column;++ .noteImage {+ width: 100%;++ :global(.ant-image) {+ width: 100%;+ }+ }+ }+ }++ .taskInfoCard {+ .taskInfo {+ gap: 16px;++ .infoItem {+ flex: 1 1 100%;+ }+ }+ }+ }+}diff --git a/project/web/src/app/[lng]/data-monitoring/[id]/page.tsx b/project/web/src/app/[lng]/data-monitoring/[id]/page.tsxnew file mode 100644index 00000000..aab5d263--- /dev/null+++ b/project/web/src/app/[lng]/data-monitoring/[id]/page.tsx@@ -0,0 +1,257 @@+'use client'++import {+ ArrowLeftOutlined,+ LikeOutlined,+ StarOutlined,+ CommentOutlined,+} from '@ant-design/icons'+import { Card, Image, message, Spin, Table, Tag } from 'antd'+import type { ColumnsType } from 'antd/es/table'+import { useParams, useRouter } from 'next/navigation'+import { useEffect, useState } from 'react'+import { useTransClient } from '@/app/i18n/client'+import {+ apiGetNoteMonitoringDetail,+ type NoteMonitoringItem,+} from '@/api/monitoring'+import styles from './detailPage.module.scss'++interface HistoryDataRecord {+ key: string+ date: string+ likeIncrement: number+ favoriteIncrement: number+ commentIncrement: number+}++export default function MonitoringDetailPage() {+ const { t } = useTransClient('dataMonitoring')+ const router = useRouter()+ const params = useParams()+ const id = params.id as string++ const [loading, setLoading] = useState(true)+ const [detail, setDetail] = useState<NoteMonitoringItem | null>(null)++ // 加载监测详情+ const loadDetail = async () => {+ setLoading(true)+ try {+ const data = await apiGetNoteMonitoringDetail(id)+ setDetail(data || null)+ }+ catch (error: any) {+ message.error(error.message || t('error.loadFailed'))+ }+ finally {+ setLoading(false)+ }+ }++ useEffect(() => {+ if (id) {+ loadDetail()+ }+ }, [id])++ // 获取每日增量数据+ const getDailyIncrements = () => {+ if (!detail?.insights || detail.insights.length === 0) return []++ // 按业务日期排序+ const sortedInsights = [...detail.insights].sort((a, b) =>+ new Date(a.businessDate).getTime() - new Date(b.businessDate).getTime()+ )++ // 直接使用 dailyDelta 数据+ return sortedInsights.map(item => ({+ key: item._id,+ date: item.businessDate,+ likeIncrement: item.dailyDelta.likeCountIncrease,+ favoriteIncrement: item.dailyDelta.favoriteCountIncrease,+ commentIncrement: item.dailyDelta.commentCountIncrease,+ }))+ }++ const tableColumns: ColumnsType<HistoryDataRecord> = [+ {+ title: t('detail.table.date'),+ dataIndex: 'date',+ key: 'date',+ width: 150,+ fixed: 'left',+ },+ {+ title: (+ <span>+ <LikeOutlined style={{ marginRight: 4 }} />+ {t('detail.table.likeIncrement')}+ </span>+ ),+ dataIndex: 'likeIncrement',+ key: 'likeIncrement',+ align: 'right',+ render: (value: number) => (+ <span style={{ color: value > 0 ? '#52c41a' : '#999', fontWeight: 'bold' }}>+ {value > 0 ? `+${value}` : value}+ </span>+ ),+ },+ {+ title: (+ <span>+ <StarOutlined style={{ marginRight: 4 }} />+ {t('detail.table.favoriteIncrement')}+ </span>+ ),+ dataIndex: 'favoriteIncrement',+ key: 'favoriteIncrement',+ align: 'right',+ render: (value: number) => (+ <span style={{ color: value > 0 ? '#52c41a' : '#999', fontWeight: 'bold' }}>+ {value > 0 ? `+${value}` : value}+ </span>+ ),+ },+ {+ title: (+ <span>+ <CommentOutlined style={{ marginRight: 4 }} />+ {t('detail.table.commentIncrement')}+ </span>+ ),+ dataIndex: 'commentIncrement',+ key: 'commentIncrement',+ align: 'right',+ render: (value: number) => (+ <span style={{ color: value > 0 ? '#52c41a' : '#999', fontWeight: 'bold' }}>+ {value > 0 ? `+${value}` : value}+ </span>+ ),+ },+ ]++ if (loading) {+ return (+ <div className={styles.loadingContainer}>+ <Spin size="large" />+ </div>+ )+ }++ if (!detail) {+ return (+ <div className={styles.errorContainer}>+ <p>{t('detail.notFound')}</p>+ </div>+ )+ }++ return (+ <div className={styles.detailPage}>+ {/* 页面标题 */}+ <div className={styles.pageHeader}>+ <h1 className={styles.pageTitle}>+ <ArrowLeftOutlined+ className={styles.backIcon}+ onClick={() => router.back()}+ />+ {t('detail.pageTitle')}+ </h1>+ </div>++ {/* 任务信息 */}+ <Card className={styles.taskInfoCard}>+ <div className={styles.taskInfo}>+ <div className={styles.infoItem}>+ <span className={styles.label}>{t('detail.taskId')}:</span>+ <span className={styles.value}>{detail._id.substring(0, 12)}</span>+ </div>+ <div className={styles.infoItem}>+ <span className={styles.label}>{t('detail.startTime')}:</span>+ <span className={styles.value}>+ {new Date(detail.createdAt).toLocaleString('zh-CN')}+ </span>+ </div>+ <div className={styles.infoItem}>+ <span className={styles.label}>{t('detail.updateTime')}:</span>+ <span className={styles.value}>+ {new Date(detail.updatedAt).toLocaleString('zh-CN')}+ </span>+ </div>++ </div>+ </Card>++ {/* 笔记信息 */}+ <Card className={styles.noteCard}>+ <div className={styles.noteContent}>+ {detail.postDetail?.cover && (+ <div className={styles.noteImage}>+ <Image+ src={detail.postDetail.cover}+ alt={detail.postDetail.title || t('detail.noteCover')}+ width={500}+ height={500}+ style={{ objectFit: 'cover', borderRadius: '8px' }}+ />+ </div>+ )}+ <div className={styles.noteDetails}>+ <h2 className={styles.noteTitle}>+ {detail.postDetail?.title || t('list.untitled')}+ </h2>+ <div className={styles.noteTags}>+ {detail.link && (+ <a href={detail.link} target="_blank" rel="noopener noreferrer" className={styles.viewLink}>+ {t('detail.viewOriginal')} →+ </a>+ )}+ </div>+ <div className={styles.noteDesc}>+ {detail.postDetail?.desc && detail.postDetail.desc.length > 500+ ? `${detail.postDetail.desc.substring(0, 500)}...`+ : detail.postDetail?.desc}+ </div>+ <div className={styles.noteStats}>+ <div className={styles.statItem}>+ <LikeOutlined className={styles.statIcon} />+ <span className={styles.statLabel}>{t('stats.likes')}:</span>+ <span className={styles.statValue}>{detail.postDetail?.likeCount || 0}</span>+ </div>+ <div className={styles.statItem}>+ <StarOutlined className={styles.statIcon} />+ <span className={styles.statLabel}>{t('stats.favorites')}:</span>+ <span className={styles.statValue}>{detail.postDetail?.collectCount || 0}</span>+ </div>+ <div className={styles.statItem}>+ <CommentOutlined className={styles.statIcon} />+ <span className={styles.statLabel}>{t('stats.comments')}:</span>+ <span className={styles.statValue}>{detail.postDetail?.commentCount || 0}</span>+ </div>+ </div>+ </div>+ </div>+ </Card>++ {/* 增量视图 */}+ <Card className={styles.incrementCard}>+ <h3 className={styles.cardTitle}>{t('detail.dailyIncrement')}</h3>+ <Table+ columns={tableColumns}+ dataSource={getDailyIncrements()}+ pagination={{+ pageSize: 10,+ showSizeChanger: false,+ showTotal: total => t('detail.table.totalDays', { count: total }),+ }}+ locale={{+ emptyText: t('detail.noData')+ }}+ />+ </Card>+ </div>+ )+}+diff --git a/project/web/src/app/[lng]/data-monitoring/dataMonitoring.module.scss b/project/web/src/app/[lng]/data-monitoring/dataMonitoring.module.scssnew file mode 100644index 00000000..ce133afc--- /dev/null+++ b/project/web/src/app/[lng]/data-monitoring/dataMonitoring.module.scss@@ -0,0 +1,501 @@+.dataMonitoringPage {+ padding: 24px;+ background-color: #f5f5f5;+ min-height: calc(100vh - 64px);++ .pageHeader {+ display: flex;+ align-items: center;+ gap: 16px;+ margin-bottom: 24px;+ padding: 24px;+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);+ border-radius: 12px;+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);++ .headerIcon {+ font-size: 48px;+ line-height: 1;+ }++ .headerContent {+ flex: 1;++ .pageTitle {+ margin: 0;+ font-size: 28px;+ font-weight: 600;+ color: #fff;+ }++ .pageDesc {+ margin: 8px 0 0;+ font-size: 14px;+ color: rgba(255, 255, 255, 0.9);+ }+ }+ }++ .tabsCard {+ background: #fff;+ border-radius: 12px;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);++ .monitoringTabs {+ :global {+ .ant-tabs-nav {+ margin-bottom: 0;+ }++ .ant-tabs-tab {+ font-size: 16px;+ padding: 12px 24px;++ &.ant-tabs-tab-active {+ .ant-tabs-tab-btn {+ color: #667eea;+ font-weight: 600;+ }+ }+ }++ .ant-tabs-ink-bar {+ background: #667eea;+ }+ }+ }++ .tabContent {+ padding: 24px 0;+ min-height: 400px;+ }+ }++ .addSection {+ display: flex;+ justify-content: center;+ padding: 24px 0;++ .addCard {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 16px;+ padding: 48px 64px;+ border: 2px dashed #d9d9d9;+ border-radius: 12px;+ background: #fafafa;+ transition: all 0.3s ease;++ &:hover {+ border-color: #667eea;+ background: #f0f2ff;+ }++ .addIcon {+ font-size: 48px;+ color: #667eea;+ }++ .addTitle {+ margin: 0;+ font-size: 18px;+ font-weight: 500;+ color: #333;+ }++ .addButton {+ min-width: 120px;+ height: 40px;+ font-size: 16px;+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);+ border: none;+ border-radius: 8px;++ &:hover {+ background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);+ }++ &:disabled {+ background: #d9d9d9;+ cursor: not-allowed;+ }+ }+ }+ }++ .loading {+ display: flex;+ justify-content: center;+ align-items: center;+ padding: 80px 0;+ }++ .monitoringList {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));+ gap: 20px;+ padding: 24px;++ .monitoringCard {+ border-radius: 12px;+ overflow: hidden;+ transition: all 0.3s ease;++ &:hover {+ transform: translateY(-4px);+ box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);+ }++ .coverWrapper {+ height: 200px;+ overflow: hidden;+ background: #f5f5f5;++ .coverImage {+ width: 100%;+ height: 100%;+ object-fit: cover;+ }+ }++ .cardHeader {+ display: flex;+ justify-content: space-between;+ align-items: flex-start;+ margin-bottom: 16px;+ padding-bottom: 12px;+ border-bottom: 1px solid #f0f0f0;++ .noteTitle {+ margin: 0;+ font-size: 16px;+ font-weight: 600;+ color: #333;+ flex: 1;+ overflow: hidden;+ text-overflow: ellipsis;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ -webkit-box-orient: vertical;+ line-height: 1.5;+ max-height: 3em;+ }++ .headerRight {+ display: flex;+ flex-direction: column;+ align-items: flex-end;+ gap: 8px;+ margin-left: 12px;+ flex-shrink: 0;+ }++ .platform {+ padding: 4px 12px;+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);+ color: #fff;+ font-size: 12px;+ border-radius: 12px;+ }+ }++ .cardStats {+ display: grid;+ grid-template-columns: repeat(2, 1fr);+ gap: 12px;+ margin-bottom: 16px;++ .statItem {+ display: flex;+ flex-direction: column;+ padding: 12px;+ background: #f9fafb;+ border-radius: 8px;++ .statLabel {+ font-size: 12px;+ color: #999;+ margin-bottom: 4px;+ }++ .statValue {+ font-size: 20px;+ font-weight: 600;+ color: #333;+ }+ }+ }++ .errorMessage {+ margin: 12px 0;+ }++ .cardFooter {+ display: flex;+ justify-content: space-between;+ padding-top: 12px;+ border-top: 1px solid #f0f0f0;++ .createTime,+ .updateTime {+ font-size: 12px;+ color: #999;+ }+ }+ }+ }++ .paginationWrapper {+ display: flex;+ justify-content: center;+ padding: 24px 0;+ }++ .empty {+ padding: 80px 0;+ }++ .linkMonitoring,+ .accountMonitoring {+ min-height: 400px;+ }++ .addModalContent {+ padding: 16px 0;++ .modalDesc {+ margin-bottom: 16px;+ font-size: 14px;+ color: #666;+ }++ :global {+ .ant-input-affix-wrapper {+ border-radius: 8px;+ padding: 12px 16px;++ &:hover,+ &:focus,+ &.ant-input-affix-wrapper-focused {+ border-color: #667eea;+ box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);+ }+ }+ }+ }++ // 详情弹窗样式+ .detailLoading {+ display: flex;+ justify-content: center;+ align-items: center;+ padding: 80px 0;+ }++ .detailContent {+ .postInfo {+ margin-bottom: 24px;+ padding-bottom: 24px;+ border-bottom: 1px solid #f0f0f0;++ h3 {+ margin: 0 0 12px;+ font-size: 20px;+ font-weight: 600;+ color: #333;+ }++ .desc {+ margin: 8px 0;+ font-size: 14px;+ color: #666;+ line-height: 1.6;+ }++ .metaInfo {+ display: flex;+ flex-wrap: wrap;+ gap: 16px;+ margin-top: 12px;+ font-size: 13px;+ color: #999;+ }+ }++ .mediaSection {+ margin-bottom: 24px;+ padding-bottom: 24px;+ border-bottom: 1px solid #f0f0f0;++ h4 {+ margin: 0 0 16px;+ font-size: 16px;+ font-weight: 600;+ color: #333;+ }++ .mediaList {+ display: flex;+ flex-wrap: wrap;+ gap: 8px;+ }+ }++ .statsSection {+ margin-bottom: 24px;+ padding: 20px;+ background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);+ border-radius: 12px;++ h4 {+ margin: 0 0 16px;+ font-size: 18px;+ font-weight: 600;+ color: #667eea;+ }++ .statsGrid {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));+ gap: 12px;++ .statBox {+ padding: 16px;+ background: #fff;+ border-radius: 8px;+ text-align: center;+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);++ .statLabel {+ font-size: 12px;+ color: #999;+ margin-bottom: 8px;+ }++ .statNumber {+ font-size: 24px;+ font-weight: 700;+ color: #333;+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);+ -webkit-background-clip: text;+ -webkit-text-fill-color: transparent;+ background-clip: text;+ }+ }+ }+ }++ .historySection {+ h4 {+ margin: 0 0 16px;+ font-size: 16px;+ font-weight: 600;+ color: #333;+ }++ .historyList {+ max-height: 400px;+ overflow-y: auto;+ padding-right: 8px;++ &::-webkit-scrollbar {+ width: 6px;+ }++ &::-webkit-scrollbar-track {+ background: #f1f1f1;+ border-radius: 3px;+ }++ &::-webkit-scrollbar-thumb {+ background: #888;+ border-radius: 3px;++ &:hover {+ background: #555;+ }+ }++ .historyItem {+ padding: 16px;+ margin-bottom: 12px;+ background: #fafafa;+ border-radius: 8px;+ border-left: 3px solid #667eea;++ &:last-child {+ margin-bottom: 0;+ }++ .historyTime {+ font-size: 13px;+ color: #667eea;+ font-weight: 600;+ margin-bottom: 8px;+ }++ .historyStats {+ display: flex;+ flex-wrap: wrap;+ gap: 16px;+ font-size: 13px;+ color: #666;++ span {+ display: flex;+ align-items: center;+ gap: 4px;+ }+ }+ }+ }+ }+ }+}++// 响应式设计+@media (max-width: 768px) {+ .dataMonitoringPage {+ padding: 16px;++ .pageHeader {+ padding: 16px;++ .headerIcon {+ font-size: 36px;+ }++ .headerContent {+ .pageTitle {+ font-size: 20px;+ }++ .pageDesc {+ font-size: 12px;+ }+ }+ }++ .monitoringList {+ grid-template-columns: 1fr;+ padding: 16px;+ }++ .addSection {+ .addCard {+ padding: 32px 48px;++ .addIcon {+ font-size: 36px;+ }++ .addTitle {+ font-size: 16px;+ }+ }+ }+ }+}+diff --git a/project/web/src/app/[lng]/data-monitoring/page.tsx b/project/web/src/app/[lng]/data-monitoring/page.tsxnew file mode 100644index 00000000..f2bd6fc4--- /dev/null+++ b/project/web/src/app/[lng]/data-monitoring/page.tsx@@ -0,0 +1,270 @@+'use client'++import { EyeOutlined, LinkOutlined, UserOutlined } from '@ant-design/icons'+import { Badge, Button, Card, Empty, Input, message, Modal, Pagination, Spin, Tabs, Tag } from 'antd'+import { useRouter } from 'next/navigation'+import { useEffect, useState } from 'react'+import { useTransClient } from '@/app/i18n/client'+import {+ apiAddNoteMonitoring,+ apiGetNoteMonitoringList,+ type NoteMonitoringListItem,+} from '@/api/monitoring'+import styles from './dataMonitoring.module.scss'++export default function DataMonitoringPage() {+ const { t } = useTransClient('dataMonitoring')+ const router = useRouter()+ const [activeTab, setActiveTab] = useState<'link' | 'account'>('link')+ const [loading, setLoading] = useState(false)+ const [monitoringList, setMonitoringList] = useState<NoteMonitoringListItem[]>([])+ const [pagination, setPagination] = useState({ page: 1, pageSize: 20, total: 0, totalPages: 0 })+ const [addModalVisible, setAddModalVisible] = useState(false)+ const [noteLink, setNoteLink] = useState('')+ const [addLoading, setAddLoading] = useState(false)++ // 加载监控列表+ const loadMonitoringList = async (page: number = 1) => {+ setLoading(true)+ try {+ const data = await apiGetNoteMonitoringList({ platform: 'xhs', page, pageSize: 20 })+ setMonitoringList(data.items)+ setPagination({+ page: data.page,+ pageSize: data.pageSize,+ total: data.total,+ totalPages: data.totalPages,+ })+ }+ catch (error: any) {+ message.error(error.message || t('error.loadFailed'))+ }+ finally {+ setLoading(false)+ }+ }++ useEffect(() => {+ if (activeTab === 'link') {+ loadMonitoringList(1)+ }+ }, [activeTab])++ // 分页变化+ const handlePageChange = (page: number) => {+ loadMonitoringList(page)+ }++ // 添加笔记监控+ const handleAddNote = async () => {+ if (!noteLink.trim()) {+ message.warning(t('addModal.linkRequired'))+ return+ }++ setAddLoading(true)+ try {+ await apiAddNoteMonitoring({ link: noteLink, platform: 'xhs' })+ message.success(t('addModal.addSuccess'))+ setAddModalVisible(false)+ setNoteLink('')+ loadMonitoringList(1)+ }+ catch (error: any) {+ message.error(error.message || t('error.addFailed'))+ }+ finally {+ setAddLoading(false)+ }+ }++ // 查看监控详情+ const handleViewDetail = (item: NoteMonitoringListItem) => {+ router.push(`/data-monitoring/${item._id}`)+ }++ // 获取状态标签+ const getStatusTag = (status: string) => {+ const statusMap: Record<string, { color: string }> = {+ pending: { color: 'default' },+ processing: { color: 'processing' },+ completed: { color: 'success' },+ success: { color: 'success' },+ failed: { color: 'error' },+ }+ const statusInfo = statusMap[status] || statusMap.pending+ return <Tag color={statusInfo.color}>{t(`status.${status}` as any)}</Tag>+ }++ const tabItems = [+ {+ key: 'link',+ label: (+ <span>+ <LinkOutlined />+ {t('tabs.byLink')}+ </span>+ ),+ },+ ]++ return (+ <div className={styles.dataMonitoringPage}>+ {/* 页面标题 */}+ <div className={styles.pageHeader}>+ <div className={styles.headerContent}>+ <h1 className={styles.pageTitle}>{t('title')}</h1>+ <p className={styles.pageDesc}>{t('description')}</p>+ </div>+ </div>++ {/* 选项卡 */}+ <Card className={styles.tabsCard}>+ <Tabs+ activeKey={activeTab}+ onChange={key => setActiveTab(key as 'link' | 'account')}+ items={tabItems}+ className={styles.monitoringTabs}+ />++ <div className={styles.tabContent}>+ {/* 按笔记链接 */}+ {activeTab === 'link' && (+ <div className={styles.linkMonitoring}>+ <div className={styles.addSection}>+ <div className={styles.addCard}>+ <LinkOutlined className={styles.addIcon} />+ <h3 className={styles.addTitle}>{t('tabs.byLink')}</h3>+ <Button+ type="primary"+ onClick={() => setAddModalVisible(true)}+ className={styles.addButton}+ >+ {t('actions.add')}+ </Button>+ </div>+ </div>++ {/* 监控列表 */}+ {loading ? (+ <div className={styles.loading}>+ <Spin size="large" />+ </div>+ ) : monitoringList.length > 0 ? (+ <>+ <div className={styles.monitoringList}>+ {monitoringList.map(item => (+ <Card+ key={item._id}+ className={styles.monitoringCard}+ hoverable+ actions={[+ <Button+ key="view"+ type="link"+ icon={<EyeOutlined />}+ onClick={() => handleViewDetail(item)}+ >+ {t('actions.viewDetail')}+ </Button>,+ ]}+ >+ <div className={styles.cardHeader}>+ <h4 className={styles.noteTitle}>+ {item.link}+ </h4>+ <div className={styles.headerRight} style={{ marginRight: '0' }}>+ {getStatusTag(item.status)}+ <Badge++ status={item.enabled ? 'success' : 'default'}+ text={item.enabled ? t('status.enabled') : t('status.disabled')}+ />+ </div>+ </div>+ {item.error && (+ <div className={styles.errorMessage}>+ <Tag color="error">{t('list.error')}: {item.error}</Tag>+ </div>+ )}+ <div className={styles.cardFooter}>+ <span className={styles.createTime}>+ {t('list.createdAt')}: {new Date(item.createdAt).toLocaleString('zh-CN')}+ </span>+ <span className={styles.updateTime}>+ {t('list.updatedAt')}: {new Date(item.updatedAt).toLocaleString('zh-CN')}+ </span>+ </div>+ </Card>+ ))}+ </div>+ {/* 分页 */}+ <div className={styles.paginationWrapper}>+ <Pagination+ current={pagination.page}+ pageSize={pagination.pageSize}+ total={pagination.total}+ onChange={handlePageChange}+ showSizeChanger={false}+ showTotal={total => t('list.totalRecords', { count: total })}+ />+ </div>+ </>+ ) : (+ <Empty+ description={t('list.empty')}+ className={styles.empty}+ />+ )}+ </div>+ )}++ {/* 按小红书账号 - 暂未开放 */}+ {activeTab === 'account' && (+ <div className={styles.accountMonitoring}>+ <div className={styles.addSection}>+ <div className={styles.addCard}>+ <UserOutlined className={styles.addIcon} />+ <h3 className={styles.addTitle}>{t('tabs.byAccount')}</h3>+ <Button+ type="primary"+ disabled+ className={styles.addButton}+ >+ {t('actions.comingSoon')}+ </Button>+ </div>+ </div>+ </div>+ )}+ </div>+ </Card>++ {/* 添加笔记链接弹窗 */}+ <Modal+ title={t('addModal.title')}+ open={addModalVisible}+ onOk={handleAddNote}+ onCancel={() => {+ setAddModalVisible(false)+ setNoteLink('')+ }}+ confirmLoading={addLoading}+ okText={t('addModal.confirm')}+ cancelText={t('addModal.cancel')}+ >+ <div className={styles.addModalContent}>+ <p className={styles.modalDesc}>{t('addModal.inputPlaceholder')}</p>+ <Input+ placeholder={t('addModal.linkPlaceholder')}+ value={noteLink}+ onChange={e => setNoteLink(e.target.value)}+ prefix={<LinkOutlined />}+ size="large"+ />+ </div>+ </Modal>+ </div>+ )+}+diff --git a/project/web/src/app/[lng]/page.tsx b/project/web/src/app/[lng]/page.tsxindex b724d76f..b4272583 100644--- a/project/web/src/app/[lng]/page.tsx+++ b/project/web/src/app/[lng]/page.tsx@@ -1,6 +1,18 @@'use client'-import { AndroidOutlined } from '@ant-design/icons'+import {+ AndroidOutlined,+ BulbOutlined,+ ClockCircleOutlined,+ FileTextOutlined,+ PictureOutlined,+ VideoCameraOutlined,+ EditOutlined,+ CheckCircleOutlined,+ CloseCircleOutlined,+ StopOutlined,+ FieldTimeOutlined,+} from '@ant-design/icons'import Image from 'next/image'import { useParams, useRouter } from 'next/navigation'import { useEffect, useRef, useState } from 'react'@@ -75,75 +87,347 @@ function ReleaseBanner() {)}+// 加载动画组件(...动画)+function LoadingDots() {+ return (+ <span className={styles.loadingDots}>+ <span className={styles.dot}>.</span>+ <span className={styles.dot}>.</span>+ <span className={styles.dot}>.</span>+ </span>+ )+}+// Hero main title sectionfunction Hero() {const { t } = useTransClient('home')- const [displayedText, setDisplayedText] = useState('')- const [currentIndex, setCurrentIndex] = useState(0)- const [isTypingComplete, setIsTypingComplete] = useState(false)- const [hideCursor, setHideCursor] = useState(false)- const [startTyping, setStartTyping] = useState(false)const router = useRouter()+ const { lng } = useParams()- // Full text to display- const fullText = t('hero.title')- const typingSpeed = 120 // Typing speed (milliseconds)- const initialDelay = 800 // Initial delay (milliseconds)- const cursorHideDelay = 2000 // Delay before hiding cursor after typing completes+ // AI generation related states+ const [prompt, setPrompt] = useState('')+ const [isGenerating, setIsGenerating] = useState(false)+ const [taskId, setTaskId] = useState('')++ // Message type definition+ type MessageItem = {+ type: 'status' | 'description' | 'error' | 'text'+ content: string+ status?: string // Status type for rendering corresponding icon+ loading?: boolean // Whether to show loading animation (for media generation status)+ }++ const [completedMessages, setCompletedMessages] = useState<MessageItem[]>([]) // Completed messages+ const [currentTypingMsg, setCurrentTypingMsg] = useState<MessageItem | null>(null) // Current typing message+ const [displayedText, setDisplayedText] = useState('') // Currently displayed text+ const [pendingMessages, setPendingMessages] = useState<MessageItem[]>([]) // Pending message queue+ const progressContainerRef = useRef<HTMLDivElement>(null) // Progress container reference+ const [progress, setProgress] = useState(0) // Progress percentage 0-100++ // Status display configuration (icons and text)+ const getStatusDisplay = (status: string) => {+ const statusConfig: Record<string, { icon: React.ReactNode; text: string; color?: string }> = {+ 'THINKING': {+ icon: <BulbOutlined style={{ marginRight: '8px', color: '#a66ae4' }} />,+ text: t('aiGeneration.status.thinking' as any),+ color: '#a66ae4'+ },+ 'WAITING': {+ icon: <ClockCircleOutlined style={{ marginRight: '8px', color: '#b78ae9' }} />,+ text: t('aiGeneration.status.waiting' as any),+ color: '#b78ae9'+ },+ 'GENERATING_CONTENT': {+ icon: <FileTextOutlined style={{ marginRight: '8px', color: '#a66ae4' }} />,+ text: t('aiGeneration.status.generatingContent' as any),+ color: '#a66ae4'+ },+ 'GENERATING_IMAGE': {+ icon: <PictureOutlined style={{ marginRight: '8px', color: '#8b4fd9' }} />,+ text: t('aiGeneration.status.generatingImage' as any),+ color: '#8b4fd9'+ },+ 'GENERATING_VIDEO': {+ icon: <VideoCameraOutlined style={{ marginRight: '8px', color: '#9558de' }} />,+ text: t('aiGeneration.status.generatingVideo' as any),+ color: '#9558de'+ },+ 'GENERATING_TEXT': {+ icon: <EditOutlined style={{ marginRight: '8px', color: '#a66ae4' }} />,+ text: t('aiGeneration.status.generatingText' as any),+ color: '#a66ae4'+ },+ 'COMPLETED': {+ icon: <CheckCircleOutlined style={{ marginRight: '8px', color: '#52c41a' }} />,+ text: t('aiGeneration.status.completed' as any),+ color: '#52c41a'+ },+ 'FAILED': {+ icon: <CloseCircleOutlined style={{ marginRight: '8px', color: '#ff4d4f' }} />,+ text: t('aiGeneration.status.failed' as any),+ color: '#ff4d4f'+ },+ 'CANCELLED': {+ icon: <StopOutlined style={{ marginRight: '8px', color: '#8c8c8c' }} />,+ text: t('aiGeneration.status.cancelled' as any),+ color: '#8c8c8c'+ },+ }+ return statusConfig[status] || { icon: null, text: status, color: '#333' }+ }- useEffect(() => {- // Start typing after initial delay- const startTimer = setTimeout(() => {- setStartTyping(true)- }, initialDelay)+ // Calculate progress (receives current progress as parameter to avoid closure issues)+ const calculateProgress = (status: string, isNewStatus: boolean, currentProgress: number) => {+ const baseProgress: Record<string, number> = {+ 'THINKING': 10,+ 'WAITING': 20,+ 'GENERATING_CONTENT': 30,+ 'GENERATING_TEXT': 40,+ 'GENERATING_IMAGE': 50,+ 'GENERATING_VIDEO': 60,+ 'COMPLETED': 100,+ }- return () => clearTimeout(startTimer)- }, [])+ // If in generating status (not first time), increase by 5%+ const generatingStatuses = ['GENERATING_CONTENT', 'GENERATING_IMAGE', 'GENERATING_VIDEO', 'GENERATING_TEXT']++ if (generatingStatuses.includes(status) && !isNewStatus) {+ // Increase 5% each polling, but not exceed 99%+ return Math.min(currentProgress + 5, 99)+ }+ // For new status, take max of current progress and base progress (ensure progress only increases)+ if (isNewStatus) {+ const targetProgress = baseProgress[status]+ if (targetProgress !== undefined) {+ return Math.max(currentProgress, targetProgress)+ }+ }++ return currentProgress+ }++ // Add new message to queue+ const addMessageToQueue = (msg: MessageItem) => {+ setPendingMessages(prev => [...prev, msg])+ }++ // Typewriter effect - process message queueuseEffect(() => {- if (startTyping && currentIndex < fullText.length) {- const currentChar = fullText[currentIndex]+ // If no current typing message and queue has pending messages+ if (!currentTypingMsg && pendingMessages.length > 0) {+ const nextMsg = pendingMessages[0]+ setCurrentTypingMsg(nextMsg)+ setDisplayedText('')+ setPendingMessages(prev => prev.slice(1))+ }+ }, [currentTypingMsg, pendingMessages])- // Adjust typing speed based on character type- let currentSpeed = typingSpeed- if (currentChar === '\n') {- currentSpeed = typingSpeed * 2 // Pause slightly on line break- }- else if (currentChar === ' ') {- currentSpeed = typingSpeed * 0.5 // Space is faster- }- else if (/[,。!?;:]/.test(currentChar)) {- currentSpeed = typingSpeed * 1.5 // Pause slightly on punctuation- }- else {- // Add some randomness to make typing more natural- currentSpeed = typingSpeed + Math.random() * 50 - 25- }+ // Typewriter effect - display character by character+ useEffect(() => {+ if (currentTypingMsg && displayedText.length < currentTypingMsg.content.length) {+ const timer = setTimeout(() => {+ setDisplayedText(currentTypingMsg.content.slice(0, displayedText.length + 1))+ }, 80) // Typing speed 80ms per character+ return () => clearTimeout(timer)+ }+ // Current message finished typing+ else if (currentTypingMsg && displayedText.length >= currentTypingMsg.content.length) {const timer = setTimeout(() => {- setDisplayedText(prev => prev + fullText[currentIndex])- setCurrentIndex(prev => prev + 1)- }, currentSpeed)+ // Move current message to completed list+ setCompletedMessages(prev => [...prev, currentTypingMsg])+ setCurrentTypingMsg(null)+ setDisplayedText('')+ }, 200) // Wait 200ms before next messagereturn () => clearTimeout(timer)}- else if (currentIndex >= fullText.length && !isTypingComplete) {- setIsTypingComplete(true)- // Delay hiding cursor after typing completes- setTimeout(() => {- setHideCursor(true)- }, cursorHideDelay)+ }, [currentTypingMsg, displayedText])++ // Auto scroll to bottom+ useEffect(() => {+ if (progressContainerRef.current) {+ progressContainerRef.current.scrollTop = progressContainerRef.current.scrollHeight+ }+ }, [completedMessages, displayedText])++ // Create AI generation task+ const handleCreateTask = async () => {+ if (!prompt.trim()) {+ alert(t('aiGeneration.emptyPromptAlert' as any))+ return+ }++ try {+ setIsGenerating(true)+ setCompletedMessages([])+ setPendingMessages([])+ setCurrentTypingMsg(null)+ setDisplayedText('')+ setProgress(0) // Reset progress++ // Step 1: Show THINKING status+ addMessageToQueue({+ type: 'status',+ content: t('aiGeneration.thinking' as any),+ status: 'THINKING'+ })++ // Step 2: Show user's prompt+ addMessageToQueue({+ type: 'text',+ content: `📝 ${t('aiGeneration.topicPrefix' as any)}${prompt}`+ })++ // Set initial progress to 10%+ setProgress(10)++ // Dynamic import API+ const { agentApi } = await import('@/api/agent')++ // Create task+ const createRes = await agentApi.createTask({ prompt })+ if (createRes?.code === 0 && createRes.data?.id) {+ const newTaskId = createRes.data.id+ setTaskId(newTaskId)++ // Start polling task status+ pollTaskStatus(newTaskId)+ } else {+ throw new Error(t('aiGeneration.createTaskFailed' as any))+ }+ } catch (error: any) {+ alert(`${t('aiGeneration.createTaskFailed' as any)}: ${error.message || t('aiGeneration.unknownError' as any)}`)+ setIsGenerating(false)+ setProgress(0) // Reset progress}- }, [startTyping, currentIndex, fullText, typingSpeed, isTypingComplete, cursorHideDelay])-- // Convert text to JSX, handle line breaks- const renderText = () => {- return displayedText.split('\n').map((line, index, array) => (- <span key={index}>- {line}- {index < array.length - 1 && <br />}- </span>- ))+ }++ // Poll task status+ const pollTaskStatus = async (taskId: string) => {+ const { agentApi } = await import('@/api/agent')+ let lastStatus = ''+ let hasShownTitle = false+ let hasShownDescription = false++ const poll = async () => {+ try {+ const res = await agentApi.getTaskDetail(taskId)++ if (res?.code === 0 && res.data) {+ const taskData = res.data++ // Show title if available and not shown yet+ if (taskData.title && !hasShownTitle) {+ addMessageToQueue({+ type: 'text',+ content: `✨ ${t('aiGeneration.generatedTitlePrefix' as any)}${taskData.title}`+ })+ hasShownTitle = true+ }++ // Show description if available and not shown yet (before status)+ if (taskData.description && !hasShownDescription) {+ addMessageToQueue({+ type: 'description',+ content: `${t('aiGeneration.descriptionPrefix' as any)}${taskData.description}`+ })+ hasShownDescription = true+ }++ // Add new message when status changes (skip THINKING as it's already shown in step 1)+ if (taskData.status !== lastStatus && taskData.status !== 'THINKING') {+ const statusDisplay = getStatusDisplay(taskData.status)+ // Mark media generation statuses to need loading animation+ const needsLoadingAnimation = taskData.status === 'GENERATING_VIDEO' ||+ taskData.status === 'GENERATING_IMAGE' ||+ taskData.status === 'GENERATING_CONTENT' ||+ taskData.status === 'GENERATING_TEXT'++ addMessageToQueue({+ type: 'status',+ content: statusDisplay.text,+ status: taskData.status,+ loading: needsLoadingAnimation+ } as any)++ // Update progress (new status) - use functional update to avoid closure issues+ setProgress(prev => calculateProgress(taskData.status, true, prev))++ lastStatus = taskData.status+ } else if (taskData.status === 'THINKING') {+ // Only record status, don't show message+ lastStatus = taskData.status+ } else if (taskData.status === lastStatus) {+ // For same status, if it's generating status, increase progress+ const generatingStatuses = ['GENERATING_CONTENT', 'GENERATING_IMAGE', 'GENERATING_VIDEO', 'GENERATING_TEXT']+ if (generatingStatuses.includes(taskData.status)) {+ // Use functional update to avoid closure issues+ setProgress(prev => calculateProgress(taskData.status, false, prev))+ }+ }++ // If task completed+ if (taskData.status === 'COMPLETED') {+ setIsGenerating(false)++ // Delay navigation to ensure last message is displayed+ setTimeout(() => {+ // Build navigation params+ const queryParams = new URLSearchParams({+ aiGenerated: 'true',+ taskId: taskData.id,+ title: taskData.title || '',+ description: taskData.description || '',+ tags: JSON.stringify(taskData.tags || []),+ medias: JSON.stringify(taskData.medias || []),+ })++ // Navigate to accounts page+ router.push(`/${lng}/accounts?${queryParams.toString()}`)+ }, 1500)+ return+ }+ // If task failed+ else if (taskData.status === 'FAILED') {+ addMessageToQueue({+ type: 'error',+ content: `${t('aiGeneration.failedReasonPrefix' as any)}${taskData.errorMessage || t('aiGeneration.unknownError' as any)}`+ })+ setIsGenerating(false)+ setProgress(0) // Reset progress+ return+ }+ // If task cancelled+ else if (taskData.status === 'CANCELLED') {+ setIsGenerating(false)+ setProgress(0) // Reset progress+ return+ }++ // Continue polling+ setTimeout(poll, 2000)+ }+ } catch (error) {+ setTimeout(poll, 2000)+ }+ }++ // Start polling+ poll()++ // Set maximum polling time to 10 minutes+ setTimeout(() => {+ if (isGenerating) {+ setIsGenerating(false)+ setProgress(0) // Reset progress+ addMessageToQueue({+ type: 'error',+ content: t('aiGeneration.taskTimeout' as any)+ })+ }+ }, 600000)}return (@@ -160,10 +444,125 @@ function Hero() {<span className={styles.githubText}>{t('hero.github')}</span></div>- <h1 className={styles.heroTitle}>- {renderText()}- <span className={`${styles.cursor} ${hideCursor ? styles.cursorHidden : styles.cursorVisible}`}>|</span>- </h1>+ {/* AI Generation Input */}+ <div className={styles.aiGenerationWrapper}>+ <div className={styles.aiInputContainer}>+ <input+ type="text"+ value={prompt}+ onChange={(e) => setPrompt(e.target.value)}+ onKeyPress={(e) => {+ if (e.key === 'Enter' && !isGenerating) {+ handleCreateTask()+ }+ }}+ placeholder={t('aiGeneration.inputPlaceholder' as any)}+ disabled={isGenerating}+ className={styles.aiInput}+ />+ <button+ onClick={handleCreateTask}+ disabled={isGenerating || !prompt.trim()}+ className={styles.aiGenerateBtn}+ >+ {isGenerating ? t('aiGeneration.generating' as any) : t('aiGeneration.generateButton' as any)}+ </button>+ </div>++ {/* Progress Display Area */}+ {(isGenerating || completedMessages.length > 0 || currentTypingMsg) && (+ <div className={styles.aiProgressWrapper}>+ <div+ ref={progressContainerRef}+ className={styles.aiProgressContainer}+ style={{+ borderBottom: progress > 0 ? 'none' : '1px solid rgba(0, 0, 0, 0.08)',+ borderRadius: progress > 0 ? '12px 12px 0 0' : '12px',+ }}+ >+ {/* Top loading indicator - only shown when generating */}+ {isGenerating && (+ <div style={{+ position: 'absolute',+ top: 0,+ left: 0,+ right: 0,+ height: '2px',+ background: 'linear-gradient(90deg, transparent, #a66ae4, transparent)',+ animation: 'slideRight 2s infinite',+ zIndex: 10,+ }} />+ )}++ {/* Continuous text stream display */}+ <div className={styles.aiProgressContent}>+ {/* Completed messages - continuous text */}+ {completedMessages.map((msg, index) => {+ const statusDisplay = msg.status ? getStatusDisplay(msg.status) : null+ const isDescription = msg.type === 'description'+ const isError = msg.type === 'error'+ const isText = msg.type === 'text'++ return (+ <div+ key={`completed-${index}`}+ className={styles.aiProgressMessage}+ style={{+ color: isError ? '#ff4d4f' : statusDisplay?.color || '#333',+ }}+ >+ {statusDisplay && statusDisplay.icon}+ {isDescription && <FileTextOutlined style={{ marginRight: '8px', color: '#52c41a', flexShrink: 0 }} />}+ {isError && <CloseCircleOutlined style={{ marginRight: '8px', color: '#ff4d4f', flexShrink: 0 }} />}+ {isText && !statusDisplay && <span style={{ marginRight: '8px' }}></span>}+ <span style={{ textAlign: 'left', flex: 1 }}>+ {msg.content}+ {msg.loading && <LoadingDots />}+ </span>+ </div>+ )+ })}++ {/* Current typing message */}+ {currentTypingMsg && displayedText && (+ <div+ className={styles.aiProgressMessage}+ style={{+ color: currentTypingMsg.type === 'error'+ ? '#ff4d4f'+ : currentTypingMsg.status+ ? getStatusDisplay(currentTypingMsg.status).color+ : '#333',+ }}+ >+ {currentTypingMsg.status && getStatusDisplay(currentTypingMsg.status).icon}+ {currentTypingMsg.type === 'description' && <FileTextOutlined style={{ marginRight: '8px', color: '#52c41a', flexShrink: 0 }} />}+ {currentTypingMsg.type === 'error' && <CloseCircleOutlined style={{ marginRight: '8px', color: '#ff4d4f', flexShrink: 0 }} />}+ {currentTypingMsg.type === 'text' && !currentTypingMsg.status && <span style={{ marginRight: '8px' }}></span>}+ <span style={{ textAlign: 'left', flex: 1 }}>+ {displayedText}+ {currentTypingMsg.loading && <LoadingDots />}+ <span className={styles.aiProgressCursor}>|</span>+ </span>+ </div>+ )}+ </div>+ </div>++ {/* Progress bar - only shown when progress > 0 */}+ {progress > 0 && (+ <div className={styles.aiProgressBarContainer}>+ <div+ className={styles.aiProgressBar}+ style={{ width: `${progress}%` }}+ >+ <span className={styles.aiProgressText}>{progress}%</span>+ </div>+ </div>+ )}+ </div>+ )}+ </div>{/* Mobile button */}<button@@ -171,6 +570,7 @@ function Hero() {router.push('/accounts')}}className={`${styles.heroBtn} ${styles.heroBtnMobile}`}+ style={{ marginTop: '20px' }}>{t('hero.getStarted')}<svg className={styles.btnArrow} width="16" height="16" viewBox="0 0 16 16" fill="none">diff --git a/project/web/src/app/[lng]/styles/difyHome.module.scss b/project/web/src/app/[lng]/styles/difyHome.module.scssindex b675a59e..ba369854 100644--- a/project/web/src/app/[lng]/styles/difyHome.module.scss+++ b/project/web/src/app/[lng]/styles/difyHome.module.scss@@ -2607,3 +2607,330 @@}}}++// AI生成进度动画+:global {+ @keyframes blink {+ 0%, 100% {+ opacity: 1;+ }+ 50% {+ opacity: 0;+ }+ }++ @keyframes slideRight {+ 0% {+ transform: translateX(-100%);+ }+ 100% {+ transform: translateX(100vw);+ }+ }++ @keyframes fadeInUp {+ 0% {+ opacity: 0;+ transform: translateY(10px);+ }+ 100% {+ opacity: 1;+ transform: translateY(0);+ }+ }++}++// AI生成输入和进度展示区域+.aiGenerationWrapper {+ width: 100%;+ max-width: 800px;+ margin: 40px auto 20px;+ display: flex;+ flex-direction: column;+ gap: 16px;+ padding: 0 20px;++ @media (max-width: 768px) {+ margin: 20px auto 16px;+ padding: 0 16px;+ gap: 12px;+ }+}++.aiInputContainer {+ display: flex;+ gap: 12px;+ align-items: center;+ background: rgba(255, 255, 255, 0.95);+ border-radius: 16px;+ padding: 8px;+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);+ backdrop-filter: blur(10px);++ @media (max-width: 768px) {+ flex-direction: column;+ gap: 8px;+ padding: 12px;+ border-radius: 12px;+ }+}++.aiInput {+ flex: 1;+ padding: 16px 20px;+ font-size: 16px;+ border: none;+ outline: none;+ background: transparent;+ color: #1a1a1a;+ font-family: inherit;+ width: 100%;++ &::placeholder {+ color: #999;+ }++ &:disabled {+ opacity: 0.7;+ cursor: not-allowed;+ }++ @media (max-width: 768px) {+ padding: 12px 16px;+ font-size: 15px;+ }+}++.aiGenerateBtn {+ padding: 16px 32px;+ font-size: 16px;+ font-weight: 600;+ background: linear-gradient(135deg, #a66ae4 0%, #8b4fd9 100%);+ color: #fff;+ border: none;+ border-radius: 12px;+ cursor: pointer;+ transition: all 0.3s ease;+ white-space: nowrap;+ box-shadow: 0 4px 15px rgba(166, 106, 228, 0.4);++ &:hover:not(:disabled) {+ transform: translateY(-2px);+ box-shadow: 0 6px 20px rgba(166, 106, 228, 0.5);+ }++ &:active:not(:disabled) {+ transform: translateY(0);+ }++ &:disabled {+ background: #e0e0e0;+ cursor: not-allowed;+ box-shadow: none;+ }++ @media (max-width: 768px) {+ width: 100%;+ padding: 14px 24px;+ font-size: 15px;+ }+}++// AI生成进度区域外层包装+.aiProgressWrapper {+ width: 100%;+ display: flex;+ flex-direction: column;+ gap: 0;+}++// AI生成进度框+.aiProgressContainer {+ max-height: 350px;+ overflow-y: auto;+ padding: 20px;+ background: rgba(255, 255, 255, 0.95);+ border: 1px solid rgba(0, 0, 0, 0.08);+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);+ position: relative;+ scroll-behavior: smooth;+ white-space: pre-wrap;+ word-break: break-word;++ @media (max-width: 768px) {+ max-height: 300px;+ padding: 16px;+ }++ // 滚动条样式+ &::-webkit-scrollbar {+ width: 6px;+ }++ &::-webkit-scrollbar-track {+ background: rgba(0, 0, 0, 0.05);+ border-radius: 3px;+ }++ &::-webkit-scrollbar-thumb {+ background: linear-gradient(135deg, #a66ae4 0%, #8b4fd9 100%);+ border-radius: 3px;++ &:hover {+ background: linear-gradient(135deg, #9558de 0%, #7a3fc9 100%);+ }+ }+}++// 进度条容器+.aiProgressBarContainer {+ width: 100%;+ height: 24px;+ background: rgba(255, 255, 255, 0.95);+ border: 1px solid rgba(0, 0, 0, 0.08);+ border-top: none;+ border-radius: 0 0 12px 12px;+ padding: 4px;+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);++ @media (max-width: 768px) {+ height: 20px;+ padding: 3px;+ }+}++// 进度条+.aiProgressBar {+ height: 100%;+ background: linear-gradient(90deg, #a66ae4 0%, #8b4fd9 100%);+ border-radius: 6px;+ transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); // 更平滑的过渡+ display: flex;+ align-items: center;+ justify-content: flex-end;+ padding-right: 6px;+ min-width: 35px;+ position: relative;++ @media (max-width: 768px) {+ padding-right: 4px;+ min-width: 30px;+ }+}++// 进度文字+.aiProgressText {+ font-size: 10px;+ font-weight: 600;+ color: #fff;+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);+ position: relative;+ z-index: 1;++ @media (max-width: 768px) {+ font-size: 9px;+ }+}++.aiProgressLoader {+ position: absolute;+ top: 0;+ left: 0;+ right: 0;+ height: 2px;+ background: linear-gradient(90deg, transparent, #a66ae4, transparent);+ animation: slideRight 2s infinite;+}++.aiProgressContent {+ position: relative;+ z-index: 1;+ font-size: 14px;+ line-height: 2;+ color: #333;+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;++ @media (max-width: 768px) {+ font-size: 13px;+ line-height: 1.8;+ }+}++.aiProgressMessage {+ margin-bottom: 8px;+ display: flex;+ text-align: left;++ :global(.anticon) {+ margin-right: 8px;+ flex-shrink: 0;+ margin-top: 2px;++ @media (max-width: 768px) {+ margin-right: 6px;+ }+ }++ span {+ text-align: left;+ word-break: break-word;+ }++ @media (max-width: 768px) {+ margin-bottom: 6px;+ }+}++.aiProgressCursor {+ animation: blink 1s infinite;+ margin-left: 2px;+ display: inline-block;+ transform: scaleX(0.5); // 将宽度缩小到50%+ transform-origin: center;+ color: #a66ae4; // 主题色+}++// 加载动画点(...)+.loadingDots {+ display: inline-flex;+ align-items: center;+ margin-left: 4px;++ .dot {+ animation: dotPulse 1.4s infinite ease-in-out;+ opacity: 0;++ &:nth-child(1) {+ animation-delay: 0s;+ }++ &:nth-child(2) {+ animation-delay: 0.2s;+ }++ &:nth-child(3) {+ animation-delay: 0.4s;+ }+ }+}++// 进度条闪光动画+@keyframes shimmer {+ 0% {+ left: -100%;+ }+ 100% {+ left: 100%;+ }+}++// 点动画+@keyframes dotPulse {+ 0%, 80%, 100% {+ opacity: 0;+ }+ 40% {+ opacity: 1;+ }+}\ No newline at end of filediff --git a/project/web/src/app/i18n/locales/en/dataMonitoring.json b/project/web/src/app/i18n/locales/en/dataMonitoring.jsonnew file mode 100644index 00000000..6b750142--- /dev/null+++ b/project/web/src/app/i18n/locales/en/dataMonitoring.json@@ -0,0 +1,115 @@+{+ "title": "Note Propagation Monitoring",+ "description": "Monitor note likes, favorites, comments, shares and other propagation data at minute-level frequency, effectively verify note propagation effect",+ "tabs": {+ "byLink": "By Note Link",+ "byAccount": "By Xiaohongshu"+ },+ "actions": {+ "add": "Add",+ "comingSoon": "Coming Soon",+ "viewDetail": "View Details"+ },+ "addModal": {+ "title": "Add Note Monitoring",+ "inputPlaceholder": "Please enter Xiaohongshu note link",+ "linkPlaceholder": "https://www.xiaohongshu.com/explore/...",+ "linkRequired": "Please enter note link",+ "confirm": "Confirm",+ "cancel": "Cancel",+ "addSuccess": "Added successfully",+ "addFailed": "Failed to add"+ },+ "list": {+ "empty": "No monitoring data yet, click the button above to add a note link",+ "untitled": "Untitled Note",+ "createdAt": "Created at",+ "updatedAt": "Updated at",+ "error": "Error",+ "totalRecords": "Total {{count}} records"+ },+ "stats": {+ "views": "Views",+ "likes": "Likes",+ "comments": "Comments",+ "favorites": "Favorites",+ "shares": "Shares"+ },+ "status": {+ "pending": "Pending",+ "processing": "Processing",+ "completed": "Completed",+ "success": "Success",+ "failed": "Failed",+ "enabled": "Enabled",+ "disabled": "Disabled"+ },+ "detail": {+ "back": "Back",+ "backToList": "Back to List",+ "notFound": "Monitoring data not found",+ "pause": "Pause",+ "resume": "Resume",+ "paused": "Paused",+ "resumed": "Resumed",+ "export": "Export",+ "exportSuccess": "Exported successfully",+ "viewNote": "View Note",+ "pageTitle": "Note Monitoring Details",+ "startTime": "Start Time",+ "updateTime": "Update Time",+ "noteCover": "Note Cover",+ "viewOriginal": "View Original",+ "dailyIncrement": "Daily Data Increment",+ "noData": "No Data",+ "taskId": "Task ID",+ "createdTime": "Task Created",+ "publishTime": "Published",+ "firstMonitoring": "First Monitored",+ "monitoringDuration": "Duration",+ "duration": "{{count}} day(s)",+ "monitoringFrequency": "Frequency",+ "minutesPerTime": " min/time",+ "lastMonitoring": "Last Monitored",+ "completionRate": "Completion Rate",+ "monitoringComplete": " Monitoring Complete",+ "dataDetail": "Data Detail",+ "downloadRecord": "Download Record",+ "exportResult": "Export Result",+ "postInfo": "Note Information",+ "mediaPreview": "Media Preview",+ "dataHistory": "Data History",+ "noHistory": "No history data",+ "status": {+ "active": "Active",+ "paused": "Paused"+ },+ "tabs": {+ "chart": "Cumulative View",+ "table": "Incremental View"+ },+ "table": {+ "time": "Time",+ "date": "Date",+ "likeIncrement": "Like Increment",+ "favoriteIncrement": "Favorite Increment",+ "commentIncrement": "Comment Increment",+ "totalLikes": "Total Likes",+ "newLikes": "New Likes",+ "totalComments": "Total Comments",+ "newComments": "New Comments",+ "totalFavorites": "Total Favorites",+ "newFavorites": "New Favorites",+ "total": "Total {{count}} items",+ "totalDays": "Total {{count}} days"+ }+ },+ "error": {+ "loadFailed": "Failed to load",+ "addFailed": "Failed to add",+ "toggleFailed": "Operation failed",+ "exportFailed": "Export failed",+ "getDetailFailed": "Failed to get details"+ }+}+diff --git a/project/web/src/app/i18n/locales/en/home.json b/project/web/src/app/i18n/locales/en/home.jsonindex 0986d847..32ddf269 100644--- a/project/web/src/app/i18n/locales/en/home.json+++ b/project/web/src/app/i18n/locales/en/home.json@@ -26,6 +26,31 @@"getStarted": "Get Started","useMobilePhone": "use on mobile phone"},+ "aiGeneration": {+ "inputPlaceholder": "Enter your content idea, AI will generate a complete work for you...",+ "generateButton": "Generate",+ "generating": "Generating...",+ "emptyPromptAlert": "Please enter a prompt for content generation",+ "createTaskFailed": "Failed to create task",+ "thinking": "AI Thinking...",+ "topicPrefix": "Creation Topic: ",+ "generatedTitlePrefix": "Generated Title: ",+ "descriptionPrefix": "📄 ",+ "failedReasonPrefix": "Failure Reason: ",+ "taskTimeout": "Task timeout, please try again later",+ "unknownError": "Unknown error",+ "status": {+ "thinking": "AI Thinking...",+ "waiting": "Waiting...",+ "generatingContent": "Generating Content",+ "generatingImage": "Generating Image",+ "generatingVideo": "Generating Video",+ "generatingText": "Generating Text",+ "completed": "Completed!",+ "failed": "Failed",+ "cancelled": "Cancelled"+ }+ },"brandBar": {"title": "Supported Social Media Platforms"},diff --git a/project/web/src/app/i18n/locales/en/route.json b/project/web/src/app/i18n/locales/en/route.jsonindex 62edebd1..8d5745ef 100644--- a/project/web/src/app/i18n/locales/en/route.json+++ b/project/web/src/app/i18n/locales/en/route.json@@ -9,6 +9,7 @@"interactive": "Engage","engagement": "Engagement","dataStatistics": "Data",+ "dataMonitoring": "Data Monitoring","navigation": "Navigation","aiRank": "AI Rank"}diff --git a/project/web/src/app/i18n/locales/zh-CN/dataMonitoring.json b/project/web/src/app/i18n/locales/zh-CN/dataMonitoring.jsonnew file mode 100644index 00000000..e6a5148d--- /dev/null+++ b/project/web/src/app/i18n/locales/zh-CN/dataMonitoring.json@@ -0,0 +1,115 @@+{+ "title": "笔记传播监测",+ "description": "按分钟级频率监测笔记的点赞、收藏、评论、转发等传播数据,有效验证笔记传播效果",+ "tabs": {+ "byLink": "按笔记链接",+ "byAccount": "按小红书账号"+ },+ "actions": {+ "add": "去添加",+ "comingSoon": "即将开放",+ "viewDetail": "查看详情"+ },+ "addModal": {+ "title": "添加笔记监测",+ "inputPlaceholder": "请输入小红书笔记链接",+ "linkPlaceholder": "https://www.xiaohongshu.com/explore/...",+ "linkRequired": "请输入笔记链接",+ "confirm": "确定",+ "cancel": "取消",+ "addSuccess": "添加成功",+ "addFailed": "添加失败"+ },+ "list": {+ "empty": "暂无监测数据,点击上方按钮添加笔记链接",+ "untitled": "未命名笔记",+ "createdAt": "创建时间",+ "updatedAt": "更新时间",+ "error": "错误",+ "totalRecords": "共 {{count}} 条记录"+ },+ "stats": {+ "views": "阅读数",+ "likes": "点赞数",+ "comments": "评论数",+ "favorites": "收藏数",+ "shares": "分享数"+ },+ "status": {+ "pending": "等待中",+ "processing": "处理中",+ "completed": "已完成",+ "success": "成功",+ "failed": "失败",+ "enabled": "已启用",+ "disabled": "已禁用"+ },+ "detail": {+ "back": "返回",+ "backToList": "返回列表",+ "notFound": "未找到监测数据",+ "pause": "暂停监测",+ "resume": "恢复监测",+ "paused": "已暂停",+ "resumed": "已恢复",+ "export": "导出数据",+ "exportSuccess": "导出成功",+ "viewNote": "查看笔记",+ "pageTitle": "笔记监测详情",+ "startTime": "开始时间",+ "updateTime": "更新时间",+ "noteCover": "笔记封面",+ "viewOriginal": "查看原文",+ "dailyIncrement": "每日数据增量",+ "noData": "暂无数据",+ "taskId": "任务编号",+ "createdTime": "任务提交时间",+ "publishTime": "发布时间",+ "firstMonitoring": "首次监测时间",+ "monitoringDuration": "监测时长",+ "duration": "{{count}}天",+ "monitoringFrequency": "监测频率",+ "minutesPerTime": "分钟/次",+ "lastMonitoring": "最近一次监测",+ "completionRate": "监测完成度",+ "monitoringComplete": "监测已完成",+ "dataDetail": "数据详情",+ "downloadRecord": "下载记录",+ "exportResult": "导出结果",+ "postInfo": "笔记信息",+ "mediaPreview": "媒体预览",+ "dataHistory": "数据历史",+ "noHistory": "暂无历史数据",+ "status": {+ "active": "监测中",+ "paused": "已暂停"+ },+ "tabs": {+ "chart": "累计视图",+ "table": "增量视图"+ },+ "table": {+ "time": "时间",+ "date": "日期",+ "likeIncrement": "点赞增量",+ "favoriteIncrement": "收藏增量",+ "commentIncrement": "评论增量",+ "totalLikes": "即时点赞",+ "newLikes": "新增点赞",+ "totalComments": "即时评论",+ "newComments": "新增评论",+ "totalFavorites": "即时收藏",+ "newFavorites": "新增收藏",+ "total": "共 {{count}} 条",+ "totalDays": "共 {{count}} 天"+ }+ },+ "error": {+ "loadFailed": "加载失败",+ "addFailed": "添加失败",+ "toggleFailed": "操作失败",+ "exportFailed": "导出失败",+ "getDetailFailed": "获取详情失败"+ }+}+diff --git a/project/web/src/app/i18n/locales/zh-CN/home.json b/project/web/src/app/i18n/locales/zh-CN/home.jsonindex 629aa925..a22246bc 100644--- a/project/web/src/app/i18n/locales/zh-CN/home.json+++ b/project/web/src/app/i18n/locales/zh-CN/home.json@@ -25,6 +25,31 @@"getStarted": "立即开始","useMobilePhone": "使用移动设备"},+ "aiGeneration": {+ "inputPlaceholder": "输入你想创作的内容,AI将为你生成完整的作品...",+ "generateButton": "生成作品",+ "generating": "生成中...",+ "emptyPromptAlert": "请输入生成内容的提示词",+ "createTaskFailed": "创建任务失败",+ "thinking": "AI思考中...",+ "topicPrefix": "创作主题:",+ "generatedTitlePrefix": "生成主题:",+ "descriptionPrefix": "📄 ",+ "failedReasonPrefix": "失败原因: ",+ "taskTimeout": "任务超时,请稍后重试",+ "unknownError": "未知错误",+ "status": {+ "thinking": "AI思考中...",+ "waiting": "等待处理...",+ "generatingContent": "内容生成中",+ "generatingImage": "图片生成中",+ "generatingVideo": "视频生成中",+ "generatingText": "文本生成中",+ "completed": "生成完成!",+ "failed": "生成失败",+ "cancelled": "已取消"+ }+ },"brandBar": {"title": "支持的社交媒体平台"},diff --git a/project/web/src/app/i18n/locales/zh-CN/route.json b/project/web/src/app/i18n/locales/zh-CN/route.jsonindex e60b5057..a0ac6127 100644--- a/project/web/src/app/i18n/locales/zh-CN/route.json+++ b/project/web/src/app/i18n/locales/zh-CN/route.json@@ -10,6 +10,7 @@"interactive": "作品互动","engagement": "互动数据","dataStatistics": "数据统计",+ "dataMonitoring": "数据监控","navigation": "导航","aiRank": "AI热榜"}diff --git a/project/web/src/app/layout/routerData.ts b/project/web/src/app/layout/routerData.tsindex 4c7c7cba..aab6b1e1 100644--- a/project/web/src/app/layout/routerData.ts+++ b/project/web/src/app/layout/routerData.ts@@ -56,6 +56,12 @@ export const routerData: IRouterDataItem[] = [path: '/dataStatistics',},+ {+ name: '数据监控',+ translationKey: 'dataMonitoring',+ path: '/data-monitoring',+ },+{name: '素材库',translationKey: 'header.materialLibrary',diff --git a/project/web/src/components/PublishDialog/PublishDialog.util.ts b/project/web/src/components/PublishDialog/PublishDialog.util.tsindex 4d64b713..ba23daf9 100644--- a/project/web/src/components/PublishDialog/PublishDialog.util.ts+++ b/project/web/src/components/PublishDialog/PublishDialog.util.ts@@ -29,9 +29,23 @@ export function VideoGrabFrame(// 视频首帧cover: IImgFile}> {- return new Promise((resolve) => {+ return new Promise((resolve, reject) => {const video = document.createElement('video')video.src = videoUrl+ video.crossOrigin = 'anonymous' // 尝试跨域访问++ // 设置超时+ const timeout = setTimeout(() => {+ video.remove()+ reject(new Error('视频加载超时'))+ }, 30000) // 30秒超时++ // 错误处理+ video.addEventListener('error', (e) => {+ clearTimeout(timeout)+ video.remove()+ reject(new Error(`视频加载失败: ${video.error?.message || '未知错误'}`))+ })// 当视频元数据加载完毕时执行回调video.addEventListener('loadedmetadata', () => {@@ -53,19 +67,41 @@ export function VideoGrabFrame(context.fillStyle = 'white'context.fillRect(0, 0, width, height)context.drawImage(video, 0, 0)- canvas.toBlob(async (blob) => {- const cover = await formatImg({- blob: blob!,- path: `cover.${blob!.type.split('/')[1]}`,- })- resolve({- width,- height,- duration: Math.floor(duration),- cover,++ // 尝试导出canvas,可能因为CORS失败+ try {+ canvas.toBlob(async (blob) => {+ if (!blob) {+ clearTimeout(timeout)+ video.remove()+ reject(new Error('Canvas转换为Blob失败'))+ return+ }++ try {+ const cover = await formatImg({+ blob: blob,+ path: `cover.${blob.type.split('/')[1]}`,+ })+ clearTimeout(timeout)+ resolve({+ width,+ height,+ duration: Math.floor(duration),+ cover,+ })+ video.remove()+ } catch (formatError) {+ clearTimeout(timeout)+ video.remove()+ reject(new Error(`格式化封面失败: ${formatError}`))+ }})+ } catch (canvasError) {+ clearTimeout(timeout)video.remove()- })+ reject(new Error(`Canvas操作失败(可能是CORS问题): ${canvasError}`))+ }})// 加载视频diff --git a/project/web/src/components/PublishDialog/index.tsx b/project/web/src/components/PublishDialog/index.tsxindex 3112e244..858873e8 100644--- a/project/web/src/components/PublishDialog/index.tsx+++ b/project/web/src/components/PublishDialog/index.tsx@@ -217,7 +217,14 @@ const PublishDialog = memo(// 图片匹配if (images) {newPubItem.params.images = images.map((img) => {- img.ossUrl = md5Cache[tasks[img.uploadTaskId!].md5!]?.ossUrl+ // 只有当图片没有ossUrl且有uploadTaskId时,才从上传任务中获取+ // AI生成的图片已经有ossUrl,不需要从上传任务获取+ if (!img.ossUrl && img.uploadTaskId && tasks[img.uploadTaskId]) {+ const taskMd5 = tasks[img.uploadTaskId].md5+ if (taskMd5 && md5Cache[taskMd5]) {+ img.ossUrl = md5Cache[taskMd5].ossUrl+ }+ }return img})return newPubItem@@ -303,11 +310,10 @@ const PublishDialog = memo(return}- // 授权完成后刷新账号列表+ // Refresh account list after authorizationsetTimeout(async () => {try {await getAccountList()- console.log(t('messages.accountListRefreshed' as any))}catch (error) {console.error(@@ -315,7 +321,7 @@ const PublishDialog = memo(error,)}- }, 3000) // 等待3秒让授权完成+ }, 3000) // Wait 3 seconds for authorization to complete}catch (error) {console.error(t('messages.authFailed' as any), error)@@ -356,7 +362,6 @@ const PublishDialog = memo(setModerationDesc('')setModerationLevel(null)const result = await toolsApi.textModeration(contentToCheck)- console.log('result', result)if (result?.code === 0) {const data: any = result?.data || ({} as any)@@ -480,9 +485,12 @@ const PublishDialog = memo(}}else {+ // 弹窗关闭时只清除选中状态和步骤,保留pubList以便下次打开isClear.current = truesetPubListChoosed([])- clear()+ setStep(0)+ setExpandedPubItem(undefined)+ // 注意:不要调用clear(),否则会清空pubList导致无法选择账户}}, [accounts, open])@@ -614,13 +622,11 @@ const PublishDialog = memo(}, openLeft ? 100 : 500)}, [openLeft, setOpenLeft])- // AI内容同步到编辑器+ // Sync AI content to editorconst handleSyncToEditor = useCallback(async (content: string, images?: IImgFile[], video?: IVideoFile, append?: boolean) => {- console.log('父组件收到同步请求 - 内容:', content, '图片数量:', images?.length || 0, '视频:', video ? '有' : '无', '追加模式:', append)- // 处理图片上传+ // Handle image uploadif (images && images.length > 0) {- console.log('开始上传AI同步的图片')const uploadsWithImages: Array<{ image: IImgFile, promise: Promise<any>, cancel: () => void }> = []for (const image of images) {@@ -642,18 +648,15 @@ const PublishDialog = memo(})}- // 使用带有 uploadTaskId 的图片+ // Use images with uploadTaskIdimages = uploadsWithImages.map(item => item.image)- console.log('图片上传任务已创建:', images)}- // 处理视频上传(AI生成的视频已经有ossUrl,只需要上传封面)+ // Handle video upload (AI-generated videos already have ossUrl, only need to upload cover)if (video) {- console.log('处理AI同步的视频,ossUrl:', video.ossUrl)- // 如果视频已经有ossUrl(AI生成的),只需要上传封面+ // If video already has ossUrl (AI-generated), only upload coverif (video.ossUrl && !video.cover.ossUrl) {- console.log('视频已有OSS地址,只上传封面')const coverHandle = enqueueUpload({file: video.cover.file,fileName: video.cover.filename,@@ -667,9 +670,8 @@ const PublishDialog = memo(},}}- // 如果视频没有ossUrl(用户上传的),需要上传视频和封面+ // If video doesn't have ossUrl (user uploaded), need to upload both video and coverelse if (!video.ossUrl) {- console.log('上传视频和封面')const videoHandle = enqueueUpload({file: video.file,fileName: video.filename,@@ -690,82 +692,72 @@ const PublishDialog = memo(},}}- console.log('视频处理完成:', video)}- // 如果只有一个账号,直接更新+ // If only one account, update directlyif (pubListChoosed.length === 1) {const params: any = {}- // 只有当 content 不为空字符串时才更新文案+ // Only update content if not empty stringif (content) {- // 如果是追加模式,将内容追加到现有文案后面+ // If append mode, append content to existing textif (append && pubListChoosed[0].params.des) {params.des = pubListChoosed[0].params.des + '\n' + content} else {params.des = content}}- // 视频和图片不能同时存在+ // Video and images cannot exist simultaneouslyif (video) {- console.log('设置视频到单账号参数')params.video = video- // 如果有视频,清空图片+ // If has video, clear imagesparams.images = []} else if (images && images.length > 0) {- console.log('设置图片到单账号参数')params.images = images}- console.log('更新单账号参数:', params)setOnePubParams(params, pubListChoosed[0].account.id)}- // 如果是多账号且在第一步,更新公共参数+ // If multiple accounts and in step 0, update common paramselse if (pubListChoosed.length >= 2 && step === 0) {const params: any = {}- // 只有当 content 不为空字符串时才更新文案+ // Only update content if not empty stringif (content) {- // 如果是追加模式,将内容追加到现有文案后面+ // If append mode, append content to existing textif (append && commonPubParams.des) {params.des = commonPubParams.des + '\n' + content} else {params.des = content}}- // 视频和图片不能同时存在+ // Video and images cannot exist simultaneouslyif (video) {- console.log('设置视频到多账号公共参数')params.video = video- // 如果有视频,清空图片+ // If has video, clear imagesparams.images = []} else if (images && images.length > 0) {- console.log('设置图片到多账号公共参数')params.images = images}- console.log('更新多账号公共参数:', params)setAccountAllParams(params)}- // 如果在第二步且有展开的项,更新该项+ // If in step 1 and has expanded item, update that itemelse if (step === 1 && expandedPubItem) {const params: any = {}- // 只有当 content 不为空字符串时才更新文案+ // Only update content if not empty stringif (content) {- // 如果是追加模式,将内容追加到现有文案后面+ // If append mode, append content to existing textif (append && expandedPubItem.params.des) {params.des = expandedPubItem.params.des + '\n' + content} else {params.des = content}}- // 视频和图片不能同时存在+ // Video and images cannot exist simultaneouslyif (video) {- console.log('设置视频到展开项参数')params.video = video- // 如果有视频,清空图片+ // If has video, clear imagesparams.images = []} else if (images && images.length > 0) {- console.log('设置图片到展开项参数')params.images = images}- console.log('更新展开项参数:', params)setOnePubParams(params, expandedPubItem.account.id)}}, [pubListChoosed, step, expandedPubItem, setOnePubParams, setAccountAllParams, enqueueUpload])diff --git a/project/web/src/utils/request.ts b/project/web/src/utils/request.tsindex 7893ca7f..ef46d2cb 100644--- a/project/web/src/utils/request.ts+++ b/project/web/src/utils/request.ts@@ -18,7 +18,7 @@ const fetchService = new FetchService({baseURL: `${process.env.NEXT_PUBLIC_API_URL}/`,requestInterceptor(requestParams) {const token = useUserStore.getState().token-+ // const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtYWlsIjoiemlqdWUyMDI1QG91dGxvb2suY29tIiwiaWQiOiI2OGI1MDM0ZDIxYjE1YTQwZTUxMWRmOWIiLCJuYW1lIjoi55So5oi3X1dYeVMzb0N3IiwiaWF0IjoxNzY0MDM1NTQzLCJleHAiOjE3NjQ2NDAzNDN9.ylPhoyWW5zPV2Y92lxR8OP0z55pWrY7aZ_kZlMRd0_s'requestParams.headers = {...(requestParams.headers || {}),Authorization: token ? `Bearer ${token}` : '',