mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-03-01 07:44:44 +08:00
feat: Implement automatic update checking and user notifications for new versions
This commit is contained in:
@@ -10,6 +10,9 @@ import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { useRemoteControlStore } from "@/stores/remoteControlStore";
|
||||
import LoginModal from "@/components/LoginModal";
|
||||
import useAuthStore from "@/stores/authStore";
|
||||
import { useUpdateStore, initUpdateStore } from "@/stores/updateStore";
|
||||
import { UpdateModal } from "@/components/UpdateModal";
|
||||
import { UPDATE_CONFIG } from "@/constants/UpdateConfig";
|
||||
|
||||
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
@@ -22,9 +25,11 @@ export default function RootLayout() {
|
||||
const { loadSettings, remoteInputEnabled, apiBaseUrl } = useSettingsStore();
|
||||
const { startServer, stopServer } = useRemoteControlStore();
|
||||
const { checkLoginStatus } = useAuthStore();
|
||||
const { checkForUpdate, lastCheckTime } = useUpdateStore();
|
||||
|
||||
useEffect(() => {
|
||||
loadSettings();
|
||||
initUpdateStore(); // 初始化更新存储
|
||||
}, [loadSettings]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,6 +47,17 @@ export default function RootLayout() {
|
||||
}
|
||||
}, [loaded, error]);
|
||||
|
||||
// 检查更新
|
||||
useEffect(() => {
|
||||
if (loaded && UPDATE_CONFIG.AUTO_CHECK && Platform.OS === 'android') {
|
||||
// 检查是否需要自动检查更新
|
||||
const shouldCheck = Date.now() - lastCheckTime > UPDATE_CONFIG.CHECK_INTERVAL;
|
||||
if (shouldCheck) {
|
||||
checkForUpdate(true); // 静默检查
|
||||
}
|
||||
}
|
||||
}, [loaded, lastCheckTime, checkForUpdate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (remoteInputEnabled) {
|
||||
startServer();
|
||||
@@ -68,6 +84,7 @@ export default function RootLayout() {
|
||||
</Stack>
|
||||
<Toast />
|
||||
<LoginModal />
|
||||
<UpdateModal />
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user