diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts index c3709ac2..545e04cb 100644 --- a/src/hooks/useExport.ts +++ b/src/hooks/useExport.ts @@ -25,7 +25,7 @@ interface ExportImageConfig { export default () => { const slidesStore = useSlidesStore() - const { slides, theme, viewportRatio } = storeToRefs(slidesStore) + const { slides, theme, viewportRatio, title } = storeToRefs(slidesStore) const exporting = ref(false) @@ -47,7 +47,7 @@ export default () => { toImage(domRef, config).then(dataUrl => { exporting.value = false - saveAs(dataUrl, `pptist_slides.${format}`) + saveAs(dataUrl, `${title.value}.${format}`) }).catch(() => { exporting.value = false message.error('导出图片失败') @@ -58,13 +58,13 @@ export default () => { // 导出pptist文件(特有 .pptist 后缀文件) const exportSpecificFile = (_slides: Slide[]) => { const blob = new Blob([encrypt(JSON.stringify(_slides))], { type: '' }) - saveAs(blob, 'pptist_slides.pptist') + saveAs(blob, `${title.value}.pptist`) } // 导出JSON文件 const exportJSON = () => { const blob = new Blob([JSON.stringify(slides.value)], { type: '' }) - saveAs(blob, 'pptist_slides.json') + saveAs(blob, `${title.value}.json`) } // 格式化颜色值为 透明度 + HexString,供pptxgenjs使用 @@ -769,7 +769,7 @@ export default () => { } 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 message.error('导出失败') }) diff --git a/src/store/slides.ts b/src/store/slides.ts index 45caf023..fd0a8787 100644 --- a/src/store/slides.ts +++ b/src/store/slides.ts @@ -23,6 +23,7 @@ interface FormatedAnimation { } export interface SlidesState { + title: string theme: SlideTheme slides: Slide[] slideIndex: number @@ -31,6 +32,7 @@ export interface SlidesState { export const useSlidesStore = defineStore('slides', { state: (): SlidesState => ({ + title: '未命名演示文稿', // 幻灯片标题 theme: theme, // 主题样式 slides: slides, // 幻灯片页面数据 slideIndex: 0, // 当前页面索引 @@ -105,6 +107,11 @@ export const useSlidesStore = defineStore('slides', { }, actions: { + setTitle(title: string) { + if (!title) this.title = '未命名演示文稿' + else this.title = title + }, + setTheme(themeProps: Partial) { this.theme = { ...this.theme, ...themeProps } }, diff --git a/src/views/Editor/EditorHeader/index.vue b/src/views/Editor/EditorHeader/index.vue index 23377605..14651aa7 100644 --- a/src/views/Editor/EditorHeader/index.vue +++ b/src/views/Editor/EditorHeader/index.vue @@ -19,6 +19,22 @@ + +
+ +
{{ title }}
+
@@ -63,8 +79,9 @@