From 77e246198faee3e37f33a6f95227cb4a062dc3b4 Mon Sep 17 00:00:00 2001 From: speakeloudest Date: Thu, 14 Aug 2025 22:34:44 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(main)/(content)/(user)/dashboard/content.tsx | 1 + apps/user/components/main/OfferDialog/index.tsx | 2 +- apps/user/utils/request.ts | 13 ++++++++++++- packages/airo-ui/src/components/sidebar.tsx | 10 ++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx b/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx index a6e363d..2c50920 100644 --- a/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx +++ b/apps/user/app/(main)/(content)/(user)/dashboard/content.tsx @@ -247,6 +247,7 @@ export default function Content() { {announcementData?.map((item) => { return (

((props, ref) => {

diff --git a/apps/user/utils/request.ts b/apps/user/utils/request.ts index da2486e..f56d6ad 100644 --- a/apps/user/utils/request.ts +++ b/apps/user/utils/request.ts @@ -7,7 +7,18 @@ import { getAuthorization, Logout } from './common'; async function handleError(response: any) { const code = response.data?.code; - if ([40002, 40003, 40004, 40005].includes(code)) return Logout(); + console.log(1111111, code); + if ([40002, 40003, 40004, 40005].includes(code)) { + if (isBrowser()) { + const t = await getTranslations('common'); + const message = + t(`request.${code}`) !== `request.${code}` + ? t(`request.${code}`) + : response.data?.msg || response.message; + toast.error(message); + } + return Logout(); + } if (response?.config?.skipErrorHandler) return; if (!isBrowser()) return; diff --git a/packages/airo-ui/src/components/sidebar.tsx b/packages/airo-ui/src/components/sidebar.tsx index 8578a68..464c20b 100644 --- a/packages/airo-ui/src/components/sidebar.tsx +++ b/packages/airo-ui/src/components/sidebar.tsx @@ -52,8 +52,14 @@ const SidebarContext = React.createContext(SAFE_SIDEBAR_CONTEXT) function useSidebar() { const context = React.useContext(SidebarContext); // Optionally warn in development when using the safe fallback - if (process.env.NODE_ENV !== 'production' && context === SAFE_SIDEBAR_CONTEXT) { - console.warn('useSidebar is used outside of a SidebarProvider. Falling back to no-op context.'); + if (!context) { + return { + toggleSidebar: () => { + console.warn( + 'useSidebar is used outside of a SidebarProvider. Falling back to no-op context.', + ); + }, + }; // 提供默認空函數,防止首頁報錯 } return context; }