Blame view

HHECS.Web/src/components/Screenfull/index.vue 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<template>
  <div>
    <svg-icon :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" @click="click" />
  </div>
</template>

<script>
import screenfull from 'screenfull'
export default {
  name: 'Screenfull',
  data() {
    return {
      isFullscreen: false
    }
  },
  mounted() {
    this.init()
18
    // 默认进入全屏
胡菁 authored
19
20
21
22
23
    if (window.appConfig.isFullscreen) {
      if (screenfull.isEnabled) {
        screenfull.request()
        this.isFullscreen = true
      }
24
    }
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  },
  beforeDestroy() {
    this.destroy()
  },
  methods: {
    click() {
      if (!screenfull.isEnabled) {
        this.$message({
          message: 'you browser can not work',
          type: 'warning'
        })
        return false
      }
      screenfull.toggle()
    },
    change() {
      this.isFullscreen = screenfull.isFullscreen
    },
    init() {
胡菁 authored
44
      if (screenfull.isEnabled) {
45
46
47
48
        screenfull.on('change', this.change)
      }
    },
    destroy() {
胡菁 authored
49
      if (screenfull.isEnabled) {
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
        screenfull.off('change', this.change)
      }
    }
  }
}
</script>

  <style scoped>
  .screenfull-svg {
    display: inline-block;
    cursor: pointer;
    fill: #5a5e66;;
    width: 20px;
    height: 20px;
    vertical-align: 10px;
  }
  </style>