|
@@ -15,9 +15,9 @@
|
|
|
<div class="placeholder" @click="file.click()" v-if="!media.length">
|
|
|
<div class="icon">
|
|
|
<i class="iconfont icon-add"></i>
|
|
|
- <span>{{$t('components.uploadVideo')}}</span>
|
|
|
+ <span>{{ $t('components.uploadVideo') }}</span>
|
|
|
</div>
|
|
|
- <div class="tips">{{$t('components.limitFileSizeBit',{file:"mp4/mov",size:"20",bit:"2"})}}</div>
|
|
|
+ <div class="tips">{{ $t('components.limitFileSizeBit', { file: 'mp4/mov', size: '20', bit: '2' }) }}</div>
|
|
|
<input ref="file" type="file" style="display: none" accept=".mp4, .mov" @change="onChange" />
|
|
|
</div>
|
|
|
<div class="del-btn" v-if="notify.media?.[notify.type]?.length && isEdit" @click="delMedia">
|
|
@@ -26,7 +26,9 @@
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { ref, onMounted, inject } from 'vue'
|
|
|
-import { checkSizeLimitFree, base64ToDataURL } from '@/utils/file'
|
|
|
+import { checkSizeLimitFree, base64ToDataURL, getMime } from '@/utils/file'
|
|
|
+import i18n from '@/i18n'
|
|
|
+const { t } = i18n.global
|
|
|
const notify = inject('notify')
|
|
|
const isEdit = inject('isEdit')
|
|
|
const emits = defineEmits(['tips'])
|
|
@@ -38,7 +40,10 @@ const onChange = e => {
|
|
|
}
|
|
|
|
|
|
let file = e.target.files[0]
|
|
|
-
|
|
|
+ if (!['mp4', 'mov'].includes(getMime(file.name))) {
|
|
|
+ emits('tips', t('components.FileSizeTips', { size: '20', file: 'mp4/mov' }))
|
|
|
+ return
|
|
|
+ }
|
|
|
if (checkSizeLimitFree(file.size, 20)) {
|
|
|
let reader = new FileReader()
|
|
|
reader.onload = function () {
|
|
@@ -47,7 +52,7 @@ const onChange = e => {
|
|
|
}
|
|
|
reader.readAsDataURL(file)
|
|
|
} else {
|
|
|
- emits('tips', t('components.FileSizeTips', { size: '5', file: 'mp4/mov' }))
|
|
|
+ emits('tips', t('components.FileSizeTips', { size: '20', file: 'mp4/mov' }))
|
|
|
}
|
|
|
e.target.value = ''
|
|
|
}
|