From c7fbc1f44131c31ab0a163c08e7082a0b397d4d0 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 25 Mar 2026 12:51:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=A1=B5UI=E4=BA=A4=E4=BA=92=E3=80=81=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9A=97=E9=BB=91=E4=B8=BB=E9=A2=98=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=20header=20=E5=BA=95=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - downloads.tsx: 删除前弹 Alert 确认框(区分"取消下载"和"删除文件") - downloads.tsx: 下载出错时显示"重新下载"按钮,跳转视频详情页 - downloads.tsx: 下载中取消按钮改为 close-circle-outline 图标 - downloads.tsx: 已完成条目整行可点击播放,移除单独"播放"按钮 - downloads.tsx: 播放器横竖屏均显示顶部控制栏,点击切换显隐 - downloads.tsx: 移除进度条旁 ActivityIndicator,保留百分比文字 - downloads.tsx: 全部颜色跟随暗黑主题(bg/card/text/textSub/border) - index.tsx: 移除悬浮 header 底部分割线 --- app/downloads.tsx | 165 +++++++++++++++++++++++-------------- app/index.tsx | 3 - app/video/[bvid].tsx | 18 ++-- components/DanmakuList.tsx | 5 +- 4 files changed, 119 insertions(+), 72 deletions(-) diff --git a/app/downloads.tsx b/app/downloads.tsx index 0f19eaf..51dccf2 100644 --- a/app/downloads.tsx +++ b/app/downloads.tsx @@ -6,10 +6,10 @@ import { StyleSheet, TouchableOpacity, Image, - ActivityIndicator, Modal, StatusBar, useWindowDimensions, + Alert, } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useRouter } from 'expo-router'; @@ -19,6 +19,8 @@ let ScreenOrientation: typeof import('expo-screen-orientation') | null = null; try { ScreenOrientation = require('expo-screen-orientation'); } catch {} import { useDownloadStore, DownloadTask } from '../store/downloadStore'; import { LanShareModal } from '../components/LanShareModal'; +import { proxyImageUrl } from '../utils/imageUrl'; +import { useTheme } from '../utils/theme'; function formatFileSize(bytes?: number): string { if (!bytes || bytes <= 0) return ''; @@ -26,8 +28,6 @@ function formatFileSize(bytes?: number): string { if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`; } -import { proxyImageUrl } from '../utils/imageUrl'; -import { useTheme } from '../utils/theme'; export default function DownloadsScreen() { const router = useRouter(); @@ -36,12 +36,14 @@ export default function DownloadsScreen() { const [playingUri, setPlayingUri] = useState(null); const [playingTitle, setPlayingTitle] = useState(''); const [shareTask, setShareTask] = useState<(DownloadTask & { key: string }) | null>(null); + const [showControls, setShowControls] = useState(true); const { width, height } = useWindowDimensions(); const isLandscape = width > height; async function openPlayer(uri: string, title: string) { setPlayingTitle(title); setPlayingUri(uri); + setShowControls(true); await ScreenOrientation?.unlockAsync(); } @@ -50,6 +52,18 @@ export default function DownloadsScreen() { await ScreenOrientation?.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP); } + function confirmDelete(key: string, status: DownloadTask['status']) { + const isDownloading = status === 'downloading'; + Alert.alert( + isDownloading ? '取消下载' : '删除下载', + isDownloading ? '确定取消该下载任务?' : '确定删除该文件?删除后不可恢复。', + [ + { text: '取消', style: 'cancel' }, + { text: isDownloading ? '取消下载' : '删除', style: 'destructive', onPress: () => removeTask(key) }, + ], + ); + } + useEffect(() => { loadFromStorage(); }, []); @@ -74,29 +88,33 @@ export default function DownloadsScreen() { {sections.length === 0 ? ( - - 暂无下载记录 + + 暂无下载记录 ) : ( item.key} renderSectionHeader={({ section }) => ( - - {section.title} + + {section.title} )} renderItem={({ item }) => ( { if (item.localUri) openPlayer(item.localUri, item.title); }} - onDelete={() => removeTask(item.key)} + onDelete={() => confirmDelete(item.key, item.status)} onShare={() => setShareTask(item)} + onRetry={() => router.push(`/video/${item.bvid}` as any)} /> )} - ItemSeparatorComponent={() => } + ItemSeparatorComponent={() => ( + + )} contentContainerStyle={{ paddingBottom: 32 }} /> )} @@ -115,27 +133,29 @@ export default function DownloadsScreen() { onRequestClose={closePlayer} >