huanghongfeng
3 天以前 5ffc36a1db18d3112a9b50a9cf3953d7fcf21bae
ÏîÄ¿´úÂë/DP/src/views/home.vue
@@ -1,12 +1,4 @@
<!--
 * @Author: daidai
 * @Date: 2022-01-12 14:23:32
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-09-09 14:47:24
 * @FilePath: \web-pc\src\pages\big-screen\view\home.vue
-->
<template>
  <!-- <div id="index" ref="appRef" class="index_home" :class="{ pageisScale: isScale }"> -->
  <ScaleScreen
    :width="1920"
    :height="1080"
@@ -14,6 +6,11 @@
    :selfAdaption="$store.state.setting.isScale"
  >
    <div class="bg">
      <!-- å…¨å±é®ç½©å±‚ -->
      <div v-if="showMask" class="fullscreen-mask" @click="enterFullscreen">
        <button class="fullscreen-button">点击全屏显示</button>
      </div>
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <!-- å¤´éƒ¨ s -->
@@ -43,7 +40,6 @@
    </div>
    <Setting ref="setting" />
  </ScaleScreen>
  <!-- </div> -->
</template>
<script>
@@ -60,6 +56,7 @@
      dateYear: null,
      dateWeek: null,
      weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      showMask: true // æŽ§åˆ¶é®ç½©å±‚显示
    };
  },
  filters: {
@@ -72,9 +69,13 @@
  mounted() {
    this.timeFn();
    this.cancelLoading();
    // ç›‘听全屏变化
    document.addEventListener('fullscreenchange', this.handleFullscreenChange);
  },
  beforeDestroy() {
    clearInterval(this.timing);
    document.removeEventListener('fullscreenchange', this.handleFullscreenChange);
  },
  methods: {
    showSetting() {
@@ -90,13 +91,57 @@
    cancelLoading() {
      let timer = setTimeout(() => {
        this.loading = false;
        clearTimeout(timer);
      }, 500);
      }, 100);
    },
    // è¿›å…¥å…¨å±
    enterFullscreen() {
      const element = document.documentElement;
      if (element.requestFullscreen) {
        element.requestFullscreen();
      } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
      } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
      }
    },
    // å¤„理全屏变化
    handleFullscreenChange() {
      this.showMask = !document.fullscreenElement;
    }
  },
};
</script>
<style lang="scss">
@import "./home.scss";
</style>
.fullscreen-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  cursor: pointer;
}
.fullscreen-button {
  padding: 15px 30px;
  font-size: 18px;
  background-color: #1a5cd7;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  &:hover {
    background-color: #0d4bc2;
    transform: scale(1.05);
  }
}
</style>