增加了自动化视频以及修复了一些已知漏洞 (#1554)
* 解决bug:为角色添加权限时,如果有重复api权限,该角色所有权限均添加失败(包括登录) * 支持视频上传和选用。视频首帧作为封面预览。 * 增加自动化代码视频选项 * 媒体库可上传视频 SelectImage组件增加参数file-type="image|video" 方便用户对媒体库可选内容做限制 * 自动化代码bug修复 --------- Co-authored-by: liuyahui <liuyahui@wjacloud.com> Co-authored-by: Alan <alan.cd@qq.com>
This commit is contained in:
committed by
GitHub
co-authored by
liuyahui
Alan
parent
c1c37901b5
commit
809e2496c0
@@ -19,6 +19,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/pinia/modules/user'
|
||||
import { isVideoMime, isImageMime } from '@/utils/image'
|
||||
|
||||
defineOptions({
|
||||
name: 'UploadCommon',
|
||||
@@ -32,18 +33,30 @@ const fullscreenLoading = ref(false)
|
||||
|
||||
const checkFile = (file) => {
|
||||
fullscreenLoading.value = true
|
||||
const isJPG = file.type === 'image/jpeg'
|
||||
const isPng = file.type === 'image/png'
|
||||
const isLt2M = file.size / 1024 / 1024 < 0.5
|
||||
if (!isJPG && !isPng) {
|
||||
ElMessage.error('上传图片只能是 jpg或png 格式!')
|
||||
const isLt500K = file.size / 1024 / 1024 < 0.5 // 500K, @todo 应支持在项目中设置
|
||||
const isLt5M = file.size / 1024 / 1024 < 5 // 5MB, @todo 应支持项目中设置
|
||||
const isVideo = isVideoMime(file.type)
|
||||
const isImage = isImageMime(file.type)
|
||||
let pass = true
|
||||
if (!isVideo && !isImage) {
|
||||
ElMessage.error('上传图片只能是 jpg,png,svg,webp 格式, 上传视频只能是 mp4,webm 格式!')
|
||||
fullscreenLoading.value = false
|
||||
pass = false
|
||||
}
|
||||
if (!isLt2M) {
|
||||
if (!isLt5M && isVideo) {
|
||||
ElMessage.error('上传视频大小不能超过 5MB')
|
||||
fullscreenLoading.value = false
|
||||
pass = false
|
||||
}
|
||||
if (!isLt500K && isImage) {
|
||||
ElMessage.error('未压缩的上传图片大小不能超过 500KB,请使用压缩上传')
|
||||
fullscreenLoading.value = false
|
||||
pass = false
|
||||
}
|
||||
return (isPng || isJPG) && isLt2M
|
||||
|
||||
console.log('upload file check result: ', pass)
|
||||
|
||||
return pass
|
||||
}
|
||||
|
||||
const uploadSuccess = (res) => {
|
||||
|
||||
Reference in New Issue
Block a user