feat(upload): 封面上传支持横版与前端压缩
- 新增 imageCompress 与 imagePresets,上传前按规格高质量等比压缩 - 短剧封面拆分为竖版/横版两个上传位,带建议尺寸提示 - 轮播图、创作者中心封面与分集封面接入压缩与提示
This commit is contained in:
1 parent
dea414739e
commit
923b7dce1e
9 files changed
+486
-87
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
import { pageDramasApi } from '@/api/admin/drama'
|
||||
import { useRbac } from '@/stores/rbac'
|
||||
import { uploadFile } from '@/utils/uploader'
|
||||
import { BANNER_IMAGE, compressForPreset } from '@/views/contentManagement/upload/imagePresets'
|
||||
import PageHeading from '@/views/components/PageHeading.vue'
|
||||
|
||||
const { can } = useRbac()
|
||||
@@ -218,12 +219,13 @@ async function uploadImage(options) {
|
||||
imagePercent.value = 0
|
||||
imageError.value = ''
|
||||
try {
|
||||
const asset = await uploadFile(options.file, {
|
||||
const file = await compressForPreset(options.file, BANNER_IMAGE)
|
||||
const asset = await uploadFile(file, {
|
||||
bizType: 'BANNER',
|
||||
onProgress: (percent) => (imagePercent.value = percent)
|
||||
})
|
||||
form.imageUrl = asset.url
|
||||
imageFileName.value = options.file.name
|
||||
imageFileName.value = file.name
|
||||
await resetValidation()
|
||||
ElMessage.success('图片已上传')
|
||||
} catch {
|
||||
@@ -467,7 +469,9 @@ onMounted(async () => {
|
||||
{{ imageDisplayName }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="banner-image-hint">支持 JPG、PNG、WebP,单张不超过 5MB。</p>
|
||||
<p class="banner-image-hint"
|
||||
>{{ BANNER_IMAGE.hint }};支持 JPG、PNG、WebP,单张不超过 5MB。</p
|
||||
>
|
||||
<el-alert
|
||||
v-if="imageError"
|
||||
:title="imageError"
|
||||
|
||||
Reference in new issue
Block a user