From 7df0a8404c167e4fc60342e5e5d77cd108eba446 Mon Sep 17 00:00:00 2001 From: Tnze Date: Mon, 7 Oct 2024 07:58:38 +0800 Subject: [PATCH] Add error handling for remote recipe selecting --- src/components/recipe-manager/RecipePanel.vue | 9 ++++++++- src/components/recipe-manager/local-source.ts | 4 ---- src/components/recipe-manager/web-source.ts | 4 ---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/recipe-manager/RecipePanel.vue b/src/components/recipe-manager/RecipePanel.vue index d8bfa8f4..3bcc2f0c 100644 --- a/src/components/recipe-manager/RecipePanel.vue +++ b/src/components/recipe-manager/RecipePanel.vue @@ -151,7 +151,14 @@ onMounted(async () => { ElMessage.error($t("datasource-unsupport-recipe-info")); return; } - const recipeInfo = await source.recipeInfo(recipeId); + try { + isRecipeTableLoading.value = true; + var recipeInfo = await source.recipeInfo(recipeId); + } catch (e: any) { + ElMessage.error(String(e)); + isRecipeTableLoading.value = false; + return; + } await selectRecipeRow(recipeInfo); } }); diff --git a/src/components/recipe-manager/local-source.ts b/src/components/recipe-manager/local-source.ts index c5c261f0..db194d71 100644 --- a/src/components/recipe-manager/local-source.ts +++ b/src/components/recipe-manager/local-source.ts @@ -48,10 +48,6 @@ export class LocalRecipeSource { return result } - async recipeInfo(recipeId: number): Promise { - throw "todo" - } - async itemInfo(itemId: number): Promise { const { id, name, level, can_be_hq, category_id } = await (await this.invoke)("item_info", { itemId }) as { id: number, diff --git a/src/components/recipe-manager/web-source.ts b/src/components/recipe-manager/web-source.ts index 3486e5a4..69b4c722 100644 --- a/src/components/recipe-manager/web-source.ts +++ b/src/components/recipe-manager/web-source.ts @@ -78,10 +78,6 @@ export class WebSource { return result } - async recipeInfo(recipeId: number): Promise { - throw "todo" - } - async itemInfo(itemId: number): Promise { const query = new URLSearchParams({ 'item_id': String(itemId) }) const url = new URL("item_info", this.base).toString() + '?' + query.toString();