热力上图功能BUG处理

This commit is contained in:
renhao 2025-08-01 22:52:47 +08:00
parent e11e6999a9
commit 8fa3101fbd
2 changed files with 211 additions and 0 deletions

View File

@ -0,0 +1,98 @@
<template>
<el-dialog
class="dialog"
v-model="dialogVisible"
:title="videoTitle"
:width="width"
:before-close="handleClose"
>
<div ref="domRef" class="video"></div>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose"> </el-button>
</span>
</template>
</el-dialog>
</template>
<script setup name="VideoPlay">
import VideoPlayer from "xgplayer";
import "xgplayer/dist/index.min.css";
import {computed, nextTick, onMounted, onUnmounted, ref, watch} from "vue";
const props = defineProps({
visible: {
required: true,
type: Boolean,
default: false,
},
videoTitle: {
type: String,
default: "视频播放",
},
url: {
required: true,
type: String,
default: "",
},
width: {
type: String,
default: "600px",
},
});
const emit = defineEmits(["update:visible"]);
// dom ref
const domRef = ref();
const player = ref();
// computed
const dialogVisible = computed(() => props.visible);
//
function renderXgPlayer() {
if (!domRef.value) return;
const url = props.url;
player.value = new VideoPlayer({
el: domRef.value,
url,
playbackRate: [0.5, 0.75, 1, 1.5, 2],
//
autoplay: true,
muted: true,
autoplayMuted: true,
});
}
//
function destroyXgPlayer() {
player.value?.destroy();
}
//
function handleClose() {
emit("update:visible", false);
}
//
watch(
() => dialogVisible.value,
(val) => {
if (val) {
nextTick(() => {
renderXgPlayer();
});
} else {
destroyXgPlayer();
}
}
);
</script>
<style lang="scss" scoped>
.dialog {
box-sizing: border-box;
.video {
width: 100% !important;
}
}
</style>

View File

@ -0,0 +1,113 @@
<template>
<!-- <el-dialog
class="dialog"
v-model="dialogVisible"
:title="videoTitle"
:width="width"
:before-close="handleClose"
> -->
<div ref="domRef" class="video" v-if="dialogVisible"></div>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="handleClose"> </el-button>
</span>
</template>
</el-dialog> -->
</template>
<script setup name="VideoPlay">
import VideoPlayer from "xgplayer";
import "xgplayer/dist/index.min.css";
import {computed, nextTick, onMounted, onUnmounted, ref, watch} from "vue";
const props = defineProps({
visible: {
required: true,
type: Boolean,
default: false,
},
videoTitle: {
type: String,
default: "视频播放",
},
url: {
required: true,
type: String,
},
width: {
type: String,
default: "600px",
},
autoplay: {
type: Boolean,
default: true,
},
loop: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(["update:visible"]);
// dom ref
const domRef = ref();
const player = ref();
// computed
const dialogVisible = computed(() => props.visible);
//
function renderXgPlayer() {
if (!domRef.value) return;
const url = props.url;
player.value = new VideoPlayer({
el: domRef.value,
url,
playbackRate: [0.5, 0.75, 1, 1.5, 2],
//
loop:props.loop,
autoplay: props.autoplay,
muted: props.autoplay,
autoplayMuted: props.autoplay,
});
}
//
function destroyXgPlayer() {
player.value?.destroy();
}
//
function handleClose() {
emit("update:visible", false);
}
//
watch(
() => dialogVisible.value,
(val) => {
if (val) {
nextTick(() => {
renderXgPlayer();
});
} else {
destroyXgPlayer();
}
}
);
onMounted(() => {
renderXgPlayer();
});
</script>
<style lang="scss" scoped>
.video {
width: 100% !important;
height: 100% !important;
&:deep(.xgplayer-start) {
width: 50px;
height: 50px;
}
}
</style>