Skip to content

Commit 76e4714

Browse files
authored
refactor: add an error message when deleting a model (#369)
1 parent e8ddee3 commit 76e4714

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • src/pages/preference/components/model

src/pages/preference/components/model/index.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ import { join } from '@/utils/path'
1414
const modelStore = useModelStore()
1515
1616
async function handleDelete(item: Model) {
17-
const { id, path } = item
17+
try {
18+
const { id, path } = item
1819
19-
await remove(path, { recursive: true })
20+
await remove(path, { recursive: true })
2021
21-
modelStore.models = modelStore.models.filter(item => item.id !== id)
22+
modelStore.models = modelStore.models.filter(item => item.id !== id)
2223
23-
if (id === modelStore.currentModel?.id) {
24-
modelStore.currentModel = modelStore.models[0]
25-
}
24+
if (id === modelStore.currentModel?.id) {
25+
modelStore.currentModel = modelStore.models[0]
26+
}
2627
27-
message.success('删除成功')
28+
message.success('删除成功')
29+
} catch (error) {
30+
message.error(String(error))
31+
}
2832
}
2933
</script>
3034

0 commit comments

Comments
 (0)