fix:限制上传内容大小
All checks were successful
Build and Push Docker Image / build (push) Successful in 3m46s
All checks were successful
Build and Push Docker Image / build (push) Successful in 3m46s
This commit is contained in:
parent
b98300d927
commit
70dda373a1
@ -15,8 +15,8 @@ export default defineConfig({
|
||||
proxy: {
|
||||
'/api/': {
|
||||
// target: 'http://yt:8003',
|
||||
target: 'http://10.39.13.78:8001/',
|
||||
// target: 'https://test-admin.linyikj.com.cn/',
|
||||
// target: 'http://10.39.13.78:8001/',
|
||||
target: 'https://test-admin.linyikj.com.cn/',
|
||||
// target: 'https://admin.linyikj.com.cn/',
|
||||
// target: 'http://c789629c.natappfree.cc',
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { MyProFormFieldProps } from '@/common';
|
||||
import { Apis } from '@/gen/Apis';
|
||||
import { PlusOutlined, UploadOutlined } from '@ant-design/icons';
|
||||
import { Button, Modal, Upload, UploadFile, UploadProps } from 'antd';
|
||||
import { Button, message, Modal, Upload, UploadFile, UploadProps } from 'antd';
|
||||
import { RcFile } from 'antd/es/upload';
|
||||
import axios from 'axios';
|
||||
import { useSetState } from 'react-use';
|
||||
@ -10,6 +10,7 @@ import './MyUploadImages.scss';
|
||||
type MyType = {
|
||||
uploadType?: 'image' | 'video' | 'audio' | 'file';
|
||||
max?: number;
|
||||
size?: number;
|
||||
} & UploadProps<any> &
|
||||
MyProFormFieldProps<UploadFile[]>;
|
||||
|
||||
@ -26,6 +27,7 @@ export function MyUploadImages({
|
||||
onChange,
|
||||
uploadType = 'image',
|
||||
max = 1,
|
||||
size = 10,
|
||||
...rest
|
||||
}: MyType) {
|
||||
const [preview, setPreview] = useSetState<{
|
||||
@ -129,10 +131,25 @@ export function MyUploadImages({
|
||||
};
|
||||
};
|
||||
|
||||
const handleBeforeUpload = (file: any, fileList: any) => {
|
||||
if (file?.size > 1024 * 1024 * size) {
|
||||
message.error('文件大小不能超过10MB,请选择重新上传!');
|
||||
return false;
|
||||
}
|
||||
console.log('beforeUpload', file, fileList);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Upload
|
||||
accept={uploadType === 'image' ? 'image/*' : '*'}
|
||||
accept={
|
||||
uploadType === 'image'
|
||||
? 'image/*'
|
||||
: uploadType === 'video'
|
||||
? 'video/*'
|
||||
: '*'
|
||||
}
|
||||
beforeUpload={handleBeforeUpload}
|
||||
fileList={value}
|
||||
listType={uploadType === 'image' ? 'picture-card' : 'text'}
|
||||
onPreview={handlePreview}
|
||||
|
||||
@ -187,7 +187,7 @@ export default function Create(props: MyBetaModalFormProps) {
|
||||
title: '上传图片',
|
||||
// uploadType: 'file',
|
||||
required: true,
|
||||
tooltip: '限9张图片',
|
||||
tooltip: '限9张图片10M以内',
|
||||
max: 9,
|
||||
colProps: { span: 24 },
|
||||
}),
|
||||
@ -205,8 +205,8 @@ export default function Create(props: MyBetaModalFormProps) {
|
||||
key: 'attachments',
|
||||
title: '上传视频',
|
||||
required: true,
|
||||
tooltip: '限1个视频',
|
||||
// uploadType: 'file',
|
||||
tooltip: '限1个视频10M以内,格式要求:mp4',
|
||||
uploadType: 'video',
|
||||
max: 1,
|
||||
colProps: { span: 24 },
|
||||
}),
|
||||
@ -260,7 +260,7 @@ export default function Create(props: MyBetaModalFormProps) {
|
||||
},
|
||||
MyFormItems.UploadImages({
|
||||
key: 'cover_image',
|
||||
tooltip: '限1张图片',
|
||||
tooltip: '限1张图片10M以内',
|
||||
title: '设置封面',
|
||||
required: true,
|
||||
max: 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user