Commit 3b22a7b0 by lijiabin

【代码优化 11018】 perf: 优化转本地blob

parent 9164531a
......@@ -292,11 +292,12 @@
width="800px"
:close-on-click-modal="false"
>
<!-- 这个用blob是因为 转为canvas 防止跨域污染 -->
<!-- 转为canvas 防止跨域污染 crossorigin="anonymous" -->
<div v-if="locationVideoBlolUrl" class="space-y-6">
<!-- 视频预览 -->
<div class="relative">
<video
crossorigin="anonymous"
ref="videoRef"
:src="locationVideoBlolUrl"
class="w-full max-h-96 rounded-lg bg-black"
......@@ -372,7 +373,7 @@ import SelectTags from '@/components/common/SelectTags/index.vue'
import type { TagItemDto, AddOrUpdateVideoDto } from '@/api'
import { useVideoStore, useUserStore } from '@/stores'
import { storeToRefs } from 'pinia'
import { selectDepOrUser, fetchOssBlob } from '@/utils'
import { selectDepOrUser } from '@/utils'
import BackButton from '@/components/common/BackButton/index.vue'
import { push } from 'notivue'
......@@ -610,19 +611,13 @@ const handleSubmit = async (releaseStatus: ReleaseStatusTypeEnum) => {
}
const handleVideoChange = ({
file,
videoDuration,
}: {
file: File
url: string
videoDuration: string
}) => {
if (locationVideoBlolUrl.value) {
URL.revokeObjectURL(locationVideoBlolUrl.value)
}
if (file) {
locationVideoBlolUrl.value = URL.createObjectURL(file)
}
locationVideoBlolUrl.value = form.value.videoUrl
form.value.videoDuration = videoDuration
}
......@@ -645,8 +640,9 @@ onDeactivated(() => {
onActivated(async () => {
if (route.query.id) {
const { data } = await getArticleDetail(route.query.id as string)
const blobUrl = await fetchOssBlob(data.videoUrl)
locationVideoBlolUrl.value = blobUrl
locationVideoBlolUrl.value = data.videoUrl
form.value = {
...form.value,
...data,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment