fix bug 4
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
:action="url"
|
||||
:headers="fileHeader"
|
||||
accept="image/*"
|
||||
:before-upload="beforeUpload"
|
||||
@change="handelChange"
|
||||
>
|
||||
<div
|
||||
@@ -41,8 +42,11 @@ import { uploadURL } from '@root/config'
|
||||
import { onMounted, ref, watch, computed } from 'vue'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { UploadProps } from 'ant-design-vue'
|
||||
import { getToken } from '@/utils'
|
||||
import { fixFileCapture } from '@/utils/fixFileCapture'
|
||||
import { createWebpBeforeUpload } from '@/utils/prepareImageForUpload'
|
||||
import { normalizeUploadFileResponse, toAbsoluteFileUrl } from '@/utils/file'
|
||||
|
||||
const loading = ref<boolean>(false)
|
||||
const percent = ref<number>(0)
|
||||
@@ -68,6 +72,10 @@ const emit = defineEmits<{
|
||||
(e: 'errorUpload'): void
|
||||
}>()
|
||||
|
||||
const beforeUpload: UploadProps['beforeUpload'] = createWebpBeforeUpload((msg) =>
|
||||
message.error(msg)
|
||||
)
|
||||
|
||||
function handelChange({ file, fileList }) {
|
||||
if (Object.hasOwn(file, 'percent')) {
|
||||
percent.value = Math.floor(file.percent)
|
||||
@@ -86,7 +94,11 @@ function handelChange({ file, fileList }) {
|
||||
message.error('خطا در آپلود فایل')
|
||||
}
|
||||
if (file.status == 'done') {
|
||||
imageUrl.value = file.response.full_src
|
||||
const fileResource = normalizeUploadFileResponse(file.response)
|
||||
imageUrl.value =
|
||||
fileResource?.full_src ||
|
||||
toAbsoluteFileUrl(file.response?.full_src || file.response?.src) ||
|
||||
''
|
||||
loading.value = false
|
||||
emit('upload', file.response)
|
||||
message.success('فایل با موفقیت آپلود شد')
|
||||
|
||||
Reference in New Issue
Block a user