fixed: 图片上传错误提示

This commit is contained in:
none 2023-03-08 19:13:54 +08:00
parent 28f38db147
commit 98a20a5c0b
3 changed files with 12 additions and 11 deletions

View File

@ -175,7 +175,7 @@ export const UploadImageButton = (props: PropsInterface) => {
<Row>
<Col span={24}>
<UploadImageSub
categoryId={defaultCid}
categoryIds={[]}
onUpdate={() => {
resetImageList();
}}

View File

@ -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") {
if (response.code == 0) {
message.success(`${info.file.name} 上传成功`);
} else {
message.error(response.msg);
}
} else if (status === "error") {
message.error(`${info.file.name} 上传失败`);
}

View File

@ -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 = () => {
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={24}>
<UploadImageSub
categoryId={Number(category_ids.join(","))}
categoryIds={category_ids}
onUpdate={() => {
resetImageList();
}}