Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: importing a PPTXFile does not stop loading when parsing the file fails #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions src/hooks/useImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,20 @@ export default () => {

const reader = new FileReader()
reader.onload = async e => {
const json = await parse(e.target!.result as ArrayBuffer, {
slideFactor: 75 / 914400,
fontsizeFactor: 100 / 98,
})
let json
try {
json = await parse(e.target!.result as ArrayBuffer, {
slideFactor: 75 / 914400,
fontsizeFactor: 100 / 98,
})
}
catch {
message.error('无法正确读取 / 解析该文件')
}
if (!json) {
exporting.value = false
return
}

const width = json.size.width
const scale = VIEWPORT_SIZE / width
Expand Down