powerfun-setting/src/component/UpdateModal.tsx
Caiyanpeng 64beed9c4e 新增自动更新功能,隐藏首页T5骑行台入口
① 新增自动更新功能(UpdateModal),HomeScreen接入版本检测
② LanguageModal 添加 statusBarTranslucent 浸润样式
③ 首页T5骑行台入口注释隐藏
④ 版本号从 1.0.1 升级至 1.0.2
⑤ 多语言文件更新(en.json, zh.json)
⑥ 新增 CLAUDE.md 项目说明文档
⑦ 更新 yarn.lock 依赖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-11 09:18:11 +08:00

136 lines
3.4 KiB
TypeScript

import React from "react";
import { View, Text, TouchableOpacity, StyleSheet, Modal, Linking } from "react-native";
import { useTranslation } from "react-i18next";
import pxToDp from "../helper/pxToDp";
interface UpdateModalProps {
visible: boolean;
updateInfo: {
latestVersion: string;
downloadUrl: string;
updateLogs: string[];
} | null;
currentVersion: string;
onClose: () => void;
}
export default function UpdateModal({ visible, updateInfo, currentVersion, onClose }: UpdateModalProps) {
const { t } = useTranslation();
const handleUpdatePress = () => {
if (updateInfo?.downloadUrl) {
Linking.openURL(updateInfo.downloadUrl);
}
};
if (!updateInfo) return null;
return (
<Modal
visible={visible}
transparent={true}
animationType="fade"
onRequestClose={onClose}
statusBarTranslucent
>
<View style={styles.modalOverlay}>
<View style={styles.modalContent}>
<Text style={styles.modalTitle}>{t("home.updateTitle")}</Text>
<Text style={styles.modalVersion}>
{t("home.latestVersion")}: {updateInfo.latestVersion}
</Text>
<Text style={styles.modalVersion}>
{t("home.currentVersion")}: {currentVersion}
</Text>
<View style={styles.updateLogsContainer}>
<Text style={styles.updateLogsTitle}>{t("home.updateLogs")}</Text>
{updateInfo.updateLogs.map((log, index) => (
<Text key={index} style={styles.updateLogItem}> {log}</Text>
))}
</View>
<TouchableOpacity
style={styles.updateButton}
onPress={handleUpdatePress}
>
<Text style={styles.updateButtonText}>{t("home.updateNow")}</Text>
</TouchableOpacity>
{/* <TouchableOpacity
style={styles.laterButton}
onPress={onClose}
>
<Text style={styles.laterButtonText}>{t("home.updateLater")}</Text>
</TouchableOpacity> */}
</View>
</View>
</Modal>
);
}
const styles = StyleSheet.create({
modalOverlay: {
flex: 1,
backgroundColor: "rgba(0, 0, 0, 0.5)",
justifyContent: "center",
alignItems: "center",
},
modalContent: {
width: pxToDp(600),
backgroundColor: "#fff",
borderRadius: pxToDp(20),
padding: pxToDp(40),
alignItems: "center",
},
modalTitle: {
fontSize: pxToDp(36),
fontWeight: "bold",
color: "#333",
marginBottom: pxToDp(20),
},
modalVersion: {
fontSize: pxToDp(28),
color: "#666",
marginBottom: pxToDp(10),
},
updateLogsContainer: {
width: "100%",
marginTop: pxToDp(20),
marginBottom: pxToDp(20),
paddingHorizontal: pxToDp(10),
maxHeight: pxToDp(300),
},
updateLogsTitle: {
fontSize: pxToDp(28),
fontWeight: "bold",
color: "#333",
marginBottom: pxToDp(10),
},
updateLogItem: {
fontSize: pxToDp(24),
color: "#666",
lineHeight: pxToDp(40),
},
updateButton: {
width: "100%",
backgroundColor: "#E7141E",
borderRadius: pxToDp(12),
padding: pxToDp(24),
alignItems: "center",
// marginBottom: pxToDp(20),
},
updateButtonText: {
fontSize: pxToDp(32),
fontWeight: "bold",
color: "#fff",
},
laterButton: {
padding: pxToDp(20),
},
laterButtonText: {
fontSize: pxToDp(28),
color: "#999",
},
});