feat:通知主题修改

This commit is contained in:
liailing1026
2026-01-26 17:25:23 +08:00
parent 418b2e5f8f
commit 1749ae4f1e
2 changed files with 49 additions and 8 deletions

View File

@@ -133,6 +133,14 @@ export function useNotification() {
} }
} }
// 更新通知的主标题
const updateNotificationTitle = (id: string, title: string) => {
const notification = notifications.value.find((n) => n.id === id)
if (notification) {
notification.title = title
}
}
const clear = () => { const clear = () => {
notifications.value.forEach((n) => n.onClose?.()) notifications.value.forEach((n) => n.onClose?.())
notifications.value = [] notifications.value = []
@@ -149,6 +157,7 @@ export function useNotification() {
progress, progress,
updateProgress, updateProgress,
updateProgressDetail, updateProgressDetail,
updateNotificationTitle,
clear, clear,
} }
} }

View File

@@ -358,12 +358,25 @@ const {
notifications, notifications,
progress: showProgress, progress: showProgress,
updateProgressDetail, updateProgressDetail,
updateNotificationTitle,
success, success,
info, info,
warning, warning,
error error
} = useNotification() } = useNotification()
const currentProgressNotificationId = ref<string | null>(null) const currentProgressNotificationId = ref<string | null>(null)
const currentProgressTitle = ref('任务执行中') // 🆕 追踪当前进度通知的标题
/**
* 更新进度通知的标题
*/
function updateProgressNotificationTitle(title: string) {
currentProgressTitle.value = title
if (currentProgressNotificationId.value) {
// 直接更新通知的主标题
updateNotificationTitle(currentProgressNotificationId.value, title)
}
}
// Pause functionality state // Pause functionality state
const isPaused = ref(false) const isPaused = ref(false)
@@ -484,10 +497,13 @@ async function executeNextReadyBatch() {
currentStepName: event.step_name currentStepName: event.step_name
} }
// 创建或更新进度通知,显示详细步骤信息 // 🆕 创建或更新进度通知,显示详细步骤信息(根据状态显示不同标题)
const currentTitle = isPausing.value ? '暂停中' : '任务执行中'
updateProgressNotificationTitle(currentTitle)
if (!currentProgressNotificationId.value) { if (!currentProgressNotificationId.value) {
currentProgressNotificationId.value = showProgress( currentProgressNotificationId.value = showProgress(
'任务执行中', currentTitle,
executionProgress.value.currentStep, executionProgress.value.currentStep,
executionProgress.value.totalSteps executionProgress.value.totalSteps
) )
@@ -533,7 +549,10 @@ async function executeNextReadyBatch() {
// 当前动作完成,完成暂停 // 当前动作完成,完成暂停
isPaused.value = true isPaused.value = true
isPausing.value = false isPausing.value = false
success('已暂停', '已暂停执行,可稍后继续') // 🆕 更新进度通知标题为"已暂停..."
updateProgressNotificationTitle('已暂停')
// 只显示简短的成功提示,不覆盖进度通知
console.log('✅ 已暂停执行')
} }
// 更新详细进度信息,显示动作级别进度 // 更新详细进度信息,显示动作级别进度
@@ -603,11 +622,13 @@ async function executeNextReadyBatch() {
} }
}) })
// 关闭进度通知并显示完成通知 // 🆕 关闭进度通知并显示完成通知
if (currentProgressNotificationId.value) { if (currentProgressNotificationId.value) {
removeNotification(currentProgressNotificationId.value) removeNotification(currentProgressNotificationId.value)
currentProgressNotificationId.value = null currentProgressNotificationId.value = null
} }
// 重置标题
currentProgressTitle.value = '任务执行中'
success('任务执行完成', `所有步骤已执行完成`, { duration: 3000 }) success('任务执行完成', `所有步骤已执行完成`, { duration: 3000 })
resolve() resolve()
@@ -759,6 +780,8 @@ async function handlePauseResume() {
// 只有在收到成功响应后才更新状态 // 只有在收到成功响应后才更新状态
isPaused.value = false isPaused.value = false
isPausing.value = false isPausing.value = false
// 🆕 恢复执行时更新进度通知标题
updateProgressNotificationTitle('任务执行中')
success('已恢复', '已恢复执行') success('已恢复', '已恢复执行')
} else { } else {
warning('无法恢复', 'WebSocket未连接无法恢复执行') warning('无法恢复', 'WebSocket未连接无法恢复执行')
@@ -773,7 +796,7 @@ async function handlePauseResume() {
if (websocket.connected) { if (websocket.connected) {
// 先设置 isPausing允许接收当前正在执行的动作的结果 // 先设置 isPausing允许接收当前正在执行的动作的结果
isPausing.value = true isPausing.value = true
info('暂停中', '正在等待当前动作完成...') info('暂停中', '正在等待当前动作完成')
await websocket.send('pause_execution', { await websocket.send('pause_execution', {
goal: agentsStore.agentRawPlan.data?.['General Goal'] || '' goal: agentsStore.agentRawPlan.data?.['General Goal'] || ''
@@ -967,10 +990,13 @@ async function restartFromStep(stepIndex: number) {
const currentStepNumber = const currentStepNumber =
globalStepIndex >= 0 ? globalStepIndex + 1 : (event.step_index || 0) + 1 globalStepIndex >= 0 ? globalStepIndex + 1 : (event.step_index || 0) + 1
// 创建或更新进度通知 // 🆕 创建或更新进度通知(根据状态显示不同标题)
const restartTitle = isPausing.value ? '暂停中' : '重新执行中'
updateProgressNotificationTitle(restartTitle)
if (!currentProgressNotificationId.value) { if (!currentProgressNotificationId.value) {
currentProgressNotificationId.value = showProgress( currentProgressNotificationId.value = showProgress(
'重新执行中', restartTitle,
currentStepNumber, currentStepNumber,
collaborationProcess.value.length collaborationProcess.value.length
) )
@@ -996,7 +1022,9 @@ async function restartFromStep(stepIndex: number) {
// 当前动作完成,完成暂停 // 当前动作完成,完成暂停
isPaused.value = true isPaused.value = true
isPausing.value = false isPausing.value = false
success('已暂停', '已暂停执行,可稍后继续') // 🆕 更新进度通知标题为"已暂停..."
updateProgressNotificationTitle('已暂停')
console.log('✅ 已暂停执行')
} }
// 实时更新store // 实时更新store
@@ -1196,6 +1224,10 @@ async function handleRun() {
// Reset pause and streaming state // Reset pause and streaming state
isPaused.value = false isPaused.value = false
isStreaming.value = false isStreaming.value = false
isPausing.value = false
// 🆕 重置进度通知标题
currentProgressTitle.value = '任务执行中'
// Start execution // Start execution
loading.value = true loading.value = true