@adminforth/upload 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom/uploader.vue +11 -2
- package/dist/custom/uploader.vue +11 -2
- package/dist/index.js +0 -1
- package/index.ts +0 -1
- package/package.json +1 -1
package/custom/uploader.vue
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<IconMagic class="w-5 h-5"/>
|
|
12
12
|
</button>
|
|
13
13
|
|
|
14
|
-
<label for="
|
|
14
|
+
<label :for="inputId"
|
|
15
15
|
class="flex flex-col px-3 items-center justify-center w-full h-64 border-2 border-dashed rounded-lg cursor-pointer dark:hover:bg-gray-800 hover:bg-gray-100 dark:hover:border-gray-500 dark:hover:bg-gray-600"
|
|
16
16
|
@dragover.prevent="() => dragging = true"
|
|
17
17
|
@dragleave.prevent="() => dragging = false"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
62
|
-
<input id="
|
|
62
|
+
<input :id="inputId" type="file" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
63
63
|
</label>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
@@ -70,6 +70,7 @@ import { computed, ref, onMounted, watch } from 'vue'
|
|
|
70
70
|
import { callAdminForthApi } from '@/utils'
|
|
71
71
|
import { IconMagic } from '@iconify-prerendered/vue-mdi';
|
|
72
72
|
|
|
73
|
+
const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
|
|
73
74
|
|
|
74
75
|
import ImageGenerator from '@@/plugins/UploadPlugin/imageGenerator.vue';
|
|
75
76
|
|
|
@@ -85,6 +86,8 @@ const emit = defineEmits([
|
|
|
85
86
|
'update:emptiness',
|
|
86
87
|
]);
|
|
87
88
|
|
|
89
|
+
const uploadInputRef = ref(null);
|
|
90
|
+
|
|
88
91
|
const showImageGen = ref(false);
|
|
89
92
|
const dragging = ref(false);
|
|
90
93
|
|
|
@@ -136,6 +139,7 @@ function clear() {
|
|
|
136
139
|
progress.value = 0;
|
|
137
140
|
uploaded.value = false;
|
|
138
141
|
uploadedSize.value = 0;
|
|
142
|
+
uploadInputRef.value.value = null;
|
|
139
143
|
emit('update:value', null);
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -154,6 +158,11 @@ function humanifySize(size) {
|
|
|
154
158
|
|
|
155
159
|
|
|
156
160
|
const onFileChange = async (e) => {
|
|
161
|
+
// if empty then return
|
|
162
|
+
if (!e.target.files || e.target.files.length === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
157
166
|
imgPreview.value = null;
|
|
158
167
|
progress.value = 0;
|
|
159
168
|
uploaded.value = false;
|
package/dist/custom/uploader.vue
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<IconMagic class="w-5 h-5"/>
|
|
12
12
|
</button>
|
|
13
13
|
|
|
14
|
-
<label for="
|
|
14
|
+
<label :for="inputId"
|
|
15
15
|
class="flex flex-col px-3 items-center justify-center w-full h-64 border-2 border-dashed rounded-lg cursor-pointer dark:hover:bg-gray-800 hover:bg-gray-100 dark:hover:border-gray-500 dark:hover:bg-gray-600"
|
|
16
16
|
@dragover.prevent="() => dragging = true"
|
|
17
17
|
@dragleave.prevent="() => dragging = false"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
62
|
-
<input id="
|
|
62
|
+
<input :id="inputId" type="file" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
63
63
|
</label>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
@@ -70,6 +70,7 @@ import { computed, ref, onMounted, watch } from 'vue'
|
|
|
70
70
|
import { callAdminForthApi } from '@/utils'
|
|
71
71
|
import { IconMagic } from '@iconify-prerendered/vue-mdi';
|
|
72
72
|
|
|
73
|
+
const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
|
|
73
74
|
|
|
74
75
|
import ImageGenerator from '@@/plugins/UploadPlugin/imageGenerator.vue';
|
|
75
76
|
|
|
@@ -85,6 +86,8 @@ const emit = defineEmits([
|
|
|
85
86
|
'update:emptiness',
|
|
86
87
|
]);
|
|
87
88
|
|
|
89
|
+
const uploadInputRef = ref(null);
|
|
90
|
+
|
|
88
91
|
const showImageGen = ref(false);
|
|
89
92
|
const dragging = ref(false);
|
|
90
93
|
|
|
@@ -136,6 +139,7 @@ function clear() {
|
|
|
136
139
|
progress.value = 0;
|
|
137
140
|
uploaded.value = false;
|
|
138
141
|
uploadedSize.value = 0;
|
|
142
|
+
uploadInputRef.value.value = null;
|
|
139
143
|
emit('update:value', null);
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -154,6 +158,11 @@ function humanifySize(size) {
|
|
|
154
158
|
|
|
155
159
|
|
|
156
160
|
const onFileChange = async (e) => {
|
|
161
|
+
// if empty then return
|
|
162
|
+
if (!e.target.files || e.target.files.length === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
157
166
|
imgPreview.value = null;
|
|
158
167
|
progress.value = 0;
|
|
159
168
|
uploaded.value = false;
|
package/dist/index.js
CHANGED
|
@@ -371,7 +371,6 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
371
371
|
let previewUrl;
|
|
372
372
|
if ((_b = this.options.preview) === null || _b === void 0 ? void 0 : _b.previewUrl) {
|
|
373
373
|
previewUrl = this.options.preview.previewUrl({ s3Path });
|
|
374
|
-
return;
|
|
375
374
|
}
|
|
376
375
|
else if (this.options.s3ACL === 'public-read') {
|
|
377
376
|
previewUrl = `https://${this.options.s3Bucket}.s3.${this.options.s3Region}.amazonaws.com/${s3Path}`;
|
package/index.ts
CHANGED
|
@@ -413,7 +413,6 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
413
413
|
let previewUrl;
|
|
414
414
|
if (this.options.preview?.previewUrl) {
|
|
415
415
|
previewUrl = this.options.preview.previewUrl({ s3Path });
|
|
416
|
-
return;
|
|
417
416
|
} else if (this.options.s3ACL === 'public-read') {
|
|
418
417
|
previewUrl = `https://${this.options.s3Bucket}.s3.${this.options.s3Region}.amazonaws.com/${s3Path}`;
|
|
419
418
|
} else {
|