| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <template>
- <div class="editor-header">
- <div class="left">
- <Popover trigger="click" placement="bottom-start" v-model:value="mainMenuVisible">
- <template #content>
- <!-- <PopoverMenuItem @click="openAIPPTDialog(); mainMenuVisible = false">AI 生成 PPT</PopoverMenuItem> -->
- <FileInput accept="application/vnd.openxmlformats-officedocument.presentationml.presentation" @change="files => {
- importPPTXFile(files)
- mainMenuVisible = false
- }">
- <PopoverMenuItem>导入 PPTX 文件</PopoverMenuItem>
- </FileInput>
- <!-- <FileInput accept=".json" @change="files => {
- importJSON(files)
- mainMenuVisible = false
- }">
- <PopoverMenuItem>导入 JSON 文件</PopoverMenuItem>
- </FileInput> -->
- <!-- <FileInput accept=".pptist" @change="files => {
- importSpecificFile(files)
- mainMenuVisible = false
- }">
- <PopoverMenuItem>导入 pptist 文件</PopoverMenuItem>
- </FileInput> -->
- <!-- <PopoverMenuItem @click="setDialogForExport('pptx')">导出文件</PopoverMenuItem> -->
- <PopoverMenuItem @click="resetSlides(); mainMenuVisible = false">重置幻灯片</PopoverMenuItem>
- <!-- <PopoverMenuItem @click="openMarkupPanel(); mainMenuVisible = false">幻灯片类型标注</PopoverMenuItem> -->
- <!-- <PopoverMenuItem @click="goLink('https://github.com/pipipi-pikachu/PPTist/issues')">意见反馈</PopoverMenuItem> -->
- <!-- <PopoverMenuItem @click="goLink('https://github.com/pipipi-pikachu/PPTist/blob/master/doc/Q&A.md')">常见问题</PopoverMenuItem> -->
- <PopoverMenuItem @click="mainMenuVisible = false; hotkeyDrawerVisible = true">快捷操作</PopoverMenuItem>
- </template>
- <div class="menu-item" v-show="false"><IconHamburgerButton class="icon" /></div>
- </Popover>
- <FileInput accept="application/vnd.openxmlformats-officedocument.presentationml.presentation" @change="files => {
- importPPTXFile(files)
- }">
- <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>上传 PPTX 文件</div>
- </FileInput>
- <div class="title" v-show="false">
- <Input
- class="title-input"
- ref="titleInputRef"
- v-model:value="titleValue"
- @blur="handleUpdateTitle()"
- v-if="editingTitle"
- ></Input>
- <div
- class="title-text"
- @click="startEditTitle()"
- :title="title"
- v-else
- >{{ title }}</div>
- </div>
- </div>
- <div class="right">
- <div class="group-menu-item">
- <div class="menu-item" v-tooltip="'幻灯片放映(F5)'" @click="enterScreening()">
- <IconPpt class="icon" />
- </div>
- <Popover trigger="click" center>
- <template #content>
- <PopoverMenuItem @click="enterScreeningFromStart()">从头开始</PopoverMenuItem>
- <PopoverMenuItem @click="enterScreening()">从当前页开始</PopoverMenuItem>
- </template>
- <div class="arrow-btn"><IconDown class="arrow" /></div>
- </Popover>
- </div>
- <!-- <div class="menu-item" v-tooltip="'学生视图'" @click="enterStudentView()">
- <IconUser class="icon" />
- </div> -->
- <!-- <div class="menu-item" v-tooltip="'AI生成PPT'" @click="openAIPPTDialog(); mainMenuVisible = false">
- <span class="text ai">AI</span>
- </div> -->
- <div class="menu-item" v-tooltip="'导出'" @click="setDialogForExport('pptx')">
- <IconDownload class="icon" />
- </div>
- <!-- <a class="github-link" v-tooltip="'Copyright © 2020-PRESENT pipipi-pikachu'" href="https://github.com/pipipi-pikachu/PPTist" target="_blank">
- <div class="menu-item"><IconGithub class="icon" /></div>
- </a> -->
- </div>
- <Drawer
- :width="320"
- v-model:visible="hotkeyDrawerVisible"
- placement="right"
- >
- <HotkeyDoc />
- <template v-slot:title>快捷操作</template>
- </Drawer>
- <FullscreenSpin :loading="exporting" tip="正在导入..." />
- </div>
- </template>
- <script lang="ts" setup>
- import { nextTick, ref, useTemplateRef, inject } from 'vue'
- import { storeToRefs } from 'pinia'
- import { useMainStore, useSlidesStore } from '@/store'
- import useScreening from '@/hooks/useScreening'
- import useImport from '@/hooks/useImport'
- import useSlideHandler from '@/hooks/useSlideHandler'
- import type { DialogForExportTypes } from '@/types/export'
- import HotkeyDoc from './HotkeyDoc.vue'
- import FileInput from '@/components/FileInput.vue'
- import FullscreenSpin from '@/components/FullscreenSpin.vue'
- import Drawer from '@/components/Drawer.vue'
- import Input from '@/components/Input.vue'
- import Popover from '@/components/Popover.vue'
- import PopoverMenuItem from '@/components/PopoverMenuItem.vue'
- const mainStore = useMainStore()
- const slidesStore = useSlidesStore()
- const { title } = storeToRefs(slidesStore)
- const { enterScreening, enterScreeningFromStart } = useScreening()
- const { importSpecificFile, importPPTXFile, importJSON, exporting } = useImport()
- const { resetSlides } = useSlideHandler()
- const mainMenuVisible = ref(false)
- const hotkeyDrawerVisible = ref(false)
- const editingTitle = ref(false)
- const titleValue = ref('')
- const titleInputRef = useTemplateRef<InstanceType<typeof Input>>('titleInputRef')
- const startEditTitle = () => {
- titleValue.value = title.value
- editingTitle.value = true
- nextTick(() => titleInputRef.value?.focus())
- }
- const handleUpdateTitle = () => {
- slidesStore.setTitle(titleValue.value)
- editingTitle.value = false
- }
- const goLink = (url: string) => {
- window.open(url)
- mainMenuVisible.value = false
- }
- const setDialogForExport = (type: DialogForExportTypes) => {
- mainStore.setDialogForExport(type)
- mainMenuVisible.value = false
- }
- const openMarkupPanel = () => {
- mainStore.setMarkupPanelState(true)
- }
- const openAIPPTDialog = () => {
- mainStore.setAIPPTDialogState(true)
- }
- const enterStudentView = () => {
- // 通过路由跳转到学生模式
- window.location.href = '/?mode=student'
- }
- const setTitle = (newTitle: string) => {
- titleValue.value = newTitle
- slidesStore.setTitle(newTitle)
- }
- (window as any).setTitle = setTitle
- </script>
- <style lang="scss" scoped>
- .editor-header {
- background-color: #fff;
- user-select: none;
- border-bottom: 1px solid $borderColor;
- display: flex;
- justify-content: space-between;
- padding: 0 5px;
- }
- .left, .right {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .menu-item {
- height: 30px;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 14px;
- padding: 0 10px;
- border-radius: $borderRadius;
- cursor: pointer;
- .icon {
- font-size: 18px;
- color: #666;
- }
- .text {
- width: 18px;
- text-align: center;
- font-size: 17px;
- }
- .ai {
- background: linear-gradient(270deg, #d897fd, #33bcfc);
- background-clip: text;
- color: transparent;
- font-weight: 700;
- }
- &:hover {
- background-color: #f1f1f1;
- }
- svg {
- width: 18px;
- margin-right: 5px;
- }
- }
- .group-menu-item {
- height: 30px;
- display: flex;
- margin: 0 8px;
- padding: 0 2px;
- border-radius: $borderRadius;
- &:hover {
- background-color: #f1f1f1;
- }
- .menu-item {
- padding: 0 3px;
- }
- .arrow-btn {
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- }
- }
- .title {
- height: 30px;
- margin-left: 2px;
- font-size: 13px;
- .title-input {
- width: 200px;
- height: 100%;
- padding-left: 0;
- padding-right: 0;
- ::v-deep(input) {
- height: 28px;
- line-height: 28px;
- }
- }
- .title-text {
- min-width: 20px;
- max-width: 400px;
- line-height: 30px;
- padding: 0 6px;
- border-radius: $borderRadius;
- cursor: pointer;
- @include ellipsis-oneline();
- &:hover {
- background-color: #f1f1f1;
- }
- }
- }
- .github-link {
- display: inline-block;
- height: 30px;
- }
- </style>
|