Skip to content

Let's use AI to Earn!

fix(web): Added functionality to interrupt AI content generation tasks un close isok publish startus end (#478)

布莱恩·奥夫托·杰森张df8155d147c1
diff --git a/project/web/src/api/agent.ts b/project/web/src/api/agent.ts
index 4dc0e830..9d595ea3 100644
--- a/project/web/src/api/agent.ts
+++ b/project/web/src/api/agent.ts
@@ -19,6 +19,7 @@ export enum TaskStatus {
RequiresAction = 'requires_action', // 需要用户操作(如绑定频道等)
Failed = 'FAILED', // 失败
Cancelled = 'CANCELLED', // 取消
+ Aborted = 'aborted', // 中止
}
// 媒体类型
@@ -172,6 +173,7 @@ export interface SSEMessage {
// 任务增量消息响应
export interface TaskMessagesVo {
messages: TaskMessage[]
+ status?: TaskStatus // 任务状态,可选
}
export const agentApi = {
@@ -462,6 +464,15 @@ export const agentApi = {
return res
},
+ /**
+ * 中断内容生成任务
+ * @param taskId 任务ID
+ */
+ async abortTask(taskId: string) {
+ const res = await http.post(`agent/tasks/${taskId}/abort`)
+ return res
+ },
+
/**
* 获取任务列表
* @param page 页码,默认1
diff --git a/project/web/src/app/[lng]/chat/[taskId]/hooks/useChatState.ts b/project/web/src/app/[lng]/chat/[taskId]/hooks/useChatState.ts
index 515de6ea..a7c83862 100644
--- a/project/web/src/app/[lng]/chat/[taskId]/hooks/useChatState.ts
+++ b/project/web/src/app/[lng]/chat/[taskId]/hooks/useChatState.ts
@@ -150,6 +150,13 @@ export function useChatState(options: IChatStateOptions): IChatStateReturn {
onTaskUpdate: useCallback((taskData: TaskDetail) => {
setTask(taskData)
}, []),
+ onTaskStatusChange: useCallback((status: string) => {
+ if (status === 'aborted') {
+ console.log('[ChatState] Task aborted, clearing generating state')
+ // 任务被中止时,停止本地生成状态
+ setLocalIsGenerating(false)
+ }
+ }, []),
})
/**
diff --git a/project/web/src/app/[lng]/chat/[taskId]/hooks/useTaskPolling.ts b/project/web/src/app/[lng]/chat/[taskId]/hooks/useTaskPolling.ts
index 466e363f..60551fe8 100644
--- a/project/web/src/app/[lng]/chat/[taskId]/hooks/useTaskPolling.ts
+++ b/project/web/src/app/[lng]/chat/[taskId]/hooks/useTaskPolling.ts
@@ -1,4 +1,5 @@
import type { TaskDetail, TaskMessage } from '@/api/agent'
+import { TaskStatus } from '@/api/agent'
import type { IDisplayMessage } from '@/store/agent'
/**
* 任务轮询 Hook
@@ -22,6 +23,8 @@ export interface ITaskPollingOptions {
onMessagesUpdate: (messages: IDisplayMessage[], rawMessages: TaskMessage[]) => void
/** 任务更新回调 */
onTaskUpdate?: (task: TaskDetail) => void
+ /** 任务状态变化回调 */
+ onTaskStatusChange?: (status: string) => void
}
export interface ITaskPollingReturn {
@@ -44,6 +47,7 @@ export function useTaskPolling(options: ITaskPollingOptions): ITaskPollingReturn
pollingInterval = 3000,
onMessagesUpdate,
onTaskUpdate,
+ onTaskStatusChange,
} = options
const [isPolling, setIsPolling] = useState(false)
@@ -113,7 +117,15 @@ export function useTaskPolling(options: ITaskPollingOptions): ITaskPollingReturn
// 如果没有 lastMessageId,执行每 5 秒一次的全量拉取逻辑(接口支持不传 lastMessageId 获取全部消息)
if (!lastMessageId) {
const result = await agentApi.getTaskMessages(taskId)
- if (result?.code === 0 && result.data?.messages) {
+ if (result?.code === 0 && result.data) {
+ // 检查任务状态
+ if (result.data.status === TaskStatus.Aborted) {
+ console.log('[TaskPolling] Task aborted, stopping polling')
+ setIsPolling(false)
+ onTaskStatusChange?.('aborted')
+ return
+ }
+
const newMessages = result.data.messages
console.log('[TaskPolling] fetched fullMessages length:', newMessages.length)
if (!newMessages.length) {
@@ -157,7 +169,15 @@ export function useTaskPolling(options: ITaskPollingOptions): ITaskPollingReturn
// 如果存在 lastMessageId,调用增量消息接口,仅获取 lastMessageId 之后的新消息
const result = await agentApi.getTaskMessages(taskId, lastMessageId)
- if (result?.code === 0 && result.data?.messages) {
+ if (result?.code === 0 && result.data) {
+ // 检查任务状态
+ if (result.data.status === TaskStatus.Aborted) {
+ console.log('[TaskPolling] Task aborted, stopping polling')
+ setIsPolling(false)
+ onTaskStatusChange?.('aborted')
+ return
+ }
+
const newMessages = result.data.messages
console.log('[TaskPolling] fetched newMessages length:', newMessages.length, 'lastMessageId:', lastMessageId)
if (!newMessages.length) {
diff --git a/project/web/src/app/[lng]/chat/[taskId]/page.tsx b/project/web/src/app/[lng]/chat/[taskId]/page.tsx
index 7de3a4d7..33dcc9b9 100644
--- a/project/web/src/app/[lng]/chat/[taskId]/page.tsx
+++ b/project/web/src/app/[lng]/chat/[taskId]/page.tsx
@@ -8,10 +8,15 @@
import { useParams, useRouter } from 'next/navigation'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useTransClient } from '@/app/i18n/client'
+import { agentApi } from '@/api/agent'
import { ChatInput } from '@/components/Chat/ChatInput'
import { useMediaUpload } from '@/hooks/useMediaUpload'
+import { PublishDetailModal } from '@/components/Plugin/PublishDetailModal'
import { toast } from '@/lib/toast'
import { disableDebugReplay, enableDebugReplay, useAgentStore } from '@/store/agent'
+import { usePluginStore } from '@/store/plugin'
+import { PlatType } from '@/app/config/platConfig'
+import { PlatformTaskStatus } from '@/store/plugin/types/baseTypes'
/* rating entry moved into ChatHeader */
// 页面私有组件
@@ -46,6 +51,15 @@ export default function ChatDetailPage() {
t: t as (key: string) => string,
})
+ // 中断状态 - 用于强制隐藏工作流步骤
+ const [isInterrupted, setIsInterrupted] = useState(false)
+
+ // 发布详情弹框状态
+ const [publishDetailVisible, setPublishDetailVisible] = useState(false)
+ const [currentPublishTaskId, setCurrentPublishTaskId] = useState<string | undefined>(undefined)
+ // 跟踪用户是否手动关闭了弹窗
+ const [userClosedModal, setUserClosedModal] = useState(false)
+
// 滚动控制
const {
containerRef,
@@ -72,6 +86,9 @@ export default function ChatDetailPage() {
onError: () => toast.error(t('media.uploadFailed')),
})
+ // 监听发布任务创建
+ const publishTasks = usePluginStore(state => state.publishTasks)
+
useEffect(() => {
if (isInitialRender.current || displayMessages.length === 0)
return
@@ -81,6 +98,21 @@ export default function ChatDetailPage() {
}, 10)
}, [displayMessages, isInitialRender])
+ // 监听发布任务创建,显示发布详情弹框
+ useEffect(() => {
+ if (publishTasks.length > 0) {
+ // 获取最新的发布任务(通常是刚创建的)
+ const latestTask = publishTasks[0]
+ if (latestTask && !publishDetailVisible && !userClosedModal) {
+ console.log('[ChatPage] New publish task detected:', latestTask.id)
+ setCurrentPublishTaskId(latestTask.id)
+ setPublishDetailVisible(true)
+ // 重置用户关闭状态,因为现在有新任务了
+ setUserClosedModal(false)
+ }
+ }
+ }, [publishTasks, publishDetailVisible, userClosedModal])
+
/**
* 设置 Action 上下文(用于处理任务结果的 action)
*/
@@ -108,6 +140,7 @@ export default function ChatDetailPage() {
// 发起任务创建
const startTask = async () => {
+ setIsInterrupted(false)
setLocalIsGenerating(true)
try {
await createTask({
@@ -145,6 +178,68 @@ export default function ChatDetailPage() {
* 发送消息(继续对话)
*/
const handleSend = useCallback(async () => {
+ // console.log('handleSend')
+ // // 测试打开发布弹窗
+ // const testTaskId = usePluginStore.getState().addPublishTask({
+ // title: '测试发布任务',
+ // description: '用于测试发布详情弹窗',
+ // platformTasks: [
+ // {
+ // id: 'test-platform-1',
+ // platform: PlatType.Xhs,
+ // accountId: 'test-account-1',
+ // requestId: 'test-req-1',
+ // params: {
+ // platform: PlatType.Xhs,
+ // type: 'image',
+ // title: '测试小红书内容',
+ // desc: '测试描述',
+ // images: ['test-image-url'],
+ // },
+ // status: PlatformTaskStatus.COMPLETED,
+ // progress: {
+ // stage: 'complete',
+ // progress: 100,
+ // message: '发布成功',
+ // },
+ // result: {
+ // success: true,
+ // workId: 'test-work-1',
+ // shareLink: 'https://example.com/test',
+ // },
+ // startTime: Date.now() - 60000,
+ // endTime: Date.now(),
+ // error: null,
+ // },
+ // {
+ // id: 'test-platform-2',
+ // platform: PlatType.Douyin,
+ // accountId: 'test-account-2',
+ // requestId: 'test-req-2',
+ // params: {
+ // platform: PlatType.Douyin,
+ // type: 'image',
+ // title: '测试抖音内容',
+ // desc: '测试描述',
+ // images: ['test-image-url'],
+ // },
+ // status: PlatformTaskStatus.PUBLISHING,
+ // progress: {
+ // stage: 'publish',
+ // progress: 75,
+ // message: '正在发布...',
+ // },
+ // result: null,
+ // startTime: Date.now() - 30000,
+ // endTime: null,
+ // error: null,
+ // },
+ // ],
+ // })
+ // setCurrentPublishTaskId(testTaskId)
+ // setPublishDetailVisible(true)
+ // return
+
if (!inputValue.trim() || isGenerating)
return
@@ -154,6 +249,8 @@ export default function ChatDetailPage() {
// 清空输入
setInputValue('')
clearMedias()
+ // 重置中断状态,开始新任务
+ setIsInterrupted(false)
setLocalIsGenerating(true)
// 强制滚动到底部
@@ -193,10 +290,25 @@ export default function ChatDetailPage() {
/**
* 停止生成
*/
- const handleStop = useCallback(() => {
- stopTask()
- setLocalIsGenerating(false)
- }, [stopTask, setLocalIsGenerating])
+ const handleStop = useCallback(async () => {
+ try {
+ // 调用后端 API 中断任务
+ await agentApi.abortTask(taskId)
+ console.log('[ChatPage] Task aborted successfully')
+ // 显示停止成功的提示
+ toast.info(tHome('aiGeneration.taskStopped'))
+ } catch (error: any) {
+ console.error('[ChatPage] Failed to abort task:', error)
+ toast.error(t('message.error'))
+ } finally {
+ // 无论 API 调用是否成功,都停止本地状态
+ // 立即设置中断状态,强制隐藏工作流步骤
+ setIsInterrupted(true)
+ // 立即设置本地生成状态为 false,确保 UI 立即响应
+ setLocalIsGenerating(false)
+ stopTask()
+ }
+ }, [taskId, t, tHome, stopTask, setLocalIsGenerating])
/**
* 返回首页
@@ -265,7 +377,7 @@ export default function ChatDetailPage() {
{/* 消息列表 */}
<ChatMessageList
messages={displayMessages}
- workflowSteps={workflowSteps}
+ workflowSteps={isInterrupted ? [] : workflowSteps}
isGenerating={isGenerating}
containerRef={containerRef}
bottomRef={bottomRef}
@@ -291,6 +403,18 @@ export default function ChatDetailPage() {
mode="compact"
/>
</div>
+
+ {/* 发布详情弹框 - 显示插件发布进度 */}
+ <PublishDetailModal
+ visible={publishDetailVisible}
+ onClose={() => {
+ console.log('[ChatPage] User manually closed modal')
+ setPublishDetailVisible(false)
+ setCurrentPublishTaskId(undefined)
+ setUserClosedModal(true)
+ }}
+ taskId={currentPublishTaskId}
+ />
</div>
)
}
diff --git a/project/web/src/app/[lng]/chat/[taskId]/utils/taskStatus.ts b/project/web/src/app/[lng]/chat/[taskId]/utils/taskStatus.ts
index 89898744..9f3ce61b 100644
--- a/project/web/src/app/[lng]/chat/[taskId]/utils/taskStatus.ts
+++ b/project/web/src/app/[lng]/chat/[taskId]/utils/taskStatus.ts
@@ -17,6 +17,8 @@ const COMPLETED_STATUS_VALUES = [
'FAILED',
'cancelled',
'CANCELLED',
+ 'aborted',
+ 'ABORTED',
'requires_action', // 需要用户操作也算完成(停止轮询)
'error',
]
diff --git a/project/web/src/app/[lng]/income/page.tsx b/project/web/src/app/[lng]/income/page.tsx
index 17487578..f63caa67 100644
--- a/project/web/src/app/[lng]/income/page.tsx
+++ b/project/web/src/app/[lng]/income/page.tsx
@@ -443,15 +443,15 @@ export default function IncomePage() {
<TableCell>
{record.status === 'pending' || record.status === 0 || record.status === undefined
? (
- <Badge className={getBadgeClassName('orange')}>
- {t('status.pending')}
- </Badge>
- )
+ <Badge className={getBadgeClassName('orange')}>
+ {t('status.pending')}
+ </Badge>
+ )
: (
- <Badge className={getBadgeClassName('green')}>
- {t('status.withdrawn')}
- </Badge>
- )}
+ <Badge className={getBadgeClassName('green')}>
+ {t('status.withdrawn')}
+ </Badge>
+ )}
</TableCell>
<TableCell className="max-w-[200px] truncate">
{record.desc || '-'}
@@ -534,7 +534,7 @@ export default function IncomePage() {
<TableCell>
<Badge className={statusTag.className}>
{statusTag.icon}
- &nbsp;
+ &nbsp;
{statusTag.text}
</Badge>
</TableCell>
@@ -741,15 +741,15 @@ export default function IncomePage() {
<Label className="text-muted-foreground">{t('statusLabel')}</Label>
{incomeDetail.status === 'pending' || incomeDetail.status === 0 || incomeDetail.status === undefined
? (
- <Badge className={getBadgeClassName('orange')}>
- {t('status.pending')}
- </Badge>
- )
+ <Badge className={getBadgeClassName('orange')}>
+ {t('status.pending')}
+ </Badge>
+ )
: (
- <Badge className={getBadgeClassName('green')}>
- {t('status.withdrawn')}
- </Badge>
- )}
+ <Badge className={getBadgeClassName('green')}>
+ {t('status.withdrawn')}
+ </Badge>
+ )}
</div>
<div className="col-span-2">
<Label className="text-muted-foreground">{t('description')}</Label>
diff --git a/project/web/src/app/[lng]/tasks/taskPageCore.module.scss b/project/web/src/app/[lng]/tasks/taskPageCore.module.scss
index 380b1c68..9f2e2ff6 100644
--- a/project/web/src/app/[lng]/tasks/taskPageCore.module.scss
+++ b/project/web/src/app/[lng]/tasks/taskPageCore.module.scss
@@ -128,9 +128,11 @@
.taskDetailContainer {
flex-direction: column;
gap: 12px;
+
.taskDetailLeft {
width: 100%;
}
+
.taskDetailRight {
width: 100%;
}
@@ -252,4 +254,4 @@
/* 保持状态和首次提交在同一行,移动端也采用左右对齐 */
}
-}
+}
\ No newline at end of file
diff --git a/project/web/src/app/[lng]/tasks/taskPageCore.tsx b/project/web/src/app/[lng]/tasks/taskPageCore.tsx
index 0de4899a..f49bd47d 100644
--- a/project/web/src/app/[lng]/tasks/taskPageCore.tsx
+++ b/project/web/src/app/[lng]/tasks/taskPageCore.tsx
@@ -852,12 +852,12 @@ export default function TaskPageCore() {
<TabsList className="grid w-full grid-cols-2">
<TabsTrigger value="pending">
<ClockCircleOutlined />
- &nbsp;
+ &nbsp;
{t('pendingTasks')}
</TabsTrigger>
<TabsTrigger value="accepted">
<PlayCircleOutlined />
- &nbsp;
+ &nbsp;
{t('acceptedTasks')}
</TabsTrigger>
</TabsList>
@@ -999,7 +999,7 @@ export default function TaskPageCore() {
style={{ width: '100%' }}
>
<EyeOutlined />
- &nbsp;
+ &nbsp;
{t('viewDetails')}
</Button>
</div>
@@ -1146,7 +1146,7 @@ export default function TaskPageCore() {
style={{ width: '100%' }}
>
<EyeOutlined />
- &nbsp;
+ &nbsp;
{t('viewDetails')}
</Button>
</div>
@@ -1459,45 +1459,45 @@ export default function TaskPageCore() {
const publishAccount = getAccountById(acceptedTaskDetail.accountId)
return publishAccount
? (
- <div style={{
- display: 'flex',
- alignItems: 'center',
- gap: '8px',
- marginBottom: '12px',
- }}
- >
- <Image
- src={publishAccount.avatar ? getOssUrl(publishAccount.avatar) : '/default-avatar.png'}
- alt="account avatar"
- width={32}
- height={32}
- style={{
- borderRadius: '50%',
- objectFit: 'cover',
- }}
- onError={(e: any) => {
- e.target.src = '/default-avatar.png'
- }}
- />
- <div>
- <div style={{
- fontSize: '14px',
- fontWeight: '500',
- color: '#1a1a1a',
- }}
- >
- {publishAccount.nickname}
- </div>
- <div style={{
- fontSize: '12px',
- color: '#666',
- }}
- >
- {getPlatformName(publishAccount.type)}
- </div>
+ <div style={{
+ display: 'flex',
+ alignItems: 'center',
+ gap: '8px',
+ marginBottom: '12px',
+ }}
+ >
+ <Image
+ src={publishAccount.avatar ? getOssUrl(publishAccount.avatar) : '/default-avatar.png'}
+ alt="account avatar"
+ width={32}
+ height={32}
+ style={{
+ borderRadius: '50%',
+ objectFit: 'cover',
+ }}
+ onError={(e: any) => {
+ e.target.src = '/default-avatar.png'
+ }}
+ />
+ <div>
+ <div style={{
+ fontSize: '14px',
+ fontWeight: '500',
+ color: '#1a1a1a',
+ }}
+ >
+ {publishAccount.nickname}
+ </div>
+ <div style={{
+ fontSize: '12px',
+ color: '#666',
+ }}
+ >
+ {getPlatformName(publishAccount.type)}
</div>
</div>
- )
+ </div>
+ )
: null
})()}
</div>
diff --git a/project/web/src/app/[lng]/uptime/page.tsx b/project/web/src/app/[lng]/uptime/page.tsx
index 7f0fbbef..5b72fc6e 100644
--- a/project/web/src/app/[lng]/uptime/page.tsx
+++ b/project/web/src/app/[lng]/uptime/page.tsx
@@ -98,62 +98,6 @@ export default function UptimePage() {
loadHistoryData()
}, [])
- // 计算整体状态
- const overallStatus = (() => {
- if (dataMap.size === 0)
- return null
-
- const latestStatuses = new Map<string, UptimeItem>()
-
- // 获取每个模块的最新状态
- dataMap.forEach((items, type) => {
- items.forEach((item) => {
- const key = `${item.module}-${type}`
- const existing = latestStatuses.get(key)
- if (!existing || new Date(item.createdAt) > new Date(existing.createdAt))
- latestStatuses.set(key, item)
- })
- })
-
- const statuses = Array.from(latestStatuses.values())
- const hasUnavailable = statuses.some(
- s => s.status === UptimeStatusEnum.UNAVAILABLE,
- )
- const hasTimeout = statuses.some(
- s => s.status === UptimeStatusEnum.TIMEOUT,
- )
-
- if (hasUnavailable)
- return 'major-outage'
- if (hasTimeout)
- return 'partial-outage'
- return 'operational'
- })()
-
- // 获取整体状态文本
- const getOverallStatusText = () => {
- switch (overallStatus) {
- case 'major-outage':
- return '部分系统不可用'
- case 'partial-outage':
- return '部分系统性能下降'
- case 'operational':
- return '所有系统运行正常'
- }
- }
-
- // 获取整体状态颜色
- const getOverallStatusColor = () => {
- switch (overallStatus) {
- case 'major-outage':
- return 'text-red-600'
- case 'partial-outage':
- return 'text-yellow-600'
- case 'operational':
- return 'text-green-600'
- }
- }
-
// 计算指定模块和类型的正常运行时间百分比
const calculateModuleTypeUptimePercentage = (
module: UptimeModule,
@@ -220,36 +164,6 @@ export default function UptimePage() {
return (
<div className="min-h-screen bg-gray-50">
- {/* 顶部横幅 */}
- <div className="bg-white border-b">
- <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
- <div className="flex items-center justify-between">
- <div>
- <h1 className="text-3xl font-bold text-gray-900 mb-2">
- 系统状态
- </h1>
- <div className="flex items-center gap-2">
- <div
- className={cn('w-3 h-3 rounded-full', {
- 'bg-green-500': overallStatus === 'operational',
- 'bg-yellow-500': overallStatus === 'partial-outage',
- 'bg-red-500': overallStatus === 'major-outage',
- })}
- />
- <span
- className={cn(
- 'text-lg font-semibold',
- getOverallStatusColor(),
- )}
- >
- {getOverallStatusText()}
- </span>
- </div>
- </div>
- </div>
- </div>
- </div>
-
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* 为每个模块-类型组合显示状态条 */}
{loadingHistory ? (
@@ -365,4 +279,4 @@ export default function UptimePage() {
</div>
</div>
)
-}
+}
\ No newline at end of file
diff --git a/project/web/src/components/Chat/ChatInput/index.tsx b/project/web/src/components/Chat/ChatInput/index.tsx
index 05d144c9..2756856d 100644
--- a/project/web/src/components/Chat/ChatInput/index.tsx
+++ b/project/web/src/components/Chat/ChatInput/index.tsx
@@ -95,16 +95,15 @@ export function ChatInput({
/** 处理发送/停止按钮点击 */
const handleButtonClick = () => {
- // 中断功能暂时禁用
- // if (isGenerating) {
- // onStop?.()
- // } else
- if (!disabled && !isUploading && value.trim() && !isGenerating) {
+ if (isGenerating) {
+ onStop?.()
+ } else if (!disabled && !isUploading && value.trim() && !isGenerating) {
onSend()
}
}
- const canSend = !disabled && !isUploading && value.trim()
+ // 是否可以发送(仅当没有在生成时才检查内容)
+ const canSend = !disabled && !isUploading && value.trim() && !isGenerating
return (
<div
@@ -172,12 +171,12 @@ export function ChatInput({
{/* 右侧:发送/停止按钮 */}
<button
onClick={handleButtonClick}
- disabled={isGenerating || !canSend}
+ disabled={!isGenerating && !canSend}
className={cn(
'shrink-0 flex items-center justify-center rounded-full transition-all',
mode === 'large' ? 'w-10 h-10' : 'w-8 h-8',
// 生成中或无法发送时都显示灰色
- (isGenerating || !canSend)
+ (!isGenerating && !canSend)
? 'bg-muted text-muted-foreground cursor-not-allowed'
: 'bg-primary hover:bg-primary/90 text-primary-foreground',
)}
diff --git a/project/web/src/components/Plugin/PublishDetailModal.tsx b/project/web/src/components/Plugin/PublishDetailModal.tsx
index 5a2afe46..796f3ac9 100644
--- a/project/web/src/components/Plugin/PublishDetailModal.tsx
+++ b/project/web/src/components/Plugin/PublishDetailModal.tsx
@@ -247,11 +247,15 @@ export function PublishDetailModal({ visible, onClose, taskId, task }: PublishDe
</div>
)}
footer={(
- <Button onClick={onClose}>
- {t('publishDetail.close')}
- </Button>
+ <div className="flex justify-end">
+ <Button onClick={onClose}>
+ {t('publishDetail.close')}
+ </Button>
+ </div>
)}
width={600}
+ zIndex={1000}
+ closable={false}
>
<div className="space-y-4">
{/* 任务基本信息 */}
diff --git a/project/web/src/components/SettingsModal/tabs/ProfileTab.tsx b/project/web/src/components/SettingsModal/tabs/ProfileTab.tsx
index 3c1d578d..bd0c544c 100644
--- a/project/web/src/components/SettingsModal/tabs/ProfileTab.tsx
+++ b/project/web/src/components/SettingsModal/tabs/ProfileTab.tsx
@@ -185,46 +185,46 @@ export function ProfileTab({ onClose }: ProfileTabProps) {
<div className="min-w-0 flex-1">
{isEditingName
? (
- <div className="flex items-center gap-2">
- <input
- type="text"
- value={editName}
- onChange={e => setEditName(e.target.value)}
- className="flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-primary/20"
- autoFocus
- onKeyDown={(e) => {
- if (e.key === 'Enter')
- handleSaveName()
- if (e.key === 'Escape') {
- setIsEditingName(false)
- setEditName(userInfo?.name || '')
- }
- }}
- />
- <Button size="sm" onClick={handleSaveName} disabled={isSaving} className="h-8">
- {isSaving ? t('profile.saving') : t('profile.save')}
- </Button>
- <Button
- size="sm"
- variant="ghost"
- onClick={() => {
+ <div className="flex items-center gap-2">
+ <input
+ type="text"
+ value={editName}
+ onChange={e => setEditName(e.target.value)}
+ className="flex-1 rounded-md border border-border bg-background px-3 py-1.5 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-primary/20"
+ autoFocus
+ onKeyDown={(e) => {
+ if (e.key === 'Enter')
+ handleSaveName()
+ if (e.key === 'Escape') {
setIsEditingName(false)
setEditName(userInfo?.name || '')
- }}
- className="h-8"
- >
- {t('profile.cancel')}
- </Button>
- </div>
- )
- : (
- <div
- className="cursor-pointer text-lg font-semibold text-foreground transition-colors hover:text-primary"
- onClick={() => setIsEditingName(true)}
+ }
+ }}
+ />
+ <Button size="sm" onClick={handleSaveName} disabled={isSaving} className="h-8">
+ {isSaving ? t('profile.saving') : t('profile.save')}
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={() => {
+ setIsEditingName(false)
+ setEditName(userInfo?.name || '')
+ }}
+ className="h-8"
>
- {userInfo?.name || tCommon('unknownUser')}
- </div>
- )}
+ {t('profile.cancel')}
+ </Button>
+ </div>
+ )
+ : (
+ <div
+ className="cursor-pointer text-lg font-semibold text-foreground transition-colors hover:text-primary"
+ onClick={() => setIsEditingName(true)}
+ >
+ {userInfo?.name || tCommon('unknownUser')}
+ </div>
+ )}
<p className="mt-1 truncate text-sm text-muted-foreground">{userInfo?.mail || '-'}</p>
</div>
</div>
diff --git a/project/web/src/components/ui/modal.tsx b/project/web/src/components/ui/modal.tsx
index 2168e8ea..77cccbd4 100644
--- a/project/web/src/components/ui/modal.tsx
+++ b/project/web/src/components/ui/modal.tsx
@@ -145,7 +145,6 @@ export const Modal: React.FC<ModalProps> = ({
overlayStyle={overlayZIndex ? { zIndex: overlayZIndex } : undefined}
onInteractOutside={handleInteractOutside}
onEscapeKeyDown={!closable ? e => e.preventDefault() : undefined}
- aria-describedby={title ? undefined : undefined}
>
{title
? (
diff --git a/project/web/src/store/agent/agent.methods.ts b/project/web/src/store/agent/agent.methods.ts
index 907adf94..140caa8d 100644
--- a/project/web/src/store/agent/agent.methods.ts
+++ b/project/web/src/store/agent/agent.methods.ts
@@ -447,7 +447,7 @@ export function createStoreMethods(ctx: IMethodsContext) {
})
messageUtils.markMessageDone()
- toast.info(refs.t.value?.('aiGeneration.taskStopped' as any) || 'Task stopped')
+ // 移除 toast 显示,改为由调用方处理
},
/** 重置状态 */
diff --git a/project/web/src/store/plugin/store.ts b/project/web/src/store/plugin/store.ts
index 91c4fd34..961ef8c8 100644
--- a/project/web/src/store/plugin/store.ts
+++ b/project/web/src/store/plugin/store.ts
@@ -658,8 +658,65 @@ export const usePluginStore = create(
async executePluginPublish(params: ExecutePluginPublishParams): Promise<void> {
const { items, platformTaskIdMap, publishTime, onProgress, onComplete } = params
+ // 创建发布任务
+ const platformTasks: any = items.map((item) => {
+ const platform = item.account.type as PluginPlatformType
+ const accountId = item.account.id
+ const requestId = platformTaskIdMap.get(accountId) || ''
+
+ // 构造 PublishParams
+ const publishParams: PublishParams = {
+ platform,
+ accountId,
+ requestId,
+ type: item.params.video ? 'video' : 'image',
+ title: item.params.title || '',
+ desc: item.params.des || '',
+ topics: item.params.topics || [],
+ }
+
+ // 添加视频或图片参数
+ if (item.params.video) {
+ publishParams.video = item.params.video.ossUrl
+ if (item.params.video.cover?.ossUrl) {
+ publishParams.cover = item.params.video.cover.ossUrl
+ }
+ } else if (item.params.images && item.params.images.length > 0) {
+ publishParams.images = item.params.images
+ .map(img => img.ossUrl)
+ .filter((url): url is string => typeof url === 'string' && url.length > 0)
+ }
+
+ return {
+ id: generateId(),
+ platform,
+ accountId,
+ requestId,
+ params: publishParams,
+ status: PlatformTaskStatus.PENDING,
+ progress: {
+ stage: 'waiting',
+ progress: 0,
+ message: '等待开始...',
+ },
+ result: null,
+ startTime: Date.now(),
+ endTime: null,
+ error: null,
+ }
+ })
+
+ // 添加到发布任务列表
+ const taskId = methods.addPublishTask({
+ title: items[0]?.params.title || '插件发布任务',
+ description: `发布到 ${items.length} 个平台`,
+ platformTasks,
+ })
+
+ console.log('[PluginStore] Created publish task:', taskId)
+
// 并行执行插件发布(不等待,同时发布多个平台)
- const publishTasks = items.map(async (item) => {
+ const publishPromises = items.map(async (item) => {
const platform = item.account.type as PluginPlatformType
const accountId = item.account.id
// 获取该账号对应的 requestId(用于进度匹配)
@@ -670,17 +727,6 @@ export const usePluginStore = create(
return
}
- // 触发初始进度回调
- onProgress?.({
- stage: 'download',
- progress: 0,
- message: '准备发布...',
- timestamp: Date.now(),
- accountId,
- platform,
- requestId,
- })
-
// 更新任务状态为发布中
methods.updatePlatformTaskByRequestId(requestId, {
status: PlatformTaskStatus.PUBLISHING,
@@ -843,7 +889,7 @@ export const usePluginStore = create(
})
// 并行执行所有发布任务
- await Promise.all(publishTasks)
+ await Promise.all(publishPromises)
// 发布完成后的回调
onComplete?.()