refactor(app): 优化主视图屏幕和 API 请求逻辑
- 移除了 MainViewScreen 中未使用的类型导入和 Props 类型定义 - 在 useApi 中增加了新的错误处理逻辑,使用 showErrorMessage替代 Toast.show - 优化了登录退出逻辑,增加了对新状态码的处理
这个提交包含在:
父节点
5400f38946
当前提交
33c05e00ef
@ -8,8 +8,6 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { StackScreenProps } from '@react-navigation/stack';
|
|
||||||
import { MainParamList } from '@app/routes/MainParamList';
|
|
||||||
import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
|
import { Apps, NavigationPushByName } from '@common/NavigationHelper.ts';
|
||||||
import { showMessage } from '@common/ToastHelper.ts';
|
import { showMessage } from '@common/ToastHelper.ts';
|
||||||
import Alert from '@common/components/Alert.tsx';
|
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 Spinner from '@common/components/Spinner.tsx';
|
||||||
import RNFS from 'react-native-fs';
|
import RNFS from 'react-native-fs';
|
||||||
|
|
||||||
type Props = StackScreenProps<MainParamList, 'MainView'>;
|
export default function WebViewScreen() {
|
||||||
|
|
||||||
export default function WebViewScreen(props: Props) {
|
|
||||||
const [progress, setProgress] = useState('');
|
const [progress, setProgress] = useState('');
|
||||||
const [progressH, setProgressH] = useState('');
|
const [progressH, setProgressH] = useState('');
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|||||||
@ -16,10 +16,10 @@ import { z } from 'zod';
|
|||||||
import { Platform } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
import { useAuth } from '@common/contexts/useAuth.ts';
|
import { useAuth } from '@common/contexts/useAuth.ts';
|
||||||
import { useCommon } from '@common/contexts/useCommon.ts';
|
import { useCommon } from '@common/contexts/useCommon.ts';
|
||||||
import Toast from 'react-native-toast-message';
|
|
||||||
import { getEnvUrl } from '@common/env/envUtils.ts';
|
import { getEnvUrl } from '@common/env/envUtils.ts';
|
||||||
import { md5_hex } from '@common/utils/md5';
|
import { md5_hex } from '@common/utils/md5';
|
||||||
import { CLIENT_ID, MD5_KEY } from '@common/constants';
|
import { CLIENT_ID, MD5_KEY } from '@common/constants';
|
||||||
|
import { showErrorMessage } from '@common/ToastHelper.ts';
|
||||||
|
|
||||||
const SUCCESS_STATUS = /^0$/; // 请求成功的状态码
|
const SUCCESS_STATUS = /^0$/; // 请求成功的状态码
|
||||||
|
|
||||||
@ -180,8 +180,8 @@ const useApi = <
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
// 退出登录逻辑
|
// 退出登录逻辑
|
||||||
if (e.response.data?.status === '017x025') {
|
if (e.response.data?.status === '017x025'||e.response.data?.status === '017x013') {
|
||||||
Toast.show(
|
showErrorMessage(
|
||||||
e.response.data?.message ??
|
e.response.data?.message ??
|
||||||
'该账号已在其他设备登录,请重新登录!',
|
'该账号已在其他设备登录,请重新登录!',
|
||||||
);
|
);
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户