Blame view

src/views/demo/feat/full-screen/index.vue 1.69 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
  import { PageWrapper } from '/@/components/Page';
32
  import { type Nullable } from '@vben/types';
33
陈文彬 authored
34
  export default defineComponent({
35
    components: { CollapseContainer, PageWrapper },
陈文彬 authored
36
37
    setup() {
      const domRef = ref<Nullable<HTMLElement>>(null);
Vben authored
38
      const { enter, toggle, exit, isFullscreen } = useFullscreen();
陈文彬 authored
39
Vben authored
40
      const { toggle: toggleDom } = useFullscreen(domRef);
陈文彬 authored
41
      return {
Vben authored
42
        enter,
陈文彬 authored
43
        toggleDom,
Vben authored
44
45
46
        toggle,
        isFullscreen,
        exit,
陈文彬 authored
47
48
49
50
51
        domRef,
      };
    },
  });
</script>