Commit 3b22a7b0 by lijiabin

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

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