Blame view

src/views/demo/feat/full-screen/index.vue 1.8 KB
陈文彬 authored
1
<template>
2
  <PageWrapper title="全屏示例">
vben authored
3
    <CollapseContainer class="w-full h-32 bg-white rounded-md" title="Window Full Screen">
陈文彬 authored
4
5
6
7
8
9
10
11
12
13
14
15
16
17
      <a-button type="primary" @click="enterFullscreen" class="mr-2">
        Enter Window Full Screen
      </a-button>
      <a-button color="success" @click="toggleFullscreen" class="mr-2">
        Toggle Window Full Screen
      </a-button>

      <a-button color="error" @click="exitFullscreen" class="mr-2">
        Exit Window Full Screen
      </a-button>

      Current State: {{ isFullscreenRef }}
    </CollapseContainer>
vben authored
18
    <CollapseContainer class="w-full mt-5 bg-white rounded-md" title="Dom Full Screen">
陈文彬 authored
19
20
21
22
23
      <a-button type="primary" @click="toggleDom" class="mr-2"> Enter Dom Full Screen </a-button>
    </CollapseContainer>

    <div
      ref="domRef"
vben authored
24
      class="flex items-center justify-center w-1/2 h-64 mx-auto mt-10 bg-white rounded-md"
陈文彬 authored
25
26
27
    >
      <a-button type="primary" @click="toggleDom" class="mr-2"> Exit Dom Full Screen </a-button>
    </div>
28
  </PageWrapper>
陈文彬 authored
29
30
31
32
33
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { CollapseContainer } from '/@/components/Container/index';
  import { useFullscreen } from '/@/hooks/web/useFullScreen';
34
35
  import { PageWrapper } from '/@/components/Page';
陈文彬 authored
36
  export default defineComponent({
37
    components: { CollapseContainer, PageWrapper },
陈文彬 authored
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    setup() {
      const domRef = ref<Nullable<HTMLElement>>(null);
      const {
        enterFullscreen,
        toggleFullscreen,
        isFullscreenRef,
        exitFullscreen,
      } = useFullscreen();

      const { toggleFullscreen: toggleDom } = useFullscreen(domRef);
      return {
        enterFullscreen,
        toggleDom,
        toggleFullscreen,
        isFullscreenRef,
        exitFullscreen,
        domRef,
      };
    },
  });
</script>