From 98a20a5c0b63f00bcbd7777fba0fcc47d383b6e6 Mon Sep 17 00:00:00 2001 From: none Date: Wed, 8 Mar 2023 19:13:54 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/upload-image-button/index.tsx | 2 +- .../upload-image-sub/index.tsx | 17 +++++++++-------- src/pages/resource/images/index.tsx | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/compenents/upload-image-button/index.tsx b/src/compenents/upload-image-button/index.tsx index c1925c2..af52c7c 100644 --- a/src/compenents/upload-image-button/index.tsx +++ b/src/compenents/upload-image-button/index.tsx @@ -175,7 +175,7 @@ export const UploadImageButton = (props: PropsInterface) => { { resetImageList(); }} diff --git a/src/compenents/upload-image-button/upload-image-sub/index.tsx b/src/compenents/upload-image-button/upload-image-sub/index.tsx index b5a8718..ad576e8 100644 --- a/src/compenents/upload-image-button/upload-image-sub/index.tsx +++ b/src/compenents/upload-image-button/upload-image-sub/index.tsx @@ -6,7 +6,7 @@ import { getToken } from "../../../utils"; import { InboxOutlined } from "@ant-design/icons"; interface PropsInterface { - categoryId: number; + categoryIds: number[]; onUpdate: () => void; } @@ -18,18 +18,19 @@ export const UploadImageSub = (props: PropsInterface) => { multiple: true, action: config.app_url + - "/backend/v1/upload/file?category_id=" + - props.categoryId, + "/backend/v1/upload/file?category_ids=" + + props.categoryIds.join(","), headers: { authorization: "Bearer " + getToken(), }, onChange(info: any) { - const { status } = info.file; - if (status !== "uploading") { - console.log(info.file, info.fileList); - } + const { status, response } = info.file; if (status === "done") { - message.success(`${info.file.name} 上传成功`); + if (response.code == 0) { + message.success(`${info.file.name} 上传成功`); + } else { + message.error(response.msg); + } } else if (status === "error") { message.error(`${info.file.name} 上传失败`); } diff --git a/src/pages/resource/images/index.tsx b/src/pages/resource/images/index.tsx index e74d91f..33b0ed3 100644 --- a/src/pages/resource/images/index.tsx +++ b/src/pages/resource/images/index.tsx @@ -13,7 +13,7 @@ import { resource } from "../../../api"; import styles from "./index.module.less"; import { CloseOutlined } from "@ant-design/icons"; import { UploadImageSub } from "../../../compenents/upload-image-button/upload-image-sub"; -import { TreeCategory, PerButton } from "../../../compenents"; +import { TreeCategory } from "../../../compenents"; interface CategoryItem { id: number; @@ -92,7 +92,7 @@ export const ResourceImagesPage = () => { { resetImageList(); }}