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> <Row>
<Col span={24}> <Col span={24}>
<UploadImageSub <UploadImageSub
categoryId={defaultCid} categoryIds={[]}
onUpdate={() => { onUpdate={() => {
resetImageList(); resetImageList();
}} }}

View File

@ -6,7 +6,7 @@ import { getToken } from "../../../utils";
import { InboxOutlined } from "@ant-design/icons"; import { InboxOutlined } from "@ant-design/icons";
interface PropsInterface { interface PropsInterface {
categoryId: number; categoryIds: number[];
onUpdate: () => void; onUpdate: () => void;
} }
@ -18,18 +18,19 @@ export const UploadImageSub = (props: PropsInterface) => {
multiple: true, multiple: true,
action: action:
config.app_url + config.app_url +
"/backend/v1/upload/file?category_id=" + "/backend/v1/upload/file?category_ids=" +
props.categoryId, props.categoryIds.join(","),
headers: { headers: {
authorization: "Bearer " + getToken(), authorization: "Bearer " + getToken(),
}, },
onChange(info: any) { onChange(info: any) {
const { status } = info.file; const { status, response } = info.file;
if (status !== "uploading") {
console.log(info.file, info.fileList);
}
if (status === "done") { 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") { } else if (status === "error") {
message.error(`${info.file.name} 上传失败`); message.error(`${info.file.name} 上传失败`);
} }

View File

@ -13,7 +13,7 @@ import { resource } from "../../../api";
import styles from "./index.module.less"; import styles from "./index.module.less";
import { CloseOutlined } from "@ant-design/icons"; import { CloseOutlined } from "@ant-design/icons";
import { UploadImageSub } from "../../../compenents/upload-image-button/upload-image-sub"; import { UploadImageSub } from "../../../compenents/upload-image-button/upload-image-sub";
import { TreeCategory, PerButton } from "../../../compenents"; import { TreeCategory } from "../../../compenents";
interface CategoryItem { interface CategoryItem {
id: number; id: number;
@ -92,7 +92,7 @@ export const ResourceImagesPage = () => {
<Row gutter={16} style={{ marginBottom: 24 }}> <Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={24}> <Col span={24}>
<UploadImageSub <UploadImageSub
categoryId={Number(category_ids.join(","))} categoryIds={category_ids}
onUpdate={() => { onUpdate={() => {
resetImageList(); resetImageList();
}} }}