Skip to content

Commit ed14675

Browse files
committed
优化:视频播放组件概率性不能动态刷新问题
1 parent e6e0aa7 commit ed14675

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## v0.12.1
1+
## v0.13.0
22

3+
- 优化:视频播放组件概率性不能动态刷新问题
34
- 修复:云端模型网络异常情况下结果丢失问题
45

56
## v0.12.0 云端大模型,VIP模型,直播功能

electron-builder.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"type": "development",
9999
"notarize": false,
100100
"darkModeSupport": false,
101-
"hardenedRuntime": false,
101+
"hardenedRuntime": true,
102102
"identity": "Xi'an Yanyi Information Technology Co., Ltd (Q96H3H33RK)"
103103
},
104104
"linux": {

src/components/common/VideoPlayer.vue

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import Player from 'xgplayer';
33
import 'xgplayer/dist/index.min.css';
4-
import {onBeforeUnmount, onMounted, ref} from "vue";
4+
import {onBeforeUnmount, onMounted, ref, watch} from "vue";
55
66
const videoContainer = ref<HTMLDivElement | undefined>(undefined);
77
@@ -25,17 +25,31 @@ const props = withDefaults(defineProps<{
2525
2626
let player: Player | null = null;
2727
28+
const initPlayer = () => {
29+
if (player) {
30+
player.destroy();
31+
player = null;
32+
}
33+
if (videoContainer.value && props.url) {
34+
player = new Player({
35+
el: videoContainer.value,
36+
url: props.url,
37+
width: props.width,
38+
height: props.height,
39+
autoplay: props.autoplay,
40+
muted: props.autoplayMuted,
41+
loop: props.loop,
42+
controls: props.controls,
43+
});
44+
}
45+
}
46+
47+
watch(() => props.url, (newUrl) => {
48+
initPlayer()
49+
})
50+
2851
onMounted(() => {
29-
player = new Player({
30-
el: videoContainer.value,
31-
url: props.url,
32-
width: props.width,
33-
height: props.height,
34-
autoplay: props.autoplay,
35-
muted: props.autoplayMuted,
36-
loop: props.loop,
37-
controls: props.controls,
38-
});
52+
initPlayer();
3953
})
4054
4155
onBeforeUnmount(() => {

src/pages/Video/VideoGen.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ onBeforeUnmount(() => {
166166
</div>
167167
<div class="flex-shrink-0 ml-8">
168168
<div class="p-2 rounded shadow bg-gray-300" v-if="r.result.url">
169-
<div class="w-48 h-48" v-if="r.result.url">
169+
<div class="w-48 h-48">
170170
<VideoPlayer :url="'file://'+r.result.url"/>
171171
</div>
172172
</div>

0 commit comments

Comments
 (0)