diff --git a/src/components/ai/AiHelper.tsx b/src/components/ai/AiHelper.tsx index 27b2040..35e3194 100644 --- a/src/components/ai/AiHelper.tsx +++ b/src/components/ai/AiHelper.tsx @@ -1,18 +1,20 @@ import {useContext, useEffect, useRef, useState} from "react"; import {GlobalContext} from "../../context/GlobalContext.ts"; -import {get, post, put, WebSocketBaseUrl} from "../../util/AjaxUtils.ts"; +import {del, get, post, put, websocketUrl} from "../../util/AjaxUtils.ts"; import {Col, Divider, Row, Spin} from "antd"; import useMessage from "antd/es/message/useMessage"; import AiHelperText from "./text/AiHelperText.tsx"; import AiHelperMod from "./mod/AiHelperMod.tsx"; import {IProjMod} from "../../interfaces/proj/IProj.ts"; import {MAX_MOD_SIZE} from "../../route/proj/edit/ProjConfigModList.tsx"; +import {useNavigate} from "react-router-dom"; +import {uuid} from "../../util/CommonUtil.ts"; type PropsType = { projId: string; projIntroduction?: string; projDesc?: string; - projMods?: ProjModType[]; + isFree: boolean; } type ProjModType = { @@ -37,6 +39,7 @@ export default function AiHelper(props: PropsType) { const [projModArray, setProjModArray] = useState([]); const [newProjModArray, setNewProjModArray] = useState([]); const [isProjModArrayLoading, setIsProjModArrayLoading] = useState(false); + const nav = useNavigate(); const ping = () => { @@ -51,7 +54,7 @@ export default function AiHelper(props: PropsType) { } const websocket = () => { - ws.current = new WebSocket(`${WebSocketBaseUrl}/ws/ai/${globalContext.user.userId}`); + ws.current = new WebSocket(`${websocketUrl()}/ws/ai/${globalContext.user.userId}`); ws.current.onopen = (event) => { console.log('打开', event); ping(); @@ -73,6 +76,7 @@ export default function AiHelper(props: PropsType) { } else if (data.type == 'REFRESH_PROJ_MODS') { setIsProjModArrayLoading(false); const projMods = JSON.parse(data.content) as ProjModType[]; + projMods.forEach(projMod => projMod.id = uuid()) setNewProjModArray(projMods); } else if (data.type == 'REFRESH_PROJ_MOD_FIELDS') { listMods(); @@ -273,6 +277,37 @@ export default function AiHelper(props: PropsType) { } }) }} + handleEdit={(_index, projModId, item) => { + if(item.aiFieldStatus != 'SUCCESS') { + messageApi.error('模块未处理完毕不能编辑'); + return; + } + if(props.isFree) { + nav(`/proj-edit/config-mod-fedit/${props.projId}/${projModId}`) + } else { + nav(`/proj-edit/config-mod-edit/${props.projId}/${projModId}`) + } + }} + handleRemove={(_index, projModId, item) => { + if(item.aiFieldStatus != 'SUCCESS') { + messageApi.error('模块未处理完毕不能删除'); + return; + } + del({ + messageApi, + url: `/api/proj-mod/remove/proj-id/${props.projId}/${projModId}`, + onBefore() { + setIsProjModArrayLoading(true); + }, + onSuccess() { + messageApi.success('删除成功'); + listMods(); + }, + onFinally() { + setIsProjModArrayLoading(false); + } + }) + }} /> diff --git a/src/components/ai/mod/AiHelperMod.tsx b/src/components/ai/mod/AiHelperMod.tsx index 22452a5..70599cc 100644 --- a/src/components/ai/mod/AiHelperMod.tsx +++ b/src/components/ai/mod/AiHelperMod.tsx @@ -9,6 +9,8 @@ type PropsType = { handleGenerate: () => void; handleSave: (index: number, mod: ProjModType) => void; handleResaveField: (index: number, projModId: string) => void; + handleRemove: (index: number, projModId: string, item: IProjMod) => void; + handleEdit: (index: number, projModId: string, item: IProjMod) => void; } type ProjModType = { @@ -16,16 +18,6 @@ type ProjModType = { desc: string, } -const savedItems = [ - { - key: 'edit', - label: '编辑', - },{ - key: 'remove', - label: '删除', - }, -] - export default function AiHelperMod(props: PropsType) { const [modArray, setModArray] = useState([]); const [newModArray, setNewModArray] = useState([]); @@ -58,7 +50,7 @@ export default function AiHelperMod(props: PropsType) { if(value == 'GENERATING') { return '处理中' } - if(value == 'FIELD') { + if(value == 'FAILED') { return '失败' } if(value == 'SUCCESS') { @@ -82,7 +74,21 @@ export default function AiHelperMod(props: PropsType) { }}> } return ( - + { + props.handleEdit(index, record.projModId, record); + } + },{ + key: 'remove', + label: '删除', + onClick: () => { + props.handleRemove(index, record.projModId, record); + } + }, + ] }} placement="bottom" arrow> ) @@ -123,14 +129,17 @@ export default function AiHelperMod(props: PropsType) { return ( <> +
模块管理
{newModArray.length > 0 ? 原模块 : <>} - +
{ newModArray.length > 0 ? ( <> 新模块 -
+
) : <> } diff --git a/src/components/card/CardProjLoading.tsx b/src/components/card/CardProjLoading.tsx index 2f8d329..2090b27 100644 --- a/src/components/card/CardProjLoading.tsx +++ b/src/components/card/CardProjLoading.tsx @@ -19,7 +19,12 @@ export default function CardProjLoading(props: IProjLoading) { }, [duration]) return ( -
+
{ + if (!props.handleClick) { + return; + } + props.handleClick(); + }}>
{props.title} diff --git a/src/components/card/card-proj-loading.css b/src/components/card/card-proj-loading.css index e5096b7..a781f03 100644 --- a/src/components/card/card-proj-loading.css +++ b/src/components/card/card-proj-loading.css @@ -1,6 +1,7 @@ .card-proj-loading { width: 224px; padding: 10px 15px; + cursor: pointer; } .card-proj-loading .title { diff --git a/src/interfaces/card/ICardProj.ts b/src/interfaces/card/ICardProj.ts index 299ac39..9997a70 100644 --- a/src/interfaces/card/ICardProj.ts +++ b/src/interfaces/card/ICardProj.ts @@ -19,6 +19,8 @@ export interface IProjLoading { desc?: string; duration: number; + handleClick?(): void; + handleCountDownOver(): void; } diff --git a/src/route/proj/ProjCreate.tsx b/src/route/proj/ProjCreate.tsx index 554454e..eb77b60 100644 --- a/src/route/proj/ProjCreate.tsx +++ b/src/route/proj/ProjCreate.tsx @@ -45,92 +45,92 @@ export default function ProjCreate() { />
- { - nav(`/proj-new/${ProjChargeType.ALL}`) - } - } - ]} - /> - { - nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`) - } - }, - { - id: ProjChargeType.MATERIAL_AGENT_URGENT, - label: '加急:', - price: charge.proj.materialAgentUrgent, - handleClick: (_title, additional) => { - nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT_URGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`) - } - } - ]} - /> + {/* {*/} + {/* nav(`/proj-new/${ProjChargeType.ALL}`)*/} + {/* }*/} + {/* }*/} + {/* ]}*/} + {/*/>*/} + {/* {*/} + {/* nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`)*/} + {/* }*/} + {/* },*/} + {/* {*/} + {/* id: ProjChargeType.MATERIAL_AGENT_URGENT,*/} + {/* label: '加急:',*/} + {/* price: charge.proj.materialAgentUrgent,*/} + {/* handleClick: (_title, additional) => {*/} + {/* nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT_URGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`)*/} + {/* }*/} + {/* }*/} + {/* ]}*/} + {/*/>*/} { - nav(`/proj-new/${ProjChargeType.MATERIAL}`) - } - } - ]} - /> - { - nav(`/proj-new/${ProjChargeType.FREE}`) + handleClick: (_title, additional) => { + nav(`/proj-new/${ProjChargeType.MATERIAL}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`); } } ]} /> + {/* {*/} + {/* nav(`/proj-new/${ProjChargeType.FREE}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`)*/} + {/* }*/} + {/* }*/} + {/* ]}*/} + {/*/>*/}
diff --git a/src/route/proj/ProjEdit.tsx b/src/route/proj/ProjEdit.tsx index fc46a7a..ec24cf3 100644 --- a/src/route/proj/ProjEdit.tsx +++ b/src/route/proj/ProjEdit.tsx @@ -11,7 +11,7 @@ import CardProjJump from "../../components/card/CardProjJump.tsx"; import {useEffect, useState} from "react"; import {Axios, get, post} from "../../util/AjaxUtils.ts"; import {EditStepEnum, IProjEdit} from "../../interfaces/card/ICardProj.ts"; -import {MAX_MOD_SIZE} from "./edit/ProjConfigModList.tsx"; +import {MIN_MOD_SIZE} from "./edit/ProjConfigModList.tsx"; import {GenerateStatus} from "../../interfaces/proj/IProj.ts"; import AiHelper from "../../components/ai/AiHelper.tsx"; @@ -168,7 +168,7 @@ export default function ProjEdit() { desc: '请对系统菜单进行设置', step: 2, btnName: !isGenerateSuccess ? '设置' : '查看', - status: data.projModCount > MAX_MOD_SIZE ? EditStepEnum.EDITED : EditStepEnum.UN_EDIT, + status: data.projModCount >= MIN_MOD_SIZE ? EditStepEnum.EDITED : EditStepEnum.UN_EDIT, handleEdit() { if (!isGenerateSuccess) { nav(`/proj-edit/config-mod-list/${pathParams.projId}`) @@ -182,7 +182,7 @@ export default function ProjEdit() { desc: '调整菜单顺序', step: 3, btnName: !isGenerateSuccess ? '设置' : '查看', - status: data.projModCount > MAX_MOD_SIZE ? EditStepEnum.EDITED : EditStepEnum.UN_EDIT, + status: data.projModCount >= MIN_MOD_SIZE ? EditStepEnum.EDITED : EditStepEnum.UN_EDIT, handleEdit() { if (!isGenerateSuccess) { nav(`/proj-edit/config-menu-list/${pathParams.projId}`) @@ -207,7 +207,7 @@ export default function ProjEdit() { && data.editSteps[3].editStatus == EditStepEnum.EDITED && data.editSteps[4].editStatus == EditStepEnum.EDITED && data.editSteps[5].editStatus == EditStepEnum.EDITED; - const isConfig = data.loginpage.loginpageId && data.projModCount > MAX_MOD_SIZE; + const isConfig = data.loginpage.loginpageId && data.projModCount > MIN_MOD_SIZE; const isGenerate = isEdited && isConfig; const isGenerateSuccess: boolean = data.generate.generateStatus == GenerateStatus.SUCCESS; renderEditStep(data.editSteps, isEdited, isGenerateSuccess); @@ -272,7 +272,7 @@ export default function ProjEdit() { title={item.title} desc={item.desc} btnName={item.btnName} - canBtnClick={true} + canBtnClick={item.status == EditStepEnum.EDITED} status={item.status} handleEdit={item.handleEdit} /> @@ -282,6 +282,7 @@ export default function ProjEdit() { isEditStepEdited && isConfigEdited ? ( { window.open(`${Axios.defaults?.baseURL}/${previewUrl}`, '_blank') }} @@ -302,6 +303,9 @@ export default function ProjEdit() { canBtnClick={canGenerate} handleEdit={() => { setIsGenerateModalOpen(true); + setTimeout(() => { + window.location.reload(); + }, 1000) }} /> ) : <> @@ -312,7 +316,9 @@ export default function ProjEdit() { desc="资料正在排队" duration={generateEmainingTime} handleCountDownOver={() => { - renderData(); + setTimeout(() => { + window.location.reload(); + }, 1000) }} /> ) : <> @@ -320,8 +326,11 @@ export default function ProjEdit() { { generateStatus == GenerateStatus.GENERATING ? ( { + renderData(); + }} handleCountDownOver={() => { renderData(); }} @@ -445,15 +454,18 @@ export default function ProjEdit() { title="AI助手" width={1200} footer={false} + maskClosable={false} + destroyOnClose onCancel={() => { setAiHelperModalOpen(false); + renderData() }} > diff --git a/src/route/proj/edit/ProjConfigModList.tsx b/src/route/proj/edit/ProjConfigModList.tsx index e930d54..68df540 100644 --- a/src/route/proj/edit/ProjConfigModList.tsx +++ b/src/route/proj/edit/ProjConfigModList.tsx @@ -10,7 +10,7 @@ import {useEffect, useState} from "react"; import {EditOutlined, PlusOutlined, DeleteOutlined, SearchOutlined} from "@ant-design/icons"; import {del, get} from "../../../util/AjaxUtils.ts"; -export const MAX_MOD_SIZE = 18; +export const MAX_MOD_SIZE = 15; export const MIN_MOD_SIZE = 10 export const MAX_MOD_SIZE_FREE = 3 export const MIN_MOD_SIZE_FREE = 1 diff --git a/src/route/proj/edit/ProjEditStep4.tsx b/src/route/proj/edit/ProjEditStep4.tsx index 25f3f08..2a2b268 100644 --- a/src/route/proj/edit/ProjEditStep4.tsx +++ b/src/route/proj/edit/ProjEditStep4.tsx @@ -66,7 +66,7 @@ export default function ProjEditStep4() { authorIdCard: data.authorIdCard, authorNation: data.authorNation ? data.authorNation : '中国', authorProvince: data.authorProvince ? data.authorProvince.split(',') : '', - authorEstablishDate: dayjs(data.authorEstablishDate, 'YYYY-MM-DD'), + authorEstablishDate: data.authorEstablishDate ? dayjs(data.authorEstablishDate, 'YYYY-MM-DD') : '', }) } }) diff --git a/src/util/AjaxUtils.ts b/src/util/AjaxUtils.ts index f08d682..8d95550 100644 --- a/src/util/AjaxUtils.ts +++ b/src/util/AjaxUtils.ts @@ -3,12 +3,13 @@ import type {MessageInstance} from "antd/es/message/interface"; export const Axios = axios; -axios.defaults.baseURL = 'http://127.0.0.1:7025/copyright'; -// axios.defaults.baseURL = '/copyright'; -export const WebSocketBaseUrl: string = "ws://127.0.0.1:7025/copyright" -export const DevUserId: string = '80d3365e-0597-4988-979e-18ef1c3ec671'; // 18634604067 +// axios.defaults.baseURL = 'http://127.0.0.1:7025/copyright'; +axios.defaults.baseURL = '/copyright'; +// export const WebSocketBaseUrl: string = 'ws://127.0.0.1:7025/copyright'; +export const WebSocketBaseUrl: string = '/copyright'; +// export const DevUserId: string = '80d3365e-0597-4988-979e-18ef1c3ec671'; // 18634604067 // export const DevUserId: string = 'c2438eb8-2685-49a9-bf02-5111a5192d96'; // 18647109157 -// export const DevUserId: string = ''; +export const DevUserId: string = ''; type Req = { messageApi: MessageInstance; @@ -36,6 +37,19 @@ axios.interceptors.request.use(config => { } ); +export function websocketUrl() { + if (WebSocketBaseUrl.startsWith('ws')) { + return WebSocketBaseUrl; + } + const location = window.location; + const protocol = location.protocol; + let wsProtocol = 'ws'; + if (protocol == 'https') { + wsProtocol = 'wss'; + } + return `${wsProtocol}://${location.host}${WebSocketBaseUrl}`; +} + export function downloadUrl(fileId: string, isDownload?: boolean) { return `${Axios.defaults?.baseURL}/route/file/v2/download/${isDownload == false}/${fileId}` }