diff --git a/apps/admin-panel/src/components/upload/GalleryUploadInput.vue b/apps/admin-panel/src/components/upload/GalleryUploadInput.vue
index 5fb5d8a..931bea1 100644
--- a/apps/admin-panel/src/components/upload/GalleryUploadInput.vue
+++ b/apps/admin-panel/src/components/upload/GalleryUploadInput.vue
@@ -29,7 +29,7 @@
class="tile"
:class="{ 'is-uploading': item.status === 'uploading' }"
>
-
+
@@ -64,6 +64,8 @@ import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { message, Upload } from 'ant-design-vue';
import { CloudUploadOutlined, DeleteOutlined, EyeOutlined, LoadingOutlined } from '@ant-design/icons-vue';
import api from '../../api/client';
+import { imageUrl } from '../../utils/image';
+import { checkImageFile, uploadErrorMessage } from '../../utils/upload';
const props = withDefaults(
defineProps<{
@@ -116,8 +118,9 @@ watch(
);
function beforeUpload(file: File) {
- if (!file.type.startsWith('image/')) {
- message.error(`«${file.name}» تصویر نیست`);
+ const problem = checkImageFile(file);
+ if (problem) {
+ message.error(problem);
return Upload.LIST_IGNORE;
}
return true;
@@ -171,10 +174,7 @@ function doUpload({ file }: { file: File & { uid?: string } }) {
sync();
})
.catch((e) => {
- const msg =
- (e as { response?: { data?: { message?: string } } })?.response?.data?.message ??
- `بارگذاری «${file.name}» ناموفق بود`;
- message.error(msg);
+ message.error(uploadErrorMessage(e, file.name));
dropItem(uid);
});
}
diff --git a/apps/admin-panel/src/components/upload/ImageUploadInput.vue b/apps/admin-panel/src/components/upload/ImageUploadInput.vue
index 76f4a3c..a4d5f0f 100644
--- a/apps/admin-panel/src/components/upload/ImageUploadInput.vue
+++ b/apps/admin-panel/src/components/upload/ImageUploadInput.vue
@@ -17,6 +17,7 @@
:max-count="1"
accept="image/*"
:custom-request="doUpload"
+ :before-upload="beforeUpload"
@remove="handleRemove"
@preview="handlePreview"
>
@@ -37,9 +38,11 @@