Blame view

src/layouts/default/header/components/FullScreen.vue 1.27 KB
vben authored
1
2
<template>
  <Tooltip :title="getTitle" placement="bottom" :mouseEnterDelay="0.5">
Vben authored
3
    <span @click="toggle">
vben authored
4
5
6
7
8
9
10
11
12
      <FullscreenOutlined v-if="!isFullscreen" />
      <FullscreenExitOutlined v-else />
    </span>
  </Tooltip>
</template>
<script lang="ts">
  import { defineComponent, computed, unref } from 'vue';
  import { Tooltip } from 'ant-design-vue';
  import { useI18n } from '/@/hooks/web/useI18n';
Vben authored
13
14
  import { useFullscreen } from '@vueuse/core';
vben authored
15
  import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons-vue';
16
vben authored
17
18
19
20
21
22
  export default defineComponent({
    name: 'FullScreen',
    components: { FullscreenExitOutlined, FullscreenOutlined, Tooltip },

    setup() {
      const { t } = useI18n();
Vben authored
23
      const { toggle, isFullscreen } = useFullscreen();
24
25
26
27
28
29
30
      // 重新检查全屏状态
      isFullscreen.value = !!(
        document.fullscreenElement ||
        document.webkitFullscreenElement ||
        document.mozFullScreenElement ||
        document.msFullscreenElement
      );
vben authored
31
32

      const getTitle = computed(() => {
Vben authored
33
        return unref(isFullscreen)
vben authored
34
35
36
37
38
39
          ? t('layout.header.tooltipExitFull')
          : t('layout.header.tooltipEntryFull');
      });

      return {
        getTitle,
Vben authored
40
41
        isFullscreen,
        toggle,
vben authored
42
43
44
45
      };
    },
  });
</script>