首页plus
This commit is contained in:
@@ -375,6 +375,7 @@ export interface SessionListItem {
|
||||
flowName: string;
|
||||
sessionId: string;
|
||||
createDate: string;
|
||||
status?: number; // 1=执行中, 2=成功, 3=失败
|
||||
}
|
||||
|
||||
/** 获取会话记录列表 */
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
<div class="item-body">
|
||||
<div class="item-title">{{ item.title }}</div>
|
||||
<div v-if="item.status === 'executing'" class="status-badge status-running">执行中</div>
|
||||
<div v-if="item.status === 'completed'" class="status-badge status-done">执行完成</div>
|
||||
<div v-if="item.status === 'failed'" class="status-badge status-failed">执行失败</div>
|
||||
<div class="item-time">{{ item.time }}</div>
|
||||
</div>
|
||||
<button class="item-del-btn" @click.stop="handleDeleteHistory(item.id)">
|
||||
@@ -486,15 +484,7 @@ const handleDeleteNode = (data: TreeNode) => emit('delete-node', data);
|
||||
animation: pulse 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.status-done {
|
||||
background: #d1fae5;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
.status-failed {
|
||||
background: #fee2e2;
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
:active-history-id="activeHistoryId"
|
||||
@close-workflow="handleCloseWorkflow"
|
||||
/>
|
||||
<InputBar ref="inputBarRef" :send-disabled="!!(activeHistoryId && sendingSessions[activeHistoryId])" @send="handleSend" @workflow-select="handleWorkflowSelect" />
|
||||
<InputBar ref="inputBarRef" :send-disabled="isSendDisabled" @send="handleSend" @workflow-select="handleWorkflowSelect" />
|
||||
</div>
|
||||
|
||||
<!-- 预览弹窗 -->
|
||||
@@ -46,7 +46,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ref, reactive, computed, onMounted } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import Sidebar from './components/Sidebar.vue';
|
||||
import MainContent from './components/MainContent.vue';
|
||||
@@ -208,6 +208,10 @@ const removeNode = (nodes: TreeNode[], targetId: string): boolean => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const mapSessionStatus = (code?: number): 'executing' | undefined => {
|
||||
return code === 1 ? 'executing' : undefined;
|
||||
};
|
||||
|
||||
const getSessionData = (res: any): any[] => {
|
||||
if (!res?.data) return [];
|
||||
if (Array.isArray(res.data)) return res.data;
|
||||
@@ -241,6 +245,7 @@ const getList = async () => {
|
||||
sessionId: s.sessionId,
|
||||
title: s.flowName || '未命名会话',
|
||||
time: displayTime,
|
||||
status: mapSessionStatus(s.status),
|
||||
};
|
||||
});
|
||||
historyList.value = sessions;
|
||||
@@ -267,6 +272,13 @@ const workspaceLoading = ref(false);
|
||||
const sendingSessions = reactive<Record<string, boolean>>({});
|
||||
const inputBarRef = ref<any>(null);
|
||||
|
||||
const isSendDisabled = computed(() => {
|
||||
if (!activeHistoryId.value) return false;
|
||||
if (sendingSessions[activeHistoryId.value]) return true;
|
||||
const session = historyList.value.find((h) => h.id === activeHistoryId.value);
|
||||
return session?.status === 'executing';
|
||||
});
|
||||
|
||||
const getSessionId = () => {
|
||||
return `session_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
|
||||
};
|
||||
@@ -447,7 +459,7 @@ const handleSend = async (message: string) => {
|
||||
time: formatTime(new Date()),
|
||||
isUser: false,
|
||||
});
|
||||
ElMessage.success('执行完成');
|
||||
ElMessage.success('✅ 执行完成,可前往工作空间查看');
|
||||
// 重置分页并刷新工作空间树
|
||||
workspacePage.value = 1;
|
||||
hasMoreWorkspace.value = true;
|
||||
@@ -479,7 +491,8 @@ const handleSend = async (message: string) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "执行失败,请重试");
|
||||
curSession.status = 'failed';
|
||||
addMessage({
|
||||
id: 'msg-' + Date.now() + '-fail',
|
||||
@@ -487,6 +500,30 @@ const handleSend = async (message: string) => {
|
||||
time: formatTime(new Date()),
|
||||
isUser: false,
|
||||
});
|
||||
// 虚拟会话执行失败也刷新列表(后端会创建 status=3 的记录)
|
||||
if (curSession.id.startsWith('virtual_')) {
|
||||
getSessionList().then((sessionRes) => {
|
||||
const freshList = getSessionData(sessionRes).map((s: any) => ({
|
||||
id: s.id,
|
||||
sessionId: s.sessionId,
|
||||
title: s.flowName || '未命名会话',
|
||||
time: s.createDate?.substring(0, 10) || '',
|
||||
}));
|
||||
const match = freshList.find((s: any) => s.sessionId === curSession.sessionId);
|
||||
if (match) {
|
||||
const idx = historyList.value.findIndex((h) => h.id === curSession.id);
|
||||
if (idx >= 0) {
|
||||
const msgs = sessionMessages.value.get(curSession.id);
|
||||
sessionMessages.value.delete(curSession.id);
|
||||
sessionMessages.value.set(match.id, msgs || []);
|
||||
historyList.value[idx] = { ...match, status: curSession.status };
|
||||
if (activeHistoryId.value === curSession.id) {
|
||||
activeHistoryId.value = match.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
delete sendingSessions[sid];
|
||||
}
|
||||
@@ -515,8 +552,8 @@ const handleSelectHistory = async (id: string) => {
|
||||
} else {
|
||||
selectedWorkflowDetail.value = null;
|
||||
}
|
||||
// 清除 completed/failed 标记
|
||||
if (session?.status === 'completed' || session?.status === 'failed') {
|
||||
// 清除可重新执行的标记
|
||||
if (session?.status === 'completed' || session?.status === 'failed' || (session?.status === 'executing' && !sendingSessions[session.id])) {
|
||||
session.status = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user