feat: 去掉热更新

This commit is contained in:
2025-12-06 12:33:12 +08:00
parent eef0134ddc
commit 409f125db1
3 changed files with 418 additions and 1210 deletions

View File

@@ -23,7 +23,6 @@ import { DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { useFonts } from 'expo-font';
import { Stack, useRouter } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import * as Updates from 'expo-updates';
import React, { useEffect } from 'react';
import { AppState, AppStateStatus } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
@@ -486,47 +485,49 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
}, []);
// 使用 ref 确保更新检查只执行一次
const updateCheckRequestedRef = React.useRef(false);
// const updateCheckRequestedRef = React.useRef(false);
useEffect(() => {
// 如果已经执行过更新检查,直接返回
if (updateCheckRequestedRef.current) {
return;
}
// useEffect(() => {
// // 如果已经执行过更新检查,直接返回
// if (updateCheckRequestedRef.current) {
// return;
// }
updateCheckRequestedRef.current = true;
// updateCheckRequestedRef.current = true;
async function checkUpdate() {
try {
logger.info(`Checking for updates..., env: ${__DEV__}, Updates.isEnabled: ${Updates.isEnabled}`);
// async function checkUpdate() {
// try {
// logger.info(`Checking for updates..., env: ${__DEV__}, Updates.isEnabled: ${Updates.isEnabled}`);
// 只有在 expo-updates 启用时才检查更新
// 开发环境或 Updates 未启用时跳过
if (__DEV__ || !Updates.isEnabled) {
logger.info('Skipping update check: dev mode or updates not enabled');
return;
}
// // 只有在 expo-updates 启用时才检查更新
// // 开发环境或 Updates 未启用时跳过
// if (__DEV__ || !Updates.isEnabled) {
// logger.info('Skipping update check: dev mode or updates not enabled');
// return;
// }
const update = await Updates.checkForUpdateAsync();
logger.info("Update check:", update);
// const update = await Updates.checkForUpdateAsync();
// logger.info("Update check:", update);
if (update.isAvailable) {
logger.info("Update available, fetching...");
const result = await Updates.fetchUpdateAsync();
logger.info("Fetch result:", result);
// if (update.isAvailable) {
// logger.info("Update available, fetching...");
// const result = await Updates.fetchUpdateAsync();
// logger.info("Fetch result:", result);
if (result.isNew) {
logger.info("Reloading app to apply update...");
await Updates.reloadAsync();
}
}
} catch (e) {
logger.error("Update error:", e);
}
}
// if (result.isNew) {
// logger.info("Reloading app to apply update...");
// await Updates.reloadAsync();
// }
// }
// } catch (e) {
// logger.error("Update error:", e);
// }
// }
checkUpdate();
}, []);
// setTimeout(() => {
// checkUpdate();
// }, 5000);
// }, []);
const handlePrivacyAgree = () => {
dispatch(setPrivacyAgreed());