Blame view

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

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