From 5ba5ebb28c34aae0bfd8c4e058de497b0c96f16d Mon Sep 17 00:00:00 2001 From: OYX-1 <74037789+OYX-1@users.noreply.github.com> Date: Wed, 14 Aug 2024 18:30:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20AI=E5=BA=94=E7=94=A8=E7=9A=84=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E7=9B=AE=E5=BD=95=E5=92=8C=E6=8C=82=E8=BD=BD=E7=82=B9?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=97=B6=E6=8A=A5=E9=94=99=20(#1395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 之前挂载点和工作目录重复时会报错: ![img_v3_02dj_fe4f50a9-335e-4a1b-a654-f7d55e7fdb8g](https://github.com/user-attachments/assets/32d214c6-94eb-451f-91db-132552e0afb4) ## 因为工作目录一定会被挂载,该目录再次添加作为挂载点会有问题 ## 改动后前端不允许用户添加和工作目录一样的挂载点目录,提示用户:该路径已指定为工作目录,无需再设置为挂载点 ![image](https://github.com/user-attachments/assets/0b08bacb-b65b-4f9d-9c21-d35b5a4d4255) --- .changeset/strange-lamps-live.md | 5 +++++ .../app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .changeset/strange-lamps-live.md diff --git a/.changeset/strange-lamps-live.md b/.changeset/strange-lamps-live.md new file mode 100644 index 0000000000..e311b69038 --- /dev/null +++ b/.changeset/strange-lamps-live.md @@ -0,0 +1,5 @@ +--- +"@scow/ai": patch +--- + +修复 AI 应用的工作目录和挂载点重复时报错 diff --git a/apps/ai/src/app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx b/apps/ai/src/app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx index 58a9569a1e..ea19affa7b 100644 --- a/apps/ai/src/app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx +++ b/apps/ai/src/app/(auth)/jobs/[clusterId]/LaunchAppForm.tsx @@ -351,6 +351,13 @@ export const LaunchAppForm = (props: Props) => { name={["customFields", item.name]} rules={rules} initialValue={initialValue} + {...(item.name === "workingDir" ? { + tooltip: ( + <> + 工作目录的路径会自动添加为挂载点 + + ), + } : {})} > {inputItem} @@ -748,6 +755,12 @@ export const LaunchAppForm = (props: Props) => { if (otherMountPoints.includes(currentValueNormalized)) { return Promise.reject(new Error("挂载点地址不能重复")); } + + const workingDirectory = form.getFieldValue("customFields").workingDir?.toString(); + if (workingDirectory && workingDirectory.replace(/\/+$/, "") === currentValueNormalized) { + return Promise.reject(new Error("该路径已指定为工作目录,无需再设置为挂载点")); + } + return Promise.resolve(); }, }),