feat:热更新

This commit is contained in:
Developer
2026-03-20 14:06:52 +08:00
parent 4a69a8ed1d
commit 38fc41f184
8 changed files with 278 additions and 21 deletions

View File

@@ -1,15 +1,17 @@
import React from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { View, Text, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useRouter } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';
import { useAuthStore } from '../store/authStore';
import { useSettingsStore } from '../store/settingsStore';
import { useCheckUpdate } from '../hooks/useCheckUpdate';
export default function SettingsScreen() {
const router = useRouter();
const { isLoggedIn, logout } = useAuthStore();
const { coverQuality, setCoverQuality } = useSettingsStore();
const { currentVersion, isChecking, downloadProgress, checkUpdate } = useCheckUpdate();
const handleLogout = async () => {
await logout();
@@ -26,6 +28,35 @@ export default function SettingsScreen() {
<View style={styles.spacer} />
</View>
<View style={styles.section}>
<Text style={styles.sectionLabel}></Text>
<View style={styles.versionRow}>
<Text style={styles.versionLabel}></Text>
<Text style={styles.versionValue}>v{currentVersion}</Text>
</View>
</View>
<View style={styles.section}>
<Text style={styles.sectionLabel}></Text>
<TouchableOpacity
style={styles.updateBtn}
onPress={checkUpdate}
activeOpacity={0.7}
disabled={isChecking || downloadProgress !== null}
>
{isChecking ? (
<>
<ActivityIndicator size="small" color="#00AEEC" style={{ marginRight: 8 }} />
<Text style={styles.updateBtnText}>...</Text>
</>
) : downloadProgress !== null ? (
<Text style={styles.updateBtnText}> {downloadProgress}%</Text>
) : (
<Text style={styles.updateBtnText}></Text>
)}
</TouchableOpacity>
</View>
<View style={styles.section}>
<Text style={styles.sectionLabel}></Text>
<View style={styles.optionRow}>
@@ -102,6 +133,19 @@ const styles = StyleSheet.create({
optionActive: { borderColor: '#00AEEC', backgroundColor: '#e8f7fd' },
optionText: { fontSize: 14, color: '#666' },
optionTextActive: { color: '#00AEEC', fontWeight: '600' },
versionRow: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
versionLabel: { fontSize: 14, color: '#212121' },
versionValue: { fontSize: 14, color: '#999' },
updateBtn: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 6,
},
updateBtnText: { fontSize: 14, color: '#00AEEC', fontWeight: '600' },
logoutBtn: {
margin: 24,
paddingVertical: 12,