feat: 添加 Toast 组件的 onBackButtonPress 属性,优化视频组件本地文件处理逻辑,更新应用版本号和配置

This commit is contained in:
康猛 2026-02-06 13:58:06 +08:00
parent 6bb78c11cd
commit d36461e62e
7 changed files with 75 additions and 36 deletions

View File

@ -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<typeof setTimeout> | 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,
},

View File

@ -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 = ({
<ExpoImage
ref={imageRef}
// iOS 优化:使用 memory-disk 策略,但设置较低的内存缓存优先级
cachePolicy="memory-disk"
cachePolicy="disk"
// 添加 recyclingKey 帮助内存回收
recyclingKey={url}
// iOS 性能优化:允许降采样

View File

@ -8,9 +8,9 @@ export const IOS_ID = `${ANDROID_ID}.ios`
export const IOS_UNIVERSAL_LINK = 'duooomi.bowong.cn'
// 原生版本,原生代码变更时需要更新此版本号
export const VERSION = '1.5.0'
export const VERSION = '1.2.0'
// JavaScript版本JS代码变更时需要更新此版本号
export const APP_VERSION = 'dev202602041658'
export const APP_VERSION = 'dev202602051033'
const ALIPAY_SCHEMA = 'alipay2021006119657394'
const ALIPAY_SCHEMA_SANDBOX = 'alipay9021000158673972'
@ -223,6 +223,7 @@ export default ({ config }) => {
url: `https://u.expo.dev/${PROJECT_ID}`,
fallbackToCacheTimeout: 0,
checkAutomatically: 'NEVER',
channel: 'test',
},
},
}

View File

@ -717,7 +717,7 @@ const GridItem = memo<GridItemProps>(function GridItem({ item, isSelected, itemW
<Block
className={`relative overflow-hidden border-2 ${isSelected ? 'border-accent' : 'border-black'}`}
style={{
transform: [{ skewX: '-6deg' }],
// transform: [{ skewX: '-6deg' }],
height: itemWidth,
width: itemWidth,
}}

View File

@ -90,6 +90,7 @@ const Sync = observer(() => {
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: () => <SyncProgressToast />,
duration: 0,
// 同步时禁用返回按钮
onBackButtonPress: () => {},
})
bleManager
@ -392,29 +399,34 @@ const Sync = observer(() => {
return null
}, [loadingMore])
const renderHeader = useMemo(() => {
return (
// Header 组件
const renderHeader = useMemo(
() => (
<Block className="z-10">
<HeaderBanner connectedDevice={connectedDevice} onPick={handlePick} />
<TopCircleSection selectedItem={selectedItem} onStartConnect={startConnect} />
<FilterButtons isSelectionMode={isSelectionMode} onToggleSelectionMode={toggleSelectionMode} />
</Block>
),
[connectedDevice, handlePick, selectedItem, startConnect, isSelectionMode, toggleSelectionMode],
)
}, [connectedDevice, handlePick, startConnect, isSelectionMode, toggleSelectionMode, selectedItem])
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 (
<GridItem
isSelected={isSelected}
isSelectionMode={isSelectionMode}
itemWidth={ITEM_WIDTH}
post={post}
post={item}
onSelect={handleItemSelect}
/>
)
}
},
[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={<ListEmpty />}
maxItemsInRecyclePool={0}
numColumns={3}
drawDistance={300}
maxItemsInRecyclePool={0}
// 自动移除不可见的原生视图,停止渲染和解码
removeClippedSubviews={true}
renderItem={renderItem}
refreshControl={
<RefreshControl colors={['#FFE500']} refreshing={refreshing} tintColor="#FFE500" onRefresh={onRefresh} />
@ -723,12 +738,17 @@ const GridItem = memo(
// 新数据使用webp 旧数据使用mp4
const canShow = post.status === 'completed' || post.status === 'success'
// 容器高度 = item高度 + 底部间距
const containerHeight = itemWidth + 6
return (
<Block className="relative" key={post?.id} style={{ marginBottom: ITEM_GAP }} onClick={() => onSelect(post)}>
<Block
key={post?.id}
style={{ width: ITEM_CONTAINER_WIDTH, height: containerHeight }}
onClick={() => onSelect(post)}
>
<Block
className={`relative overflow-hidden border-2 ${isSelected ? 'shadow-[0px_0px_0px_4px_#FFE500]' : 'shadow-hard-black'} ${isSelected ? 'border-accent' : 'border-black'}`}
style={{
// transform: [{ skewX: '-6deg' }],
height: itemWidth,
width: itemWidth,
}}
@ -746,9 +766,7 @@ const GridItem = memo(
className="absolute inset-0 z-30 items-center justify-center"
// style={{ transform: [{ skewX: '6deg' }] }}
>
<Block
className={`size-[32px] items-center justify-center rounded-full border-[3px] border-black ${isSelected ? 'bg-accent' : 'bg-white/50'}`}
>
<Block className={`size-[32px] items-center justify-center rounded-full`}>
<Ionicons color="black" name="checkmark" size={20} />
</Block>
</Block>

View File

@ -33,12 +33,30 @@ export default function Auth() {
const [currentBranch, setCurrentBranch] = useState<string>('unknown')
const countdownTimerRef = useRef<ReturnType<typeof setInterval> | 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) {

View File

@ -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",