index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="editor-header">
  3. <div class="left">
  4. <Popover trigger="click" placement="bottom-start" v-model:value="mainMenuVisible">
  5. <template #content>
  6. <FileInput
  7. accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"
  8. @change="
  9. files => {
  10. importPPTXFile(files)
  11. mainMenuVisible = false
  12. }
  13. "
  14. >
  15. <PopoverMenuItem>导入pptx</PopoverMenuItem>
  16. </FileInput>
  17. <PopoverMenuItem @click="setDialogForExport('pptx')">导出pptx</PopoverMenuItem>
  18. <PopoverMenuItem
  19. @click="
  20. () => {
  21. resetSlides()
  22. mainMenuVisible = false
  23. }
  24. "
  25. >重置幻灯片</PopoverMenuItem
  26. >
  27. <PopoverMenuItem
  28. @click="
  29. () => {
  30. mainMenuVisible = false
  31. hotkeyDrawerVisible = true
  32. }
  33. "
  34. >快捷操作</PopoverMenuItem
  35. >
  36. </template>
  37. <div class="menuCon" :class="{ menuVisible: mainMenuVisible }">
  38. <img class="icon" src="./imgs/file.png" />
  39. </div>
  40. </Popover>
  41. <div class="line"></div>
  42. <div class="title">
  43. <div class="title-text">{{ title }}</div>
  44. </div>
  45. </div>
  46. <div class="right">
  47. <div class="cancelBtn">取消</div>
  48. <div class="saveBtn">保存课件</div>
  49. </div>
  50. <Drawer :width="320" v-model:visible="hotkeyDrawerVisible" placement="right">
  51. <HotkeyDoc />
  52. <template v-slot:title>快捷操作</template>
  53. </Drawer>
  54. <FullscreenSpin :loading="exporting" tip="正在导入..." />
  55. </div>
  56. </template>
  57. <script lang="ts" setup>
  58. import { storeToRefs } from "pinia"
  59. import { useMainStore, useSlidesStore } from "@/store"
  60. import useImport from "@/hooks/useImport"
  61. import useSlideHandler from "@/hooks/useSlideHandler"
  62. import type { DialogForExportTypes } from "@/types/export"
  63. import HotkeyDoc from "./HotkeyDoc.vue"
  64. import FileInput from "@/components/FileInput.vue"
  65. import FullscreenSpin from "@/components/FullscreenSpin.vue"
  66. import Drawer from "@/components/Drawer.vue"
  67. import Popover from "@/components/Popover.vue"
  68. import PopoverMenuItem from "@/components/PopoverMenuItem.vue"
  69. import { ref } from "vue"
  70. const mainStore = useMainStore()
  71. const slidesStore = useSlidesStore()
  72. const { title } = storeToRefs(slidesStore)
  73. const { importPPTXFile, exporting } = useImport()
  74. const { resetSlides } = useSlideHandler()
  75. const mainMenuVisible = ref(false)
  76. const hotkeyDrawerVisible = ref(false)
  77. /* 导出老逻辑 */
  78. const setDialogForExport = (type: DialogForExportTypes) => {
  79. mainStore.setDialogForExport(type)
  80. mainMenuVisible.value = false
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .editor-header {
  85. background-color: #fff;
  86. user-select: none;
  87. border-bottom: 1px solid #dedede;
  88. display: flex;
  89. justify-content: space-between;
  90. padding: 0 24px;
  91. }
  92. .left,
  93. .right {
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. }
  98. .menuCon {
  99. display: flex;
  100. justify-content: center;
  101. align-items: center;
  102. cursor: pointer;
  103. margin-right: 8px;
  104. width: 34px;
  105. height: 34px;
  106. border-radius: 6px;
  107. margin-left: -8px;
  108. &.menuVisible {
  109. background: rgba(34, 71, 133, 0.08);
  110. }
  111. & > img {
  112. width: 20px;
  113. height: 20px;
  114. }
  115. }
  116. .line {
  117. width: 1px;
  118. height: calc(100% - 26px);
  119. background-color: #dedede;
  120. }
  121. .title {
  122. margin-left: 16px;
  123. .title-text {
  124. font-weight: 600;
  125. font-size: 15px;
  126. color: #131415;
  127. }
  128. }
  129. .cancelBtn {
  130. width: 88px;
  131. height: 32px;
  132. background: #f1f2f6;
  133. border-radius: 6px;
  134. line-height: 32px;
  135. font-weight: 600;
  136. font-size: 14px;
  137. color: #1e2022;
  138. text-align: center;
  139. cursor: pointer;
  140. &:hover {
  141. opacity: 0.8;
  142. }
  143. }
  144. .saveBtn {
  145. margin-left: 16px;
  146. width: 88px;
  147. height: 32px;
  148. background: linear-gradient(312deg, #1b7af8 0%, #3cbbff 100%);
  149. border-radius: 6px;
  150. line-height: 32px;
  151. font-weight: 600;
  152. font-size: 14px;
  153. color: #ffffff;
  154. text-align: center;
  155. cursor: pointer;
  156. &:hover {
  157. opacity: 0.8;
  158. }
  159. }
  160. </style>