import { observer } from 'mobx-react-lite' import React, { useEffect, useState } from 'react' import { Alert, ScrollView, Text, TouchableOpacity, View } from 'react-native' import { videoUrlCache } from '@/utils/videoUrlCache' interface CacheStats { totalCount: number expiredCount: number validCount: number cacheSize: string } const CacheManagementPage = observer(() => { const [stats, setStats] = useState(null) const [isLoading, setIsLoading] = useState(false) const loadCacheStats = async () => { try { const cacheStats = await videoUrlCache.getStats() setStats(cacheStats) } catch (error) { console.warn('获取缓存统计失败:', error) } } const handleClearCache = () => { Alert.alert('清理缓存', '确定要清理所有视频URL缓存吗?此操作无法撤销。', [ { text: '取消', style: 'cancel' }, { text: '确定', style: 'destructive', onPress: async () => { setIsLoading(true) try { await videoUrlCache.clear() await loadCacheStats() Alert.alert('成功', '缓存已清理') } catch (error) { Alert.alert('失败', '清理缓存失败') console.warn('清理缓存失败:', error) } finally { setIsLoading(false) } }, }, ]) } useEffect(() => { loadCacheStats() }, []) return ( 视频URL缓存统计 {stats ? ( 总缓存数 {stats.totalCount} 有效缓存 {stats.validCount} 过期缓存 {stats.expiredCount} 缓存大小 {stats.cacheSize} ) : ( 加载中... )} 缓存管理 刷新统计 清理所有缓存 💡 提示:缓存会自动清理过期数据,通常不需要手动清理。 缓存有效期为24小时,最多保存200条记录。 ) }) export default CacheManagementPage