From e67db8b05f6dbccbcbdf6a87e987cd5a419b557a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E9=87=8C=E7=9A=84=E6=B0=B8?= =?UTF-8?q?=E5=B9=B3?= Date: Wed, 23 Jul 2025 17:36:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=AC=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9=E5=A6=82=E4=B8=8B=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E8=AE=A1=E5=88=92=E5=9F=BA=E7=A1=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=90=9E=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/api/common.ts | 7 +-- nkebao/src/pages/scenarios/plan/new/index.tsx | 2 +- .../plan/new/steps/BasicSettings.tsx | 56 ++++++++++++------- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/nkebao/src/api/common.ts b/nkebao/src/api/common.ts index 9ab445cc..6e675d3b 100644 --- a/nkebao/src/api/common.ts +++ b/nkebao/src/api/common.ts @@ -21,12 +21,7 @@ export async function uploadFile( }, }); - // 检查响应结果 - if (res?.code === 200 && res?.data?.url) { - return res.data.url; - } else { - throw new Error(res?.msg || "文件上传失败"); - } + return res.url; } catch (e: any) { throw new Error(e?.message || "文件上传失败"); } diff --git a/nkebao/src/pages/scenarios/plan/new/index.tsx b/nkebao/src/pages/scenarios/plan/new/index.tsx index 96bae635..7ab9db15 100644 --- a/nkebao/src/pages/scenarios/plan/new/index.tsx +++ b/nkebao/src/pages/scenarios/plan/new/index.tsx @@ -204,7 +204,7 @@ export default function NewPlan() { - + } diff --git a/nkebao/src/pages/scenarios/plan/new/steps/BasicSettings.tsx b/nkebao/src/pages/scenarios/plan/new/steps/BasicSettings.tsx index dde074fc..abc55a50 100644 --- a/nkebao/src/pages/scenarios/plan/new/steps/BasicSettings.tsx +++ b/nkebao/src/pages/scenarios/plan/new/steps/BasicSettings.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef } from "react"; -import { Form, Input, Button, Tag, Switch, Modal } from "antd"; +import { Form, Input, Button, Tag, Switch, Modal, Spin } from "antd"; import { Button as ButtonMobile } from "antd-mobile"; import { PlusOutlined, @@ -10,7 +10,6 @@ import { CheckOutlined, } from "@ant-design/icons"; import { uploadFile } from "@/api/common"; -import Layout from "@/components/Layout/Layout"; import styles from "./base.module.scss"; interface BasicSettingsProps { @@ -418,23 +417,36 @@ const BasicSettings: React.FC = ({
{/* 场景选择区块 */}
-
- {sceneList.map((scene) => { - const selected = formData.scenario === scene.id; - return ( - - ); - })} -
+ {sceneLoading ? ( +
+ +
+ ) : ( +
+ {sceneList.map((scene) => { + const selected = formData.scenario === scene.id; + return ( + + ); + })} +
+ )}
{/* 计划名称输入区 */}
计划名称
@@ -586,7 +598,6 @@ const BasicSettings: React.FC = ({ onChange={async (e) => { const file = e.target.files?.[0]; if (file) { - // 直接上传 try { const url = await uploadFile(file); const newPoster = { @@ -595,9 +606,14 @@ const BasicSettings: React.FC = ({ type: "poster", preview: url, }; + console.log(newPoster); + setCustomPosters((prev) => [...prev, newPoster]); + setSelectedMaterials([newPoster]); + onChange({ ...formData, materials: [newPoster] }); } catch (err) { // 可加toast提示 + log; } e.target.value = ""; }