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 }, negativeButtonProps: { type: 'info', ghost: false },
// 新增 // 新增
onPositiveCallback: async () => { onPositiveCallback: async () => {
fileData = JSON.parse(fileData) try {
await updateComponent(fileData, false, true) fileData = JSON.parse(fileData)
window['$message'].success('导入成功!') await updateComponent(fileData, false, true)
window['$message'].success('导入成功!')
} catch (error) {
window['$message'].error('组件导入失败,请检查文件完整性!')
}
}, },
// 覆盖 // 覆盖
onNegativeCallback: async () => { onNegativeCallback: async () => {
fileData = JSON.parse(fileData) try {
await updateComponent(fileData, true, true) fileData = JSON.parse(fileData)
window['$message'].success('导入成功!') await updateComponent(fileData, true, true)
window['$message'].success('导入成功!')
} catch (error) {
window['$message'].error('组件导入失败,请检查文件完整性!')
}
} }
}) })
}) })