perf: 优化导入失败提示

This commit is contained in:
奔跑的面条 2022-10-14 09:37:31 +08:00
parent 0aa3f68f6d
commit e6b7a868a2

View File

@ -33,15 +33,23 @@ export const useFile = () => {
negativeButtonProps: { type: 'info', ghost: false },
// 新增
onPositiveCallback: async () => {
fileData = JSON.parse(fileData)
await updateComponent(fileData, false, true)
window['$message'].success('导入成功!')
try {
fileData = JSON.parse(fileData)
await updateComponent(fileData, false, true)
window['$message'].success('导入成功!')
} catch (error) {
window['$message'].error('组件导入失败,请检查文件完整性!')
}
},
// 覆盖
onNegativeCallback: async () => {
fileData = JSON.parse(fileData)
await updateComponent(fileData, true, true)
window['$message'].success('导入成功!')
try {
fileData = JSON.parse(fileData)
await updateComponent(fileData, true, true)
window['$message'].success('导入成功!')
} catch (error) {
window['$message'].error('组件导入失败,请检查文件完整性!')
}
}
})
})