Blame view

antis-ncc-admin/src/components/Screenfull/index.vue 1.44 KB
96009bc9   hexiaodong   hxd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <template>
    <el-tooltip effect="dark"
      :content="isFullscreen?$t('common.outFullScreen'):$t('common.fullScreen')" placement="top">
      <el-link
        :icon="`icon-ym ${isFullscreen?'icon-ym-compress-screen1':'icon-ym-full-screen1'} NCC-common-head-icon`"
        :underline="false" @click="click()" />
    </el-tooltip>
  </template>
  
  <script>
  import screenfull from 'screenfull'
  
  export default {
    props: {
      isContainer: {
        type: Boolean,
        default: true
      }
    },
    name: 'Screenfull',
    data() {
      return {
        refEle: '',
        isFullscreen: false
      }
    },
    mounted() {
      this.init()
9a267e98   李宇   修改全屏和移动顺序
29
30
31
      // 优先查找 .NCC-common-layout 元素,如果找不到则使用父元素
      const layoutEle = this.$el.closest('.NCC-common-layout')
      this.refEle = layoutEle || this.$options.parent.$el
96009bc9   hexiaodong   hxd
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
    },
    beforeDestroy() {
      this.destroy()
    },
    methods: {
      click() {
        if (!screenfull.enabled) {
          this.$message({
            message: '不支持全屏',
            type: 'warning'
          })
          return false
        }
        if (this.isContainer) {
          screenfull.toggle(this.refEle)
        } else {
          screenfull.toggle()
        }
      },
      change() {
        this.isFullscreen = screenfull.isFullscreen
      },
      init() {
        if (screenfull.enabled) {
          screenfull.on('change', this.change)
        }
      },
      destroy() {
        if (screenfull.enabled) {
          screenfull.off('change', this.change)
        }
      }
    }
  }
  </script>