From 4fe4aa1e6bfd2d73dd276eb5729f5625424a3529 Mon Sep 17 00:00:00 2001 From: lyp Date: Tue, 4 Mar 2025 13:18:18 +0800 Subject: [PATCH] =?UTF-8?q?ai=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ai/AiHelper.tsx | 61 +++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/src/components/ai/AiHelper.tsx b/src/components/ai/AiHelper.tsx index bcfef1b..f1d1222 100644 --- a/src/components/ai/AiHelper.tsx +++ b/src/components/ai/AiHelper.tsx @@ -30,7 +30,7 @@ type PropsType = { projDesc?: string; isFree: boolean; renderData: any; - chargeType:any + chargeType: any } type ProjModType = { @@ -188,13 +188,15 @@ export default function AiHelper(props: PropsType) { ping(); } ws.current.onmessage = (event) => { - // console.log('message', event); - // console.log(event.data); + console.log('message', event.data); + if (event.data == 'PONE') { return; } const data = JSON.parse(event.data); + // console.log('data',data.type); + if (data.projId != props.projId) { return; } @@ -249,9 +251,50 @@ export default function AiHelper(props: PropsType) { // setIsProjModArrayLoading(true); listMods(); } + // else if (data.type == 'SYSTEM_ERROR') { + // console.log(data.content); + // // console.log(JSON.parse()); + // // messageApi.error(data.content) + // // const con = JSON.parse(data.content) + // const parts = data.content.split(':'); + // const errorType = parts[1].trim(); + // if (errorType == 'introduction') { + // messageApi.error('请重试') + // setIsProjIntroductionLoading(false); + // setIsProjDescLoading(false); + // setIsProjModArrayLoading(false); + // }else if(errorType == 'desc'){ + // messageApi.error('请重试') + // setIsProjDescLoading(false); + // }else if(errorType == 'mods'){ + // messageApi.error('请重试') + // setIsProjModArrayLoading(false); + // } + + + // } + else if (data.type == 'PROJ_INTRODUCTION_ERROR') { + messageApi.error('请重试') + setIsProjIntroductionLoading(false); + setIsProjDescLoading(false); + setIsProjModArrayLoading(false); + // return; + } + else if (data.type == 'PROJ_DESC_ERROR') { + messageApi.error('系统详情生成失败 , 请重试') + setIsProjDescLoading(false); + } + else if (data.type == 'PROJ_MODS_ERROR') { + messageApi.error('功能列表生成失败 , 请重试') + setIsProjModArrayLoading(false); + } } ws.current.onerror = (event) => { console.log('error', event); + // setIsProjModArrayLoading(false); + // setIsProjDescLoading(false); + // setIsProjIntroductionLoading(false); + // messageApi.error('请重试') } ws.current.onclose = (event) => { console.log('close', event); @@ -313,14 +356,14 @@ export default function AiHelper(props: PropsType) { url: `/api/proj/auto/get-introduction-desc-mods/${props.projId}`, config: { params: { - + } }, onBefore() { }, onSuccess() { - + }, onFinally() { @@ -341,14 +384,14 @@ export default function AiHelper(props: PropsType) { url: `/api/proj/auto/get-desc/${props.projId}`, config: { params: { - + } }, onBefore() { }, onSuccess() { - + }, onFinally() { @@ -368,14 +411,14 @@ export default function AiHelper(props: PropsType) { url: `/api/proj/auto/get-mods/${props.projId}`, config: { params: { - + } }, onBefore() { }, onSuccess() { - + }, onFinally() {