feat(app): 更新版本号并添加设备信息相关功能
- 将版本号从"1.0"修改为"1.0.0" - 在主界面添加退出登录功能 - 使用 react-native-device-info 获取设备信息 - 更新 API 请求头中的设备信息获取方式 - 移除 User 类中冗余的 deviceInfo 字段
这个提交包含在:
父节点
2634ead007
当前提交
e575e9deb5
@ -9,10 +9,11 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
# 2. 说明
|
# 2. 说明
|
||||||
> 1. 下证等逻辑放在`common`里面
|
> 1. 使用`jdk17`
|
||||||
> 2. 方法类工具类放在`common`里面
|
> 2. 下证等逻辑放在`common`里面
|
||||||
> 3. 小程序共有的功能点,复用点放在`common`里面
|
> 3. 方法类工具类放在`common`里面
|
||||||
> 4. 避免`common`引用子级(app、miniapp),造成循环依赖
|
> 4. 小程序共有的功能点,复用点放在`common`里面
|
||||||
|
> 5. 避免`common`引用子级(app、miniapp),造成循环依赖
|
||||||
>
|
>
|
||||||
|
|
||||||
# 3. 分包说明
|
# 3. 分包说明
|
||||||
|
|||||||
@ -83,7 +83,7 @@ android {
|
|||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0.0"
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
debug {
|
debug {
|
||||||
|
|||||||
@ -16,12 +16,20 @@ import { downloadToFile } from '@common/UpdateHelper.ts';
|
|||||||
import UpdateManager from '../../../../specs/NativeUpdateManager.ts';
|
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';
|
||||||
|
import { useAuth } from '@common/contexts/useAuth.ts';
|
||||||
|
import DeviceInfo from 'react-native-device-info';
|
||||||
|
|
||||||
export default function MainViewScreen() {
|
export default function MainViewScreen() {
|
||||||
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);
|
||||||
|
|
||||||
|
const {
|
||||||
|
actions: { logout },
|
||||||
|
} = useAuth();
|
||||||
|
|
||||||
|
console.log('>>>>', DeviceInfo.getVersion());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
@ -157,6 +165,13 @@ export default function MainViewScreen() {
|
|||||||
/>
|
/>
|
||||||
<View style={{ height: 45 }} />
|
<View style={{ height: 45 }} />
|
||||||
<Text>{`${RNFS.ExternalDirectoryPath}/bundles/`}</Text>
|
<Text>{`${RNFS.ExternalDirectoryPath}/bundles/`}</Text>
|
||||||
|
<View style={{ height: 55 }} />
|
||||||
|
<Button
|
||||||
|
title={'退出登录'}
|
||||||
|
onPress={() => {
|
||||||
|
logout();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{isLoading && <Spinner />}
|
{isLoading && <Spinner />}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ 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';
|
import { showErrorMessage } from '@common/ToastHelper.ts';
|
||||||
|
import DeviceInfo from 'react-native-device-info';
|
||||||
|
|
||||||
const SUCCESS_STATUS = /^0$/; // 请求成功的状态码
|
const SUCCESS_STATUS = /^0$/; // 请求成功的状态码
|
||||||
|
|
||||||
@ -69,20 +70,14 @@ const useApi = <
|
|||||||
// 【这里添加额外的 headers】
|
// 【这里添加额外的 headers】
|
||||||
const commonHeaders = useMemo(() => {
|
const commonHeaders = useMemo(() => {
|
||||||
try {
|
try {
|
||||||
const deviceInfo = JSON.parse(info.deviceInfo ?? '{}') as Record<
|
|
||||||
string,
|
|
||||||
string
|
|
||||||
>;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clientId: CLIENT_ID, // 厂商唯一标识,这个值是为医网信app分配的
|
clientId: CLIENT_ID, // 厂商唯一标识,这个值是为医网信app分配的
|
||||||
deviceType: Platform.select({ android: '0', ios: '1' }),
|
deviceType: Platform.select({ android: '0', ios: '1' }),
|
||||||
version: deviceInfo.versionName,
|
version: DeviceInfo.getVersion(),
|
||||||
deviceId: deviceInfo.deviceId,
|
deviceId: DeviceInfo.getDeviceId(),
|
||||||
phoneModel: deviceInfo.phoneModel,
|
phoneModel: DeviceInfo.getModel(),
|
||||||
phoneBrand: deviceInfo.phoneBrand,
|
phoneBrand: DeviceInfo.getBrand(),
|
||||||
phoneVersion: deviceInfo.phoneVersion,
|
phoneVersion: DeviceInfo.getSystemVersion(),
|
||||||
|
|
||||||
userId: userInfo?.userId ?? '',
|
userId: userInfo?.userId ?? '',
|
||||||
sessionId: token ?? '',
|
sessionId: token ?? '',
|
||||||
currentClientId: '',
|
currentClientId: '',
|
||||||
@ -91,7 +86,7 @@ const useApi = <
|
|||||||
} catch {
|
} catch {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}, [info.deviceInfo, token, userInfo?.userId]);
|
}, [token, userInfo?.userId]);
|
||||||
|
|
||||||
// 【这里定义 Response 的 schema】
|
// 【这里定义 Response 的 schema】
|
||||||
const responseSchema = useMemo(() => {
|
const responseSchema = useMemo(() => {
|
||||||
@ -180,7 +175,10 @@ const useApi = <
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
// 退出登录逻辑
|
// 退出登录逻辑
|
||||||
if (e.response.data?.status === '017x025'||e.response.data?.status === '017x013') {
|
if (
|
||||||
|
e.response.data?.status === '017x025' ||
|
||||||
|
e.response.data?.status === '017x013'
|
||||||
|
) {
|
||||||
showErrorMessage(
|
showErrorMessage(
|
||||||
e.response.data?.message ??
|
e.response.data?.message ??
|
||||||
'该账号已在其他设备登录,请重新登录!',
|
'该账号已在其他设备登录,请重新登录!',
|
||||||
|
|||||||
@ -5,8 +5,6 @@ export type CommonInfo = {
|
|||||||
policyAccepted: boolean; // 是否已经接受用户协议与隐私政策
|
policyAccepted: boolean; // 是否已经接受用户协议与隐私政策
|
||||||
appTourVersion: string; // 版本引导版本号
|
appTourVersion: string; // 版本引导版本号
|
||||||
lastLoginPhoneNumber: string; // 最近一次登录使用的手机号
|
lastLoginPhoneNumber: string; // 最近一次登录使用的手机号
|
||||||
deviceInfo: string; // 根据 innerModule 中的 initNativeInfo() 获取到的一些设备信息,使用时需要JSON.parse()进行解析
|
|
||||||
// ...
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 登录用户信息
|
// 登录用户信息
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户