|
@@ -0,0 +1,92 @@
|
|
|
+<!-- eslint-disable vue/no-v-html -->
|
|
|
+<template>
|
|
|
+ <div class="imageText-preview" :style="getAreaStyle()">
|
|
|
+ <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
|
|
|
+ <div ref="fullscreenElement">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :class="[full_type ? 'exit-btn' : '']"
|
|
|
+ @click="toggleFullScreen"
|
|
|
+ style="margin-bottom: 10px"
|
|
|
+ >{{ full_type ? '退出全屏' : '进入全屏' }}</el-button
|
|
|
+ >
|
|
|
+ <iframe :src="games_url" width="100%" :height="full_type ? '100%' : '580px'" style="border: none"></iframe>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import PreviewMixin from '../common/PreviewMixin';
|
|
|
+import { getH5GamesData } from '@/views/book/courseware/data/h5Games';
|
|
|
+import { H5StartupFile } from '@/api/app';
|
|
|
+export default {
|
|
|
+ name: 'H5GamesPreview',
|
|
|
+
|
|
|
+ components: {},
|
|
|
+ mixins: [PreviewMixin],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ data: getH5GamesData(),
|
|
|
+ games_url: '',
|
|
|
+ full_type: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.initData();
|
|
|
+ },
|
|
|
+ mounted() {},
|
|
|
+ methods: {
|
|
|
+ initData() {
|
|
|
+ this.games_url =
|
|
|
+ 'https://file-kf.helxsoft.cn/CSFileStore/003/00301/D-TVLONKXT3IRWYEMCJK/F-702XHW9VPAU8QVS8NF/index.html';
|
|
|
+ this.data.games_list.forEach((item) => {
|
|
|
+ H5StartupFile({ file_id: item.file_id, index_file_name: 'index.html' }).then((res) => {
|
|
|
+ this.games_url = res.file_url;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ toggleFullScreen() {
|
|
|
+ const elem = this.$refs.fullscreenElement; // 获取需要全屏的元素
|
|
|
+ if (!document.fullscreenElement) {
|
|
|
+ this.full_type = true;
|
|
|
+ if (elem.requestFullscreen) {
|
|
|
+ elem.requestFullscreen(); // 现代浏览器,如Chrome, Firefox, Opera, Safari等
|
|
|
+ } else if (elem.mozRequestFullScreen) {
|
|
|
+ // Firefox
|
|
|
+ elem.mozRequestFullScreen();
|
|
|
+ } else if (elem.webkitRequestFullscreen) {
|
|
|
+ // Chrome, Safari等
|
|
|
+ elem.webkitRequestFullscreen();
|
|
|
+ } else if (elem.msRequestFullscreen) {
|
|
|
+ // IE/Edge
|
|
|
+ elem.msRequestFullscreen();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.full_type = false;
|
|
|
+ if (document.exitFullscreen) {
|
|
|
+ document.exitFullscreen(); // 退出全屏模式
|
|
|
+ } else if (document.mozCancelFullScreen) {
|
|
|
+ // Firefox
|
|
|
+ document.mozCancelFullScreen();
|
|
|
+ } else if (document.webkitExitFullscreen) {
|
|
|
+ // Chrome, Safari等
|
|
|
+ document.webkitExitFullscreen();
|
|
|
+ } else if (document.msExitFullscreen) {
|
|
|
+ // IE/Edge
|
|
|
+ document.msExitFullscreen();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@use '@/styles/mixin.scss' as *;
|
|
|
+
|
|
|
+.exit-btn {
|
|
|
+ position: fixed;
|
|
|
+ top: 10px;
|
|
|
+ left: 10px;
|
|
|
+}
|
|
|
+</style>
|