45 lines
1.2 KiB
Vue
45 lines
1.2 KiB
Vue
<script setup>
|
|
import vueDropzone from 'dropzone-vue3'
|
|
import {useMediumStore} from "../../store/Medium.js";
|
|
|
|
const props = defineProps({
|
|
uploadEndpoint: {
|
|
type: String,
|
|
default: '/admin/medium'
|
|
}
|
|
});
|
|
|
|
const dropzoneOptions = {
|
|
url: props.uploadEndpoint,
|
|
thumbnailWidth: 150,
|
|
maxFilesize: 20,
|
|
dictDefaultMessage: `
|
|
<div class="!font-dana">
|
|
<span class="font-black text-lg">آپلود رسانه</span>
|
|
<p class="font-normal text-xs">حداکثر آپلود فایل 20 مگابایت میباشد</p>
|
|
</div>
|
|
`,
|
|
headers : { "X-CSRF-TOKEN": document.head.querySelector("[name=csrf-token]").content}
|
|
}
|
|
|
|
|
|
const MediumStore = useMediumStore();
|
|
const MediumSuccess = (response) => {
|
|
if (response.xhr.response == 'noFormat'){
|
|
alert('فرمت فایل نا معتبر است')
|
|
}
|
|
MediumStore.mediums.unshift(JSON.parse(response.xhr.response));
|
|
console.log(JSON.parse(response.xhr.response))
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<vue-dropzone
|
|
ref="myVueDropzone"
|
|
id="dropzone"
|
|
class="!border-dashed !bg-transparent overflow-y-auto max-h-[12rem]"
|
|
:options="dropzoneOptions"
|
|
v-on:vdropzone-success="MediumSuccess"
|
|
/>
|
|
</template>
|