fix(update): resolve APK download path issue and enhance update components

- Fix UpdateService to use DocumentDir instead of DownloadDir for APK storage
- Add retry mechanism for network failures in version checking and downloading
- Implement automatic cleanup of old APK files to manage storage
- Replace TouchableOpacity with StyledButton in UpdateModal for consistency
- Add TV focus control to UpdateSection component
- Reduce category button spacing on TV for better navigation
- Update download URL template to match release naming convention
This commit is contained in:
zimplexing
2025-08-13 17:19:48 +08:00
parent 9e9e4597cc
commit f0c797434d
7 changed files with 241 additions and 228 deletions

View File

@@ -6,15 +6,8 @@ import { useUpdateStore } from "@/stores/updateStore";
import { UPDATE_CONFIG } from "@/constants/UpdateConfig";
export function UpdateSection() {
const {
currentVersion,
remoteVersion,
updateAvailable,
downloading,
downloadProgress,
checkForUpdate,
setShowUpdateModal,
} = useUpdateStore();
const { currentVersion, remoteVersion, updateAvailable, downloading, downloadProgress, checkForUpdate } =
useUpdateStore();
const [checking, setChecking] = React.useState(false);
@@ -30,7 +23,7 @@ export function UpdateSection() {
return (
<View style={styles.sectionContainer}>
<ThemedText style={styles.sectionTitle}></ThemedText>
<View style={styles.row}>
<ThemedText style={styles.label}></ThemedText>
<ThemedText style={styles.value}>v{currentVersion}</ThemedText>
@@ -39,9 +32,7 @@ export function UpdateSection() {
{updateAvailable && (
<View style={styles.row}>
<ThemedText style={styles.label}></ThemedText>
<ThemedText style={[styles.value, styles.newVersion]}>
v{remoteVersion}
</ThemedText>
<ThemedText style={[styles.value, styles.newVersion]}>v{remoteVersion}</ThemedText>
</View>
)}
@@ -53,26 +44,13 @@ export function UpdateSection() {
)}
<View style={styles.buttonContainer}>
<StyledButton
onPress={handleCheckUpdate}
disabled={checking || downloading}
style={styles.button}
>
<StyledButton onPress={handleCheckUpdate} disabled={checking || downloading} style={styles.button}>
{checking ? (
<ActivityIndicator color="#fff" size="small" />
) : (
<ThemedText style={styles.buttonText}></ThemedText>
)}
</StyledButton>
{updateAvailable && !downloading && (
<StyledButton
onPress={() => setShowUpdateModal(true)}
style={[styles.button, styles.updateButton]}
>
<ThemedText style={styles.buttonText}></ThemedText>
</StyledButton>
)}
</View>
{UPDATE_CONFIG.AUTO_CHECK && (
@@ -99,6 +77,7 @@ const styles = StyleSheet.create({
fontSize: Platform.isTV ? 24 : 20,
fontWeight: "bold",
marginBottom: 16,
paddingTop: 8,
},
row: {
flexDirection: "row",
@@ -121,12 +100,16 @@ const styles = StyleSheet.create({
flexDirection: "row",
gap: 12,
marginTop: 16,
justifyContent: "center", // 居中对齐
alignItems: "center",
},
button: {
flex: 1,
},
updateButton: {
backgroundColor: "#00bb5e",
width: "90%",
...(Platform.isTV && {
// TV平台焦点样式
borderWidth: 2,
borderColor: "transparent",
}),
},
buttonText: {
color: "#ffffff",
@@ -139,4 +122,4 @@ const styles = StyleSheet.create({
marginTop: 12,
textAlign: "center",
},
});
});