From cd71815c970bb20b72ce8a903b9366aca3fc89b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 7 Mar 2026 08:59:52 +0800 Subject: [PATCH] Remove artificial delay from apiError, show toast immediately Co-Authored-By: Claude Opus 4.6 --- src/module/apiError.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/module/apiError.js b/src/module/apiError.js index 23a38c5..77caee8 100644 --- a/src/module/apiError.js +++ b/src/module/apiError.js @@ -6,33 +6,18 @@ // cindy.chang@dsp.im (Cindy Chang), 2024/5/30 /** @module apiError Centralized API error handler with toast notifications. */ -import { useLoadingStore } from '@/stores/loading'; import {useToast} from 'vue-toast-notification'; import 'vue-toast-notification/dist/theme-sugar.css'; /** - * Returns a promise that resolves after the specified milliseconds. - * @param {number} [s=0] - The delay in milliseconds. - * @returns {Promise} A promise that resolves after the delay. - */ -const delay = (s = 0) => new Promise((resolve, reject) => setTimeout(resolve, s)); - -/** - * Handles API errors by showing a loading spinner followed by a toast - * notification. 401 errors are handled by the axios response interceptor + * Handles API errors by showing a toast notification. + * 401 errors are handled by the axios response interceptor * in api/client.js. * * @param {Object} error - The error object from the API call. * @param {string} toastMessage - The message to display in the toast. - * @returns {Promise} */ -export default async function apiError(error, toastMessage) { - const loading = useLoadingStore(); +export default function apiError(error, toastMessage) { const $toast = useToast(); - await delay(); - loading.isLoading = true; - await delay(1000); - loading.isLoading = false; - await delay(500); $toast.default(toastMessage, {position: 'bottom'}); }