From 33c05e00eff8f90a2c6176862e97bfd9c492fb60 Mon Sep 17 00:00:00 2001 From: xuqm Date: Mon, 1 Sep 2025 09:16:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E4=BC=98=E5=8C=96=E4=B8=BB?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=B1=8F=E5=B9=95=E5=92=8C=20API=20=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 MainViewScreen 中未使用的类型导入和 Props 类型定义 - 在 useApi 中增加了新的错误处理逻辑,使用 showErrorMessage替代 Toast.show - 优化了登录退出逻辑,增加了对新状态码的处理 --- src/app/screens/main/MainViewScreen.tsx | 6 +----- src/common/api/useApi.ts | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/app/screens/main/MainViewScreen.tsx b/src/app/screens/main/MainViewScreen.tsx index a71dc92..c0c9eb7 100644 --- a/src/app/screens/main/MainViewScreen.tsx +++ b/src/app/screens/main/MainViewScreen.tsx @@ -8,8 +8,6 @@ import { Text, View, } from 'react-native'; -import { StackScreenProps } from '@react-navigation/stack'; -import { MainParamList } from '@app/routes/MainParamList'; import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts'; import { showMessage } from '@common/ToastHelper.ts'; import Alert from '@common/components/Alert.tsx'; @@ -19,9 +17,7 @@ import UpdateManager from '../../../../specs/NativeUpdateManager.ts'; import Spinner from '@common/components/Spinner.tsx'; import RNFS from 'react-native-fs'; -type Props = StackScreenProps; - -export default function WebViewScreen(props: Props) { +export default function WebViewScreen() { const [progress, setProgress] = useState(''); const [progressH, setProgressH] = useState(''); const [isLoading, setLoading] = useState(false); diff --git a/src/common/api/useApi.ts b/src/common/api/useApi.ts index 18ccf16..4a77ccb 100644 --- a/src/common/api/useApi.ts +++ b/src/common/api/useApi.ts @@ -16,10 +16,10 @@ import { z } from 'zod'; import { Platform } from 'react-native'; import { useAuth } from '@common/contexts/useAuth.ts'; import { useCommon } from '@common/contexts/useCommon.ts'; -import Toast from 'react-native-toast-message'; import { getEnvUrl } from '@common/env/envUtils.ts'; import { md5_hex } from '@common/utils/md5'; import { CLIENT_ID, MD5_KEY } from '@common/constants'; +import { showErrorMessage } from '@common/ToastHelper.ts'; const SUCCESS_STATUS = /^0$/; // 请求成功的状态码 @@ -180,8 +180,8 @@ const useApi = < ), ); // 退出登录逻辑 - if (e.response.data?.status === '017x025') { - Toast.show( + if (e.response.data?.status === '017x025'||e.response.data?.status === '017x013') { + showErrorMessage( e.response.data?.message ?? '该账号已在其他设备登录,请重新登录!', );