mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useRemoteControlStore } from "@/stores/remoteControlStore";
|
||||
import { APIConfigSection } from "@/components/settings/APIConfigSection";
|
||||
import { LiveStreamSection } from "@/components/settings/LiveStreamSection";
|
||||
import { RemoteInputSection } from "@/components/settings/RemoteInputSection";
|
||||
import { UpdateSection } from "@/components/settings/UpdateSection";
|
||||
// import { VideoSourceSection } from "@/components/settings/VideoSourceSection";
|
||||
import Toast from "react-native-toast-message";
|
||||
|
||||
@@ -122,7 +123,13 @@ export default function SettingsScreen() {
|
||||
// ),
|
||||
// key: "videoSource",
|
||||
// },
|
||||
];
|
||||
Platform.OS === 'android' && {
|
||||
component: (
|
||||
<UpdateSection />
|
||||
),
|
||||
key: "update",
|
||||
},
|
||||
].filter(Boolean);
|
||||
|
||||
// TV遥控器事件处理
|
||||
const handleTVEvent = React.useCallback(
|
||||
|
||||
Reference in New Issue
Block a user