mirror of https://github.com/certd/certd
refactor(ui): 优化 AI聊天功能
- 在打开聊天时增加对空消息的检查,避免发送无效请求 - 在发送消息时添加来源标识,以便服务端区分消息来源 - 在任务视图中增加对空日志的检查,避免触发空指针异常pull/409/head
parent
61a19d694b
commit
b8edd14f39
|
@ -123,6 +123,9 @@ onMounted(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
async function openChat(req: { q: string }) {
|
async function openChat(req: { q: string }) {
|
||||||
|
if (!req.q) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
chatVisible.value = true;
|
chatVisible.value = true;
|
||||||
|
|
||||||
const iframeId = "maxkb-chat";
|
const iframeId = "maxkb-chat";
|
||||||
|
@ -132,7 +135,13 @@ async function openChat(req: { q: string }) {
|
||||||
throw new Error("iframe not found");
|
throw new Error("iframe not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iframe.contentWindow?.postMessage(req, "*");
|
iframe.contentWindow?.postMessage(
|
||||||
|
{
|
||||||
|
...req,
|
||||||
|
from: "certd",
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|
|
@ -62,8 +62,10 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
function onAiChat() {
|
function onAiChat() {
|
||||||
debugger;
|
|
||||||
const logs = currentHistory.value?.logs[activeKey.value];
|
const logs = currentHistory.value?.logs[activeKey.value];
|
||||||
|
if (!logs || logs.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let logText = "";
|
let logText = "";
|
||||||
for (let log of logs) {
|
for (let log of logs) {
|
||||||
logText += log + "\n";
|
logText += log + "\n";
|
||||||
|
|
Loading…
Reference in New Issue