diff --git a/README.md b/README.md index 2813a951..e566ead9 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ # ✨ Highlights 1. Easy Development: Built with Vue 3.x and TypeScript, it does not rely on UI component libraries and avoids third-party components as much as possible. This makes styling customization easier and functionality extension more convenient. 2. User Friendly: It offers a context menu available everywhere, dozens of keyboard shortcuts, and countless editing detail optimizations, striving to replicate a desktop application-level experience. -3. Feature Rich: Supports most of the commonly used elements and functionalities found in PowerPoint, supports exporting in various formats, and offers basic editing and previewing on mobile devices. +3. Feature Rich: Supports most of the commonly used elements and functionalities found in PowerPoint, supports generate PPT by AI, supports exporting in various formats, and offers basic editing and previewing on mobile devices. # 🚀 Installation @@ -40,6 +40,7 @@ npm run dev - Export local files (PPTX, JSON, images, PDF) - Import and export pptist files - Print +- AI PPT ### Slide Page Editing - Add/delete pages - Copy/paste pages diff --git a/README_zh.md b/README_zh.md index 198bdad7..a1892071 100644 --- a/README_zh.md +++ b/README_zh.md @@ -9,7 +9,7 @@ # ✨ 项目特色 1. 易开发:基于 Vue3.x + TypeScript 构建,不依赖UI组件库,尽量避免第三方组件,样式定制更轻松、功能扩展更方便。 2. 易使用:随处可用的右键菜单、几十种快捷键、无数次编辑细节打磨,力求还原桌面应用级体验。 -3. 功能丰富:支持 PPT 中的大部分常用元素和功能,支持多种格式导出、支持移动端基础编辑和预览... +3. 功能丰富:支持 PPT 中的大部分常用元素和功能,支持AI生成PPT、支持多种格式导出、支持移动端基础编辑和预览... # 👀 前排提示 @@ -36,6 +36,7 @@ npm run dev - 导出本地文件(PPTX、JSON、图片、PDF) - 导入导出特有 .pptist 文件 - 打印 +- AI生成PPT ### 幻灯片页面编辑 - 页面添加、删除 - 页面顺序调整 diff --git a/index.html b/index.html index b8fc5b90..6a6d8aff 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + PPTist - 在线演示文稿 \ No newline at end of file diff --git a/src/hooks/useAIPPT.ts b/src/hooks/useAIPPT.ts index 7342cefb..0063b387 100644 --- a/src/hooks/useAIPPT.ts +++ b/src/hooks/useAIPPT.ts @@ -1,4 +1,3 @@ -import api from '@/services' import { nanoid } from 'nanoid' import type { PPTElement, PPTShapeElement, PPTTextElement, Slide, TextType } from '@/types/slides' import type { AIPPTSlide } from '@/types/AIPPT' @@ -158,10 +157,14 @@ export default () => { const { addSlidesFromData } = useAddSlidesOrElements() const { isEmptySlide } = useSlideHandler() - const AIPPT = async () => { - const templateSlides: Slide[] = await api.getMockData('template').then(ret => ret.slides) - const _AISlides: AIPPTSlide[] = await api.getMockData('AIPPT') + const getMdContent = (content: string) => { + const regex = /```markdown([^```]*)```/ + const match = content.match(regex) + if (match) return match[1].trim() + return content.replace('```markdown', '').replace('```', '') + } + const AIPPT = (templateSlides: Slide[], _AISlides: AIPPTSlide[]) => { const AISlides: AIPPTSlide[] = [] for (const template of _AISlides) { if (template.type === 'content') { @@ -411,5 +414,6 @@ export default () => { return { AIPPT, + getMdContent, } } \ No newline at end of file diff --git a/src/plugins/icon.ts b/src/plugins/icon.ts index da9ce976..b74c16aa 100644 --- a/src/plugins/icon.ts +++ b/src/plugins/icon.ts @@ -36,6 +36,7 @@ import { AlignHorizontally, BringToFront, SendToBack, + Send, AlignTextLeft, AlignTextRight, AlignTextCenter, @@ -166,6 +167,7 @@ export const icons: Icons = { IconAlignHorizontally: AlignHorizontally, IconBringToFront: BringToFront, IconSendToBack: SendToBack, + IconSend: Send, IconAlignTextLeft: AlignTextLeft, IconAlignTextRight: AlignTextRight, IconAlignTextCenter: AlignTextCenter, diff --git a/src/services/index.ts b/src/services/index.ts index 047683ce..3df66e73 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,7 +1,22 @@ import axios from './config' +const SERVER_URL = (import.meta.env.MODE === 'development') ? '/api' : 'https://server.pptist.cn' +const ASSET_URL = 'https://asset.pptist.cn' + export default { getMockData(filename: string): Promise { return axios.get(`./mocks/${filename}.json`) }, + + getFileData(filename: string): Promise { + return axios.get(`${ASSET_URL}/data/${filename}.json`) + }, + + AIPPT_Outline(content: string) { + return axios.post(`${SERVER_URL}/tools/aippt_outline`, { content }) + }, + + AIPPT(content: string) { + return axios.post(`${SERVER_URL}/tools/aippt`, { content }) + }, } \ No newline at end of file diff --git a/src/store/main.ts b/src/store/main.ts index 3ee95b07..64ae62ab 100644 --- a/src/store/main.ts +++ b/src/store/main.ts @@ -36,6 +36,7 @@ export interface MainState { showSearchPanel: boolean showNotesPanel: boolean showMarkupPanel: boolean + showAIPPTDialog: boolean } const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') @@ -71,6 +72,7 @@ export const useMainStore = defineStore('main', { showSearchPanel: false, // 打开查找替换面板 showNotesPanel: false, // 打开批注面板 showMarkupPanel: false, // 打开类型标注面板 + showAIPPTDialog: false, // 打开AIPPT创建窗口 }), getters: { @@ -200,5 +202,9 @@ export const useMainStore = defineStore('main', { setMarkupPanelState(show: boolean) { this.showMarkupPanel = show }, + + setAIPPTDialogState(show: boolean) { + this.showAIPPTDialog = show + }, }, }) \ No newline at end of file diff --git a/src/views/Editor/AIPPTDialog.vue b/src/views/Editor/AIPPTDialog.vue new file mode 100644 index 00000000..d0c523c0 --- /dev/null +++ b/src/views/Editor/AIPPTDialog.vue @@ -0,0 +1,175 @@ + + + + + \ No newline at end of file diff --git a/src/views/Editor/EditorHeader/index.vue b/src/views/Editor/EditorHeader/index.vue index ef49e9ad..f11c466c 100644 --- a/src/views/Editor/EditorHeader/index.vue +++ b/src/views/Editor/EditorHeader/index.vue @@ -3,7 +3,7 @@