From 79a8dae49fad7393175ec22c9c5082b7c9287091 Mon Sep 17 00:00:00 2001 From: km2025 Date: Tue, 20 Jan 2026 15:36:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20VideoBox=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=AD=20imageRef=20=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AE=9A=E4=B9=89=EF=BC=8C=E9=81=BF=E5=85=8D=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E7=A9=BA=E5=BC=95=E7=94=A8=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=9B=E4=BC=98=E5=8C=96=20Sync=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=20itemWidth=20=E8=AE=A1=E7=AE=97=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @share/components/Video.tsx | 2 +- AGENTS.md | 4 ++++ app/(tabs)/index.tsx | 33 ++++++++++++--------------------- app/(tabs)/sync.tsx | 11 +++++------ 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/@share/components/Video.tsx b/@share/components/Video.tsx index 01bc084..f6a378e 100644 --- a/@share/components/Video.tsx +++ b/@share/components/Video.tsx @@ -16,7 +16,7 @@ type Props = { // 默认宽度256半屏宽度 const VideoBox = ({ url, needWeb = true, width = 256, style, autoplay = true, ...videoProps }: Props) => { const [urlFinal, setUrlFinal] = useState('') - const imageRef = useRef(null) + const imageRef = useRef(null) const createUrl = (url: string) => { return `https://modal-dev.bowong.cc/api/custom/video/converter/v2?media_url=${encodeURI(url)}&options=compression_level=3,quality=70,loop=true,resolution=${width}x${width},fps=24` diff --git a/AGENTS.md b/AGENTS.md index d6ab3c2..5da0847 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,3 +38,7 @@ Use `bun` as the package manager (`package.json` `packageManager`). ## Configuration & Environment - Environment files live in `.env.*` and are loaded with `dotenv` in scripts. - Build profiles and OTA channels live in `eas.json`; do not commit secrets. + + +## rule +Always use Context7 MCP when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask. \ No newline at end of file diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 2b30eba..31abf0a 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,6 +1,6 @@ import { Ionicons } from '@expo/vector-icons' import { useIsFocused } from '@react-navigation/native' -import { Block, ConfirmModal, Img, ListEmpty, Text, Toast, VideoBox } from '@share/components' +import { Block, ConfirmModal, Img, ListEmpty, Text, Toast } from '@share/components' import { FlashList } from '@shopify/flash-list' import { Image } from 'expo-image' import { LinearGradient } from 'expo-linear-gradient' @@ -385,10 +385,10 @@ const Index = observer(function Index() { if (first !== null && last !== null) { // 每列3个,所以前后各加3行(9个item) - for (let i = Math.max(0, first - 9); i < first; i++) { + for (let i = Math.max(0, first - 6); i < first; i++) { if (allItems[i]) currentVisible.add(allItems[i].id) } - for (let i = last + 1; i < Math.min(allItems.length, last + 10); i++) { + for (let i = last + 1; i < Math.min(allItems.length, last - 6); i++) { currentVisible.add(allItems[i].id) } } @@ -447,11 +447,12 @@ const Index = observer(function Index() { } numColumns={3} onEndReached={handleLoadMore} - // 设置合理的回收池大小,避免内存无限增长 - maxItemsInRecyclePool={12} + // 设置合理的回收池大小,复用组件实例以提高性能 + maxItemsInRecyclePool={0} + // 自动移除不可见的原生视图,停止渲染和解码 removeClippedSubviews={true} // 减小预渲染距离,降低内存占用 - drawDistance={150} + drawDistance={300} onEndReachedThreshold={0.3} refreshControl={} renderItem={renderItem} @@ -461,7 +462,7 @@ const Index = observer(function Index() { viewabilityConfig={{ itemVisiblePercentThreshold: 10, minimumViewTime: 50, - waitForInteraction: false, + waitForInteraction: true, }} showsVerticalScrollIndicator={false} data={allItems} @@ -583,26 +584,16 @@ const HeroCircle = observer(function HeroCircle({ selectedItem, const { balance } = userBalanceStore const Width = 216 - const previewUrl = selectedItem?.webpHighPreviewUrl || selectedItem?.url || '' - - const existItem = !!selectedItem?.url + const previewUrl = selectedItem?.webpHighPreviewUrl || selectedItem?.webpPreviewUrl || '' return ( - {existItem && ( - - - - )} - - {!existItem && ( - - 加载中... - - )} + + + diff --git a/app/(tabs)/sync.tsx b/app/(tabs)/sync.tsx index 3ecc429..777aff8 100644 --- a/app/(tabs)/sync.tsx +++ b/app/(tabs)/sync.tsx @@ -20,6 +20,8 @@ import { screenWidth, uploadFile } from '@/utils' import { cn } from '@/utils/cn' import { extractCdnKey } from '@/utils/getCDNKey' +const ITEM_WIDTH = Math.floor((screenWidth - 12 * 2 - 12 * 2) / 3) + // ============ 主组件 ============ const Sync = observer(() => { // 从MobX Store获取用户信息 @@ -53,8 +55,6 @@ const Sync = observer(() => { const { connectedDevice, isScanning, transferProgress } = bleStore.state - const itemWidth = Math.floor((screenWidth - 12 * 2 - 12 * 2) / 3) - useFocusEffect(() => { if (!isAuthenticated) { router.replace('/') @@ -382,16 +382,15 @@ const Sync = observer(() => { ) }, - [isSelectionMode, selectedIds, selectedItem, itemWidth, handleItemSelect, isFocused], + [isSelectionMode, selectedIds, selectedItem, handleItemSelect, isFocused], ) return ( @@ -403,8 +402,8 @@ const Sync = observer(() => { contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: 200 }} data={posts} drawDistance={300} + maxItemsInRecyclePool={0} removeClippedSubviews={true} - getItemType={() => 'row'} ItemSeparatorComponent={() => } keyExtractor={(item: any) => item?.id || `fallback-${Math.random()}`} ListFooterComponent={ListFooter}