From b8edd14f3965915073f18ee12dbf08b5ab811d67 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 14 May 2025 15:46:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BC=98=E5=8C=96=20AI?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在打开聊天时增加对空消息的检查,避免发送无效请求 - 在发送消息时添加来源标识,以便服务端区分消息来源 - 在任务视图中增加对空日志的检查,避免触发空指针异常 --- packages/ui/certd-client/src/components/ai/index.vue | 11 ++++++++++- .../pipeline/pipeline/component/task-view/index.vue | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/ui/certd-client/src/components/ai/index.vue b/packages/ui/certd-client/src/components/ai/index.vue index 8bd9c85d..6020f614 100644 --- a/packages/ui/certd-client/src/components/ai/index.vue +++ b/packages/ui/certd-client/src/components/ai/index.vue @@ -123,6 +123,9 @@ onMounted(() => { }); async function openChat(req: { q: string }) { + if (!req.q) { + return; + } chatVisible.value = true; const iframeId = "maxkb-chat"; @@ -132,7 +135,13 @@ async function openChat(req: { q: string }) { throw new Error("iframe not found"); return; } - iframe.contentWindow?.postMessage(req, "*"); + iframe.contentWindow?.postMessage( + { + ...req, + from: "certd", + }, + "*" + ); } defineExpose({ diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue index ebe89e43..64352e03 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-view/index.vue @@ -62,8 +62,10 @@ export default { }); function onAiChat() { - debugger; const logs = currentHistory.value?.logs[activeKey.value]; + if (!logs || logs.length === 0) { + return; + } let logText = ""; for (let log of logs) { logText += log + "\n";