feat: update

This commit is contained in:
2025-11-05 17:24:55 +08:00
parent 61252cdf36
commit ce324c9bb5
42 changed files with 2078 additions and 448 deletions

View File

@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { StyleSheet, TouchableOpacity, Alert, ActivityIndicator } from 'react-native';
import * as Updates from 'expo-updates';
@@ -24,23 +24,19 @@ export default function TabOneScreen() {
setUpdateInfo('发现新版本,正在下载...');
await Updates.fetchUpdateAsync();
Alert.alert(
'更新完成',
'新版本已下载完成,是否立即重启应用?',
[
{
text: '稍后',
style: 'cancel',
onPress: () => setUpdateInfo('更新已下载,稍后重启应用即可应用'),
Alert.alert('更新完成', '新版本已下载完成,是否立即重启应用?', [
{
text: '稍后',
style: 'cancel',
onPress: () => setUpdateInfo('更新已下载,稍后重启应用即可应用'),
},
{
text: '立即重启',
onPress: async () => {
await Updates.reloadAsync();
},
{
text: '立即重启',
onPress: async () => {
await Updates.reloadAsync();
},
},
]
);
},
]);
} else {
setUpdateInfo('当前已是最新版本');
}
@@ -53,13 +49,8 @@ export default function TabOneScreen() {
};
const getUpdateInfo = () => {
const {
isEmbeddedLaunch,
isEmergencyLaunch,
updateId,
channel,
runtimeVersion,
} = Updates.useUpdates();
const { isEmbeddedLaunch, isEmergencyLaunch, updateId, channel, runtimeVersion } =
Updates.useUpdates();
return `
运行模式: ${__DEV__ ? '开发模式' : '生产模式'}
@@ -71,6 +62,10 @@ export default function TabOneScreen() {
`.trim();
};
useEffect(() => {
console.log('=== TabOneScreen 组件已渲染 ===');
}, []);
return (
<View style={styles.container}>
<Text style={styles.title}>🚀 </Text>