diff --git a/src/App.vue b/src/App.vue
index 087985a5..8b1b187a 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -10,6 +10,7 @@ import { storeToRefs } from 'pinia'
import { useScreenStore, useMainStore, useSnapshotStore } from '@/store'
import { LOCALSTORAGE_KEY_DISCARDED_DB } from '@/configs/storage'
import { isPC } from './utils/common'
+import useExport from './hooks/useExport'
import Editor from './views/Editor/index.vue'
import Screen from './views/Screen/index.vue'
@@ -35,6 +36,18 @@ export default defineComponent({
onMounted(() => {
snapshotStore.initSnapshotDatabase()
mainStore.setAvailableFonts()
+
+ const { importSpecificFile } = useExport()
+
+ if ('launchQueue' in window) {
+ /* eslint-disable-next-line */
+ (window as any).launchQueue.setConsumer(async (launchParams: any) => {
+ if (launchParams.files && launchParams.files.length) {
+ const files: File[] = launchParams.files
+ importSpecificFile(files, true)
+ }
+ })
+ }
})
// 应用注销时向 localStorage 中记录下本次 indexedDB 的数据库ID,用于之后清除数据库
diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts
index bb89f642..f21c366a 100644
--- a/src/hooks/useExport.ts
+++ b/src/hooks/useExport.ts
@@ -22,7 +22,8 @@ interface ExportImageConfig {
}
export default () => {
- const { slides, theme, viewportRatio } = storeToRefs(useSlidesStore())
+ const slidesStore = useSlidesStore()
+ const { slides, theme, viewportRatio } = storeToRefs(slidesStore)
const { addSlidesFromData } = useAddSlidesOrElements()
@@ -61,14 +62,15 @@ export default () => {
}
// 导入pptist文件
- const importSpecificFile = (files: File[]) => {
+ const importSpecificFile = (files: File[], cover = false) => {
const file = files[0]
const reader = new FileReader()
reader.addEventListener('load', () => {
try {
const slides = JSON.parse(decrypt(reader.result as string))
- addSlidesFromData(slides)
+ if (cover) slidesStore.setSlides(slides)
+ else addSlidesFromData(slides)
}
catch {
message.error('无法正确读取 / 解析该文件')
diff --git a/src/views/Editor/EditorHeader/index.vue b/src/views/Editor/EditorHeader/index.vue
index d376c0ec..d38e74df 100644
--- a/src/views/Editor/EditorHeader/index.vue
+++ b/src/views/Editor/EditorHeader/index.vue
@@ -10,6 +10,7 @@
+
diff --git a/vue.config.js b/vue.config.js
index ffbacf94..b451a2bc 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -67,6 +67,14 @@ module.exports = {
type: 'image/png',
purpose: 'maskable'
}],
+ file_handlers: [
+ {
+ action: '/',
+ accept: {
+ '*': ['.pptist'],
+ }
+ }
+ ],
start_url: '.',
display: 'standalone',
background_color: '#000000',