File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed
Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { UploadProps , UploadUserFile } from ' element-plus'
3- import { ElMessage } from ' element-plus '
3+ import { toast } from ' vue-sonner '
44
55defineOptions ({
66 name: ' FileUpload' ,
@@ -47,16 +47,16 @@ const beforeUpload: UploadProps['beforeUpload'] = (file) => {
4747 const isTypeOk = props .ext .includes (fileExt )
4848 const isSizeOk = file .size / 1024 / 1024 < props .size
4949 if (! isTypeOk ) {
50- ElMessage .error (` 上传文件只支持 ${props .ext .join (' / ' )} 格式! ` )
50+ toast .error (` 上传文件只支持 ${props .ext .join (' / ' )} 格式! ` )
5151 }
5252 if (! isSizeOk ) {
53- ElMessage .error (` 上传文件大小不能超过 ${props .size }MB! ` )
53+ toast .error (` 上传文件大小不能超过 ${props .size }MB! ` )
5454 }
5555 return isTypeOk && isSizeOk
5656}
5757
5858const onExceed: UploadProps [' onExceed' ] = () => {
59- ElMessage .warning (' 文件上传超过限制' )
59+ toast .warning (' 文件上传超过限制' )
6060}
6161
6262const onSuccess: UploadProps [' onSuccess' ] = (res , file , fileList ) => {
Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { UploadProps } from ' element-plus'
3- import { ElMessage } from ' element-plus '
3+ import { toast } from ' vue-sonner '
44
55defineOptions ({
66 name: ' ImageUpload' ,
@@ -67,10 +67,10 @@ const beforeUpload: UploadProps['beforeUpload'] = (file) => {
6767 const isTypeOk = props .ext .includes (fileExt )
6868 const isSizeOk = file .size / 1024 / 1024 < props .size
6969 if (! isTypeOk ) {
70- ElMessage .error (` 上传图片只支持 ${props .ext .join (' / ' )} 格式! ` )
70+ toast .error (` 上传图片只支持 ${props .ext .join (' / ' )} 格式! ` )
7171 }
7272 if (! isSizeOk ) {
73- ElMessage .error (` 上传图片大小不能超过 ${props .size }MB! ` )
73+ toast .error (` 上传图片大小不能超过 ${props .size }MB! ` )
7474 }
7575 if (isTypeOk && isSizeOk ) {
7676 uploadData .value .progress .preview = URL .createObjectURL (file )
Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { UploadProps } from ' element-plus'
3- import { ElMessage } from ' element-plus '
3+ import { toast } from ' vue-sonner '
44
55defineOptions ({
66 name: ' ImagesUpload' ,
@@ -81,10 +81,10 @@ const beforeUpload: UploadProps['beforeUpload'] = (file) => {
8181 const isTypeOk = props .ext .includes (fileExt )
8282 const isSizeOk = file .size / 1024 / 1024 < props .size
8383 if (! isTypeOk ) {
84- ElMessage .error (` 上传图片只支持 ${props .ext .join (' / ' )} 格式! ` )
84+ toast .error (` 上传图片只支持 ${props .ext .join (' / ' )} 格式! ` )
8585 }
8686 if (! isSizeOk ) {
87- ElMessage .error (` 上传图片大小不能超过 ${props .size }MB! ` )
87+ toast .error (` 上传图片大小不能超过 ${props .size }MB! ` )
8888 }
8989 if (isTypeOk && isSizeOk ) {
9090 uploadData .value .progress .preview = URL .createObjectURL (file )
You can’t perform that action at this time.
0 commit comments