index.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <div class="pptist-screen">
  3. <BaseView :changeViewMode="changeViewMode" v-if="viewMode === 'base'" />
  4. <PresenterView :changeViewMode="changeViewMode" v-else-if="viewMode === 'presenter'" />
  5. </div>
  6. </template>
  7. <script lang="ts" setup>
  8. import { onMounted, onUnmounted, ref } from "vue"
  9. import { KEYS } from "@/configs/hotkey"
  10. import useScreening from "@/hooks/useScreening"
  11. import BaseView from "./BaseView.vue"
  12. import PresenterView from "./PresenterView.vue"
  13. const viewMode = ref<"base" | "presenter">("base")
  14. const changeViewMode = (mode: "base" | "presenter") => {
  15. viewMode.value = mode
  16. }
  17. const { exitScreening } = useScreening()
  18. // 快捷键退出放映
  19. const keydownListener = (e: KeyboardEvent) => {
  20. const key = e.key.toUpperCase()
  21. if (key === KEYS.ESC) exitScreening()
  22. }
  23. onMounted(() => document.addEventListener("keydown", keydownListener))
  24. onUnmounted(() => document.removeEventListener("keydown", keydownListener))
  25. </script>
  26. <style lang="scss" scoped>
  27. .pptist-screen {
  28. width: 100%;
  29. height: 100%;
  30. }
  31. </style>