Blame view

src/views/demo/feat/full-screen/index.vue 1.6 KB
陈文彬 authored
1
<template>
2
  <PageWrapper title="全屏示例">
vben authored
3
    <CollapseContainer class="w-full h-32 bg-white rounded-md" title="Window Full Screen">
Vben authored
4
5
      <a-button type="primary" @click="enter" class="mr-2"> Enter Window Full Screen </a-button>
      <a-button color="success" @click="toggle" class="mr-2"> Toggle Window Full Screen </a-button>
陈文彬 authored
6
Vben authored
7
      <a-button color="error" @click="exit" class="mr-2"> Exit Window Full Screen </a-button>
陈文彬 authored
8
Vben authored
9
      Current State: {{ isFullscreen }}
陈文彬 authored
10
11
    </CollapseContainer>
vben authored
12
    <CollapseContainer class="w-full mt-5 bg-white rounded-md" title="Dom Full Screen">
陈文彬 authored
13
14
15
16
17
      <a-button type="primary" @click="toggleDom" class="mr-2"> Enter Dom Full Screen </a-button>
    </CollapseContainer>

    <div
      ref="domRef"
vben authored
18
      class="flex items-center justify-center w-1/2 h-64 mx-auto mt-10 bg-white rounded-md"
陈文彬 authored
19
20
21
    >
      <a-button type="primary" @click="toggleDom" class="mr-2"> Exit Dom Full Screen </a-button>
    </div>
22
  </PageWrapper>
陈文彬 authored
23
24
25
26
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { CollapseContainer } from '/@/components/Container/index';
Vben authored
27
28
  import { useFullscreen } from '@vueuse/core';
29
30
  import { PageWrapper } from '/@/components/Page';
陈文彬 authored
31
  export default defineComponent({
32
    components: { CollapseContainer, PageWrapper },
陈文彬 authored
33
34
    setup() {
      const domRef = ref<Nullable<HTMLElement>>(null);
Vben authored
35
      const { enter, toggle, exit, isFullscreen } = useFullscreen();
陈文彬 authored
36
Vben authored
37
      const { toggle: toggleDom } = useFullscreen(domRef);
陈文彬 authored
38
      return {
Vben authored
39
        enter,
陈文彬 authored
40
        toggleDom,
Vben authored
41
42
43
        toggle,
        isFullscreen,
        exit,
陈文彬 authored
44
45
46
47
48
        domRef,
      };
    },
  });
</script>