index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. <!-- <PopoverMenuItem @click="openAIPPTDialog(); mainMenuVisible = false">AI 生成 PPT</PopoverMenuItem> -->
  7. <FileInput accept="application/vnd.openxmlformats-officedocument.presentationml.presentation" @change="files => {
  8. importPPTXFile(files)
  9. mainMenuVisible = false
  10. }">
  11. <PopoverMenuItem>{{ lang.ssImportPptx }}</PopoverMenuItem>
  12. </FileInput>
  13. <!-- <FileInput accept=".json" @change="files => {
  14. importJSON(files)
  15. mainMenuVisible = false
  16. }">
  17. <PopoverMenuItem>导入 JSON 文件</PopoverMenuItem>
  18. </FileInput> -->
  19. <!-- <FileInput accept=".pptist" @change="files => {
  20. importSpecificFile(files)
  21. mainMenuVisible = false
  22. }">
  23. <PopoverMenuItem>导入 pptist 文件</PopoverMenuItem>
  24. </FileInput> -->
  25. <!-- <PopoverMenuItem @click="setDialogForExport('pptx')">导出文件</PopoverMenuItem> -->
  26. <PopoverMenuItem @click="resetSlides(); mainMenuVisible = false">{{ lang.ssResetSlides }}</PopoverMenuItem>
  27. <!-- <PopoverMenuItem @click="openMarkupPanel(); mainMenuVisible = false">幻灯片类型标注</PopoverMenuItem> -->
  28. <!-- <PopoverMenuItem @click="goLink('https://github.com/pipipi-pikachu/PPTist/issues')">意见反馈</PopoverMenuItem> -->
  29. <!-- <PopoverMenuItem @click="goLink('https://github.com/pipipi-pikachu/PPTist/blob/master/doc/Q&A.md')">常见问题</PopoverMenuItem> -->
  30. <PopoverMenuItem @click="mainMenuVisible = false; hotkeyDrawerVisible = true">{{ lang.ssHotkeys }}</PopoverMenuItem>
  31. </template>
  32. <div class="menu-item" v-show="false"><IconHamburgerButton class="icon" /></div>
  33. </Popover>
  34. <FileInput accept="application/vnd.openxmlformats-officedocument.presentationml.presentation" @change="files => {
  35. importPPTXFile(files)
  36. }">
  37. <div class="menu-item"><svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>{{ lang.ssUploadPptx }}</div>
  38. </FileInput>
  39. <div class="title" v-show="false">
  40. <Input
  41. class="title-input"
  42. ref="titleInputRef"
  43. v-model:value="titleValue"
  44. @blur="handleUpdateTitle()"
  45. v-if="editingTitle"
  46. ></Input>
  47. <div
  48. class="title-text"
  49. @click="startEditTitle()"
  50. :title="title"
  51. v-else
  52. >{{ title }}</div>
  53. </div>
  54. </div>
  55. <div class="right">
  56. <div class="group-menu-item">
  57. <div class="menu-item" v-tooltip="lang.ssStage" @click="enterScreening()">
  58. <IconPpt class="icon" />
  59. </div>
  60. <Popover trigger="click" center>
  61. <template #content>
  62. <PopoverMenuItem @click="enterScreeningFromStart()">{{ lang.ssFromStart }}</PopoverMenuItem>
  63. <PopoverMenuItem @click="enterScreening()">{{ lang.ssFromCurrent }}</PopoverMenuItem>
  64. </template>
  65. <div class="arrow-btn"><IconDown class="arrow" /></div>
  66. </Popover>
  67. </div>
  68. <!-- <div class="menu-item" v-tooltip="'学生视图'" @click="enterStudentView()">
  69. <IconUser class="icon" />
  70. </div> -->
  71. <!-- <div class="menu-item" v-tooltip="'AI生成PPT'" @click="openAIPPTDialog(); mainMenuVisible = false">
  72. <span class="text ai">AI</span>
  73. </div> -->
  74. <div class="menu-item" v-tooltip="lang.ssExport" @click="setDialogForExport('pptx')">
  75. <IconDownload class="icon" />
  76. </div>
  77. <!-- <a class="github-link" v-tooltip="'Copyright © 2020-PRESENT pipipi-pikachu'" href="https://github.com/pipipi-pikachu/PPTist" target="_blank">
  78. <div class="menu-item"><IconGithub class="icon" /></div>
  79. </a> -->
  80. </div>
  81. <Drawer
  82. :width="320"
  83. v-model:visible="hotkeyDrawerVisible"
  84. placement="right"
  85. >
  86. <HotkeyDoc />
  87. <template v-slot:title>{{ lang.ssHotkeys }}</template>
  88. </Drawer>
  89. <FullscreenSpin :loading="exporting" :tip="lang.ssImporting" />
  90. </div>
  91. </template>
  92. <script lang="ts" setup>
  93. import { nextTick, ref, useTemplateRef, inject, onMounted } from 'vue'
  94. import { storeToRefs } from 'pinia'
  95. import { useMainStore, useSlidesStore } from '@/store'
  96. import useScreening from '@/hooks/useScreening'
  97. import useImport from '@/hooks/useImport'
  98. import useSlideHandler from '@/hooks/useSlideHandler'
  99. import type { DialogForExportTypes } from '@/types/export'
  100. import { lang } from '@/main'
  101. import HotkeyDoc from './HotkeyDoc.vue'
  102. import FileInput from '@/components/FileInput.vue'
  103. import FullscreenSpin from '@/components/FullscreenSpin.vue'
  104. import Drawer from '@/components/Drawer.vue'
  105. import Input from '@/components/Input.vue'
  106. import Popover from '@/components/Popover.vue'
  107. import PopoverMenuItem from '@/components/PopoverMenuItem.vue'
  108. const mainStore = useMainStore()
  109. const slidesStore = useSlidesStore()
  110. const { title } = storeToRefs(slidesStore)
  111. const { enterScreening, enterScreeningFromStart } = useScreening()
  112. const { importSpecificFile, importPPTXFile, importJSON, exporting } = useImport()
  113. const { resetSlides } = useSlideHandler()
  114. const mainMenuVisible = ref(false)
  115. const hotkeyDrawerVisible = ref(false)
  116. const editingTitle = ref(false)
  117. const titleValue = ref('')
  118. const titleInputRef = useTemplateRef<InstanceType<typeof Input>>('titleInputRef')
  119. const startEditTitle = () => {
  120. titleValue.value = title.value
  121. editingTitle.value = true
  122. nextTick(() => titleInputRef.value?.focus())
  123. }
  124. const handleUpdateTitle = () => {
  125. slidesStore.setTitle(titleValue.value)
  126. editingTitle.value = false
  127. }
  128. const goLink = (url: string) => {
  129. window.open(url)
  130. mainMenuVisible.value = false
  131. }
  132. const setDialogForExport = (type: DialogForExportTypes) => {
  133. mainStore.setDialogForExport(type)
  134. mainMenuVisible.value = false
  135. }
  136. const openMarkupPanel = () => {
  137. mainStore.setMarkupPanelState(true)
  138. }
  139. const openAIPPTDialog = () => {
  140. mainStore.setAIPPTDialogState(true)
  141. }
  142. const enterStudentView = () => {
  143. // 通过路由跳转到学生模式
  144. window.location.href = '/?mode=student'
  145. }
  146. const setTitle = (newTitle: string) => {
  147. titleValue.value = newTitle
  148. slidesStore.setTitle(newTitle)
  149. }
  150. (window as any).setTitle = setTitle
  151. </script>
  152. <style lang="scss" scoped>
  153. .editor-header {
  154. background-color: #fff;
  155. user-select: none;
  156. border-bottom: 1px solid $borderColor;
  157. display: flex;
  158. justify-content: space-between;
  159. padding: 0 5px;
  160. }
  161. .left, .right {
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. }
  166. .menu-item {
  167. height: 30px;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. font-size: 14px;
  172. padding: 0 10px;
  173. border-radius: $borderRadius;
  174. cursor: pointer;
  175. .icon {
  176. font-size: 18px;
  177. color: #666;
  178. }
  179. .text {
  180. width: 18px;
  181. text-align: center;
  182. font-size: 17px;
  183. }
  184. .ai {
  185. background: linear-gradient(270deg, #d897fd, #33bcfc);
  186. background-clip: text;
  187. color: transparent;
  188. font-weight: 700;
  189. }
  190. &:hover {
  191. background-color: #f1f1f1;
  192. }
  193. svg {
  194. width: 18px;
  195. margin-right: 5px;
  196. }
  197. }
  198. .group-menu-item {
  199. height: 30px;
  200. display: flex;
  201. margin: 0 8px;
  202. padding: 0 2px;
  203. border-radius: $borderRadius;
  204. &:hover {
  205. background-color: #f1f1f1;
  206. }
  207. .menu-item {
  208. padding: 0 3px;
  209. }
  210. .arrow-btn {
  211. display: flex;
  212. justify-content: center;
  213. align-items: center;
  214. cursor: pointer;
  215. }
  216. }
  217. .title {
  218. height: 30px;
  219. margin-left: 2px;
  220. font-size: 13px;
  221. .title-input {
  222. width: 200px;
  223. height: 100%;
  224. padding-left: 0;
  225. padding-right: 0;
  226. ::v-deep(input) {
  227. height: 28px;
  228. line-height: 28px;
  229. }
  230. }
  231. .title-text {
  232. min-width: 20px;
  233. max-width: 400px;
  234. line-height: 30px;
  235. padding: 0 6px;
  236. border-radius: $borderRadius;
  237. cursor: pointer;
  238. @include ellipsis-oneline();
  239. &:hover {
  240. background-color: #f1f1f1;
  241. }
  242. }
  243. }
  244. .github-link {
  245. display: inline-block;
  246. height: 30px;
  247. }
  248. </style>