Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface MainState {
showSymbolPanel: boolean
showMarkupPanel: boolean
showAIPPTDialog: boolean
showGlobalLoading: boolean // Global loading state for AIPPT generation
}

const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
Expand Down Expand Up @@ -75,6 +76,7 @@ export const useMainStore = defineStore('main', {
showSymbolPanel: false, // 打开符号面板
showMarkupPanel: false, // 打开类型标注面板
showAIPPTDialog: false, // 打开AIPPT创建窗口
showGlobalLoading: false, // Global loading state for AIPPT generation
}),

getters: {
Expand Down Expand Up @@ -212,5 +214,9 @@ export const useMainStore = defineStore('main', {
setAIPPTDialogState(show: boolean) {
this.showAIPPTDialog = show
},

setGlobalLoading(show: boolean) {
this.showGlobalLoading = show
},
},
})
})
15 changes: 5 additions & 10 deletions src/views/Editor/AIPPTDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@
<Button class="btn" @click="step = 'outline'">返回大纲</Button>
</div>
</div>

<FullscreenSpin :loading="loading" tip="AI生成中,请耐心等待 ..." />
</div>
</template>

Expand Down Expand Up @@ -147,7 +145,6 @@ const img = ref('')
const keyword = ref('')
const outline = ref('')
const selectedTemplate = ref('template_1')
const loading = ref(false)
const outlineCreating = ref(false)
const overwrite = ref(true)
const step = ref<'setup' | 'outline' | 'template'>('setup')
Expand Down Expand Up @@ -182,7 +179,6 @@ const setKeyword = (value: string) => {
const createOutline = async () => {
if (!keyword.value) return message.error('请先输入PPT主题')

loading.value = true
outlineCreating.value = true

const stream = await api.AIPPT_Outline({
Expand All @@ -192,11 +188,10 @@ const createOutline = async () => {
})
if (stream.status === 500) {
message.error('AI服务异常,请更换其他模型重试')
loading.value = false
outlineCreating.value = false
return
}

loading.value = false
step.value = 'outline'

const reader: ReadableStreamDefaultReader = stream.body.getReader()
Expand Down Expand Up @@ -225,7 +220,8 @@ const createOutline = async () => {
}

const createPPT = async (template?: { slides: Slide[], theme: SlideTheme }) => {
loading.value = true
mainStore.setGlobalLoading(true) // Show global loading mask
mainStore.setAIPPTDialogState(false) // Close dialog immediately when createPPT is called

if (overwrite.value) resetSlides()

Expand All @@ -252,8 +248,7 @@ const createPPT = async (template?: { slides: Slide[], theme: SlideTheme }) => {
const readStream = () => {
reader.read().then(({ done, value }) => {
if (done) {
loading.value = false
mainStore.setAIPPTDialogState(false)
mainStore.setGlobalLoading(false) // Hide global loading mask
slidesStore.setTheme(templateTheme)
return
}
Expand Down Expand Up @@ -471,4 +466,4 @@ const uploadLocalTemplate = () => {
}
}
}
</style>
</style>
11 changes: 9 additions & 2 deletions src/views/Editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
>
<AIPPTDialog />
</Modal>

<FullscreenSpin
:loading="showGlobalLoading"
tip="AI生成中,请耐心等待 ..."
mask
/>
</template>

<script lang="ts" setup>
Expand All @@ -63,9 +69,10 @@ import SymbolPanel from './SymbolPanel.vue'
import MarkupPanel from './MarkupPanel.vue'
import AIPPTDialog from './AIPPTDialog.vue'
import Modal from '@/components/Modal.vue'
import FullscreenSpin from '@/components/FullscreenSpin.vue'

const mainStore = useMainStore()
const { dialogForExport, showSelectPanel, showSearchPanel, showNotesPanel, showSymbolPanel, showMarkupPanel, showAIPPTDialog } = storeToRefs(mainStore)
const { dialogForExport, showSelectPanel, showSearchPanel, showNotesPanel, showSymbolPanel, showMarkupPanel, showAIPPTDialog, showGlobalLoading } = storeToRefs(mainStore)

const closeExportDialog = () => mainStore.setDialogForExport('')
const closeAIPPTDialog = () => mainStore.setAIPPTDialogState(false)
Expand Down Expand Up @@ -103,4 +110,4 @@ usePasteEvent()
width: 260px;
height: 100%;
}
</style>
</style>