diff --git a/@share/components/Toast.tsx b/@share/components/Toast.tsx index 7abd5a4..5123009 100644 --- a/@share/components/Toast.tsx +++ b/@share/components/Toast.tsx @@ -20,6 +20,7 @@ interface ShowParams { title?: string duration?: number hideBackdrop?: boolean + onBackButtonPress?: () => void } interface ShowActionSheetParams { @@ -95,7 +96,7 @@ const Toast = (function () { // loading let loadingTimer: ReturnType | null = null const showLoading = (params?: ShowParams): void => { - const { renderContent, title, duration = 1500, hideBackdrop = false } = params || {} + const { renderContent, title, duration = 1500, hideBackdrop = false, onBackButtonPress = undefined } = params || {} hideLoading() const renderBody = (): ReactNode => { @@ -126,6 +127,7 @@ const Toast = (function () { hideBackdrop, backdropColor: 'rgba(0,0,0,0.4)', onBackdropPress: () => {}, + onBackButtonPress: onBackButtonPress, entering: false, exiting: false, }, diff --git a/@share/components/Video.tsx b/@share/components/Video.tsx index a2caccd..0462837 100644 --- a/@share/components/Video.tsx +++ b/@share/components/Video.tsx @@ -41,6 +41,10 @@ const VideoBox = ({ return lowerUrl?.match(/\.(jpg|jpeg|png|gif|webp|bmp|tiff|svg)(\?.*)?$/i) } + // / 本地文件全部用video组件播放 + const isLocal = !url.startsWith('http://') && !url.startsWith('https://') + const isImageFile = isImg(url) + const setRedirectUrl = async (isCancelled: () => boolean, url?: string) => { const isImg2 = isImg(url) if (isImg2) { @@ -85,7 +89,7 @@ const VideoBox = ({ useEffect(() => { // 每次url变化强制刷新 setUrlFinal('') - if (!url) { + if (!url || isLocal) { return } @@ -127,10 +131,6 @@ const VideoBox = ({ if (!url) return null - // 本地文件全部用video组件播放 - const isLocal = !url.startsWith('http://') && !url.startsWith('https://') - const isImageFile = isImg(url) - if (isLocal) { if (!isImageFile) { return ( @@ -182,7 +182,7 @@ const VideoBox = ({ { url: `https://u.expo.dev/${PROJECT_ID}`, fallbackToCacheTimeout: 0, checkAutomatically: 'NEVER', + channel: 'test', }, }, } diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index f5c6e0a..87a2481 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -717,7 +717,7 @@ const GridItem = memo(function GridItem({ item, isSelected, itemW { const coverUrl = gen?.template?.coverImageUrl return { id: gen?.id, + itemType: 'post' as const, // 模板静态图片 coverUrl: coverUrl, @@ -142,7 +143,7 @@ const Sync = observer(() => { // console.log('selectedItem-----------', selectedItem) const canSync = useMemo(() => { - return !!connectedDevice?.id && !!selectedItem?.imageUrl + return !!connectedDevice?.id }, [connectedDevice, selectedItem]) const handleSync = async () => { @@ -150,8 +151,12 @@ const Sync = observer(() => { Toast.show({ title: '请先连接设备' }) return } + if (!selectedItem?.imageUrl) { + Toast.show({ title: '请等待模板生成完成再同步' }) + return + } - const transferring = bleStore.state.loading.transferring + const transferring = bleStore.state.loading.transferring || bleStore.state.loading.converting if (transferring) { Toast.show({ title: '已有文件同步中,请稍后' }) @@ -186,6 +191,8 @@ const Sync = observer(() => { Toast.showLoading({ renderContent: () => , duration: 0, + // 同步时禁用返回按钮 + onBackButtonPress: () => {}, }) bleManager @@ -392,29 +399,34 @@ const Sync = observer(() => { return null }, [loadingMore]) - const renderHeader = useMemo(() => { - return ( + // Header 组件 + const renderHeader = useMemo( + () => ( - ) - }, [connectedDevice, handlePick, startConnect, isSelectionMode, toggleSelectionMode, selectedItem]) + ), + [connectedDevice, handlePick, selectedItem, startConnect, isSelectionMode, toggleSelectionMode], + ) - const renderItem = ({ item: post }: { item: any }) => { - const isSelected = isSelectionMode ? selectedIds.has(post?.id) : selectedItem?.id === post?.id + const renderItem = useCallback( + ({ item }: { item: any }) => { + const isSelected = isSelectionMode ? selectedIds.has(item?.id) : selectedItem?.id === item?.id - return ( - - ) - } + return ( + + ) + }, + [isSelectionMode, selectedIds, selectedItem?.id, handleItemSelect], + ) if (!isFocused) { return null @@ -432,11 +444,14 @@ const Sync = observer(() => { contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: listPaddingBottom }} data={posts} keyExtractor={(item: any) => item?.id} - ListFooterComponent={ListFooter} ListHeaderComponent={renderHeader} + ListFooterComponent={ListFooter} ListEmptyComponent={} - maxItemsInRecyclePool={0} numColumns={3} + drawDistance={300} + maxItemsInRecyclePool={0} + // 自动移除不可见的原生视图,停止渲染和解码 + removeClippedSubviews={true} renderItem={renderItem} refreshControl={ @@ -723,12 +738,17 @@ const GridItem = memo( // 新数据使用webp 旧数据使用mp4 const canShow = post.status === 'completed' || post.status === 'success' + // 容器高度 = item高度 + 底部间距 + const containerHeight = itemWidth + 6 return ( - onSelect(post)}> + onSelect(post)} + > - + diff --git a/app/auth.tsx b/app/auth.tsx index eada799..fa5d3c9 100644 --- a/app/auth.tsx +++ b/app/auth.tsx @@ -33,12 +33,30 @@ export default function Auth() { const [currentBranch, setCurrentBranch] = useState('unknown') const countdownTimerRef = useRef | null>(null) + const { availableUpdate } = Updates.useUpdates() + useEffect(() => { if (!Updates.isEnabled) { setCurrentBranch('development') return } const manifest = Updates.manifest + + console.log('manifest--------', JSON.stringify(manifest?.extra)) + + console.log('manifest-------updateId-', JSON.stringify(Updates.updateId)) + + const branchName = manifest?.metadata?.branchName + + console.log('当前运行的分支:', branchName) + + console.log('availableUpdate-------', JSON.stringify(availableUpdate)) + if (availableUpdate) { + // 获取即将下载/待安装更新的分支名 + const targetBranch = availableUpdate.manifest?.metadata?.branchName + console.log('检测到新分支更新:', targetBranch) + } + if (manifest?.extra?.eas?.branch) { setCurrentBranch(manifest.extra.eas.branch) } else if (Updates.channel) { diff --git a/package.json b/package.json index 3cf2b86..05122be 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build:test:android": "eas build --profile test --platform android", "build:production:ios": "eas build --profile production --platform ios", "build:production:android": "eas build --profile production --platform android", - "update:test": "dotenv -e .env.test -- eas update --clear-cache --channel test", + "update:test": "dotenv -e .env.test -- eas update --clear-cache --branch test", "update:testB": "dotenv -e .env.test -- eas update --clear-cache --branch test-b", "update:production": "dotenv -e .env.production -- eas update --clear-cache --channel production", "build:local:development:android": "dotenv -e .env.development -- eas build --profile development --platform android --local",