mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
feat: 支持设置演示文稿标题
This commit is contained in:
parent
10b01876c2
commit
e1e791a395
@ -25,7 +25,7 @@ interface ExportImageConfig {
|
|||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const slidesStore = useSlidesStore()
|
const slidesStore = useSlidesStore()
|
||||||
const { slides, theme, viewportRatio } = storeToRefs(slidesStore)
|
const { slides, theme, viewportRatio, title } = storeToRefs(slidesStore)
|
||||||
|
|
||||||
const exporting = ref(false)
|
const exporting = ref(false)
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export default () => {
|
|||||||
|
|
||||||
toImage(domRef, config).then(dataUrl => {
|
toImage(domRef, config).then(dataUrl => {
|
||||||
exporting.value = false
|
exporting.value = false
|
||||||
saveAs(dataUrl, `pptist_slides.${format}`)
|
saveAs(dataUrl, `${title.value}.${format}`)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
exporting.value = false
|
exporting.value = false
|
||||||
message.error('导出图片失败')
|
message.error('导出图片失败')
|
||||||
@ -58,13 +58,13 @@ export default () => {
|
|||||||
// 导出pptist文件(特有 .pptist 后缀文件)
|
// 导出pptist文件(特有 .pptist 后缀文件)
|
||||||
const exportSpecificFile = (_slides: Slide[]) => {
|
const exportSpecificFile = (_slides: Slide[]) => {
|
||||||
const blob = new Blob([encrypt(JSON.stringify(_slides))], { type: '' })
|
const blob = new Blob([encrypt(JSON.stringify(_slides))], { type: '' })
|
||||||
saveAs(blob, 'pptist_slides.pptist')
|
saveAs(blob, `${title.value}.pptist`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出JSON文件
|
// 导出JSON文件
|
||||||
const exportJSON = () => {
|
const exportJSON = () => {
|
||||||
const blob = new Blob([JSON.stringify(slides.value)], { type: '' })
|
const blob = new Blob([JSON.stringify(slides.value)], { type: '' })
|
||||||
saveAs(blob, 'pptist_slides.json')
|
saveAs(blob, `${title.value}.json`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化颜色值为 透明度 + HexString,供pptxgenjs使用
|
// 格式化颜色值为 透明度 + HexString,供pptxgenjs使用
|
||||||
@ -769,7 +769,7 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
pptx.writeFile({ fileName: `pptist.pptx` }).then(() => exporting.value = false).catch(() => {
|
pptx.writeFile({ fileName: `${title.value}.pptx` }).then(() => exporting.value = false).catch(() => {
|
||||||
exporting.value = false
|
exporting.value = false
|
||||||
message.error('导出失败')
|
message.error('导出失败')
|
||||||
})
|
})
|
||||||
|
@ -23,6 +23,7 @@ interface FormatedAnimation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SlidesState {
|
export interface SlidesState {
|
||||||
|
title: string
|
||||||
theme: SlideTheme
|
theme: SlideTheme
|
||||||
slides: Slide[]
|
slides: Slide[]
|
||||||
slideIndex: number
|
slideIndex: number
|
||||||
@ -31,6 +32,7 @@ export interface SlidesState {
|
|||||||
|
|
||||||
export const useSlidesStore = defineStore('slides', {
|
export const useSlidesStore = defineStore('slides', {
|
||||||
state: (): SlidesState => ({
|
state: (): SlidesState => ({
|
||||||
|
title: '未命名演示文稿', // 幻灯片标题
|
||||||
theme: theme, // 主题样式
|
theme: theme, // 主题样式
|
||||||
slides: slides, // 幻灯片页面数据
|
slides: slides, // 幻灯片页面数据
|
||||||
slideIndex: 0, // 当前页面索引
|
slideIndex: 0, // 当前页面索引
|
||||||
@ -105,6 +107,11 @@ export const useSlidesStore = defineStore('slides', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
setTitle(title: string) {
|
||||||
|
if (!title) this.title = '未命名演示文稿'
|
||||||
|
else this.title = title
|
||||||
|
},
|
||||||
|
|
||||||
setTheme(themeProps: Partial<SlideTheme>) {
|
setTheme(themeProps: Partial<SlideTheme>) {
|
||||||
this.theme = { ...this.theme, ...themeProps }
|
this.theme = { ...this.theme, ...themeProps }
|
||||||
},
|
},
|
||||||
|
@ -19,6 +19,22 @@
|
|||||||
</template>
|
</template>
|
||||||
<div class="menu-item"><IconHamburgerButton class="icon" /></div>
|
<div class="menu-item"><IconHamburgerButton class="icon" /></div>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
<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>
|
||||||
|
|
||||||
<div class="right">
|
<div class="right">
|
||||||
@ -63,8 +79,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { nextTick, ref } from 'vue'
|
||||||
import { useMainStore } from '@/store'
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { useMainStore, useSlidesStore } from '@/store'
|
||||||
import useScreening from '@/hooks/useScreening'
|
import useScreening from '@/hooks/useScreening'
|
||||||
import useImport from '@/hooks/useImport'
|
import useImport from '@/hooks/useImport'
|
||||||
import useSlideHandler from '@/hooks/useSlideHandler'
|
import useSlideHandler from '@/hooks/useSlideHandler'
|
||||||
@ -77,15 +94,32 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Drawer,
|
Drawer,
|
||||||
Popover,
|
Popover,
|
||||||
|
Input,
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
|
|
||||||
const mainStore = useMainStore()
|
const mainStore = useMainStore()
|
||||||
|
const slidesStore = useSlidesStore()
|
||||||
|
const { title } = storeToRefs(slidesStore)
|
||||||
const { enterScreening, enterScreeningFromStart } = useScreening()
|
const { enterScreening, enterScreeningFromStart } = useScreening()
|
||||||
const { importSpecificFile, importPPTXFile, exporting } = useImport()
|
const { importSpecificFile, importPPTXFile, exporting } = useImport()
|
||||||
const { resetSlides } = useSlideHandler()
|
const { resetSlides } = useSlideHandler()
|
||||||
|
|
||||||
const mainMenuVisible = ref(false)
|
const mainMenuVisible = ref(false)
|
||||||
const hotkeyDrawerVisible = ref(false)
|
const hotkeyDrawerVisible = ref(false)
|
||||||
|
const editingTitle = ref(false)
|
||||||
|
const titleInputRef = ref<HTMLInputElement>()
|
||||||
|
const titleValue = ref('')
|
||||||
|
|
||||||
|
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) => {
|
const goLink = (url: string) => {
|
||||||
window.open(url)
|
window.open(url)
|
||||||
@ -151,6 +185,33 @@ const setDialogForExport = (type: DialogForExportTypes) => {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.title {
|
||||||
|
height: 30px;
|
||||||
|
margin-left: 2px;
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
.title-input {
|
||||||
|
width: 200px;
|
||||||
|
height: 100%;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
font-family: 'Microsoft YaHei';
|
||||||
|
}
|
||||||
|
.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 {
|
.github-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user