feat: 添加 Toast 组件的 onBackButtonPress 属性,优化视频组件本地文件处理逻辑,更新应用版本号和配置
This commit is contained in:
parent
6bb78c11cd
commit
d36461e62e
|
|
@ -20,6 +20,7 @@ interface ShowParams {
|
||||||
title?: string
|
title?: string
|
||||||
duration?: number
|
duration?: number
|
||||||
hideBackdrop?: boolean
|
hideBackdrop?: boolean
|
||||||
|
onBackButtonPress?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShowActionSheetParams {
|
interface ShowActionSheetParams {
|
||||||
|
|
@ -95,7 +96,7 @@ const Toast = (function () {
|
||||||
// loading
|
// loading
|
||||||
let loadingTimer: ReturnType<typeof setTimeout> | null = null
|
let loadingTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
const showLoading = (params?: ShowParams): void => {
|
const showLoading = (params?: ShowParams): void => {
|
||||||
const { renderContent, title, duration = 1500, hideBackdrop = false } = params || {}
|
const { renderContent, title, duration = 1500, hideBackdrop = false, onBackButtonPress = undefined } = params || {}
|
||||||
hideLoading()
|
hideLoading()
|
||||||
|
|
||||||
const renderBody = (): ReactNode => {
|
const renderBody = (): ReactNode => {
|
||||||
|
|
@ -126,6 +127,7 @@ const Toast = (function () {
|
||||||
hideBackdrop,
|
hideBackdrop,
|
||||||
backdropColor: 'rgba(0,0,0,0.4)',
|
backdropColor: 'rgba(0,0,0,0.4)',
|
||||||
onBackdropPress: () => {},
|
onBackdropPress: () => {},
|
||||||
|
onBackButtonPress: onBackButtonPress,
|
||||||
entering: false,
|
entering: false,
|
||||||
exiting: false,
|
exiting: false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ const VideoBox = ({
|
||||||
return lowerUrl?.match(/\.(jpg|jpeg|png|gif|webp|bmp|tiff|svg)(\?.*)?$/i)
|
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 setRedirectUrl = async (isCancelled: () => boolean, url?: string) => {
|
||||||
const isImg2 = isImg(url)
|
const isImg2 = isImg(url)
|
||||||
if (isImg2) {
|
if (isImg2) {
|
||||||
|
|
@ -85,7 +89,7 @@ const VideoBox = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 每次url变化强制刷新
|
// 每次url变化强制刷新
|
||||||
setUrlFinal('')
|
setUrlFinal('')
|
||||||
if (!url) {
|
if (!url || isLocal) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,10 +131,6 @@ const VideoBox = ({
|
||||||
|
|
||||||
if (!url) return null
|
if (!url) return null
|
||||||
|
|
||||||
// 本地文件全部用video组件播放
|
|
||||||
const isLocal = !url.startsWith('http://') && !url.startsWith('https://')
|
|
||||||
const isImageFile = isImg(url)
|
|
||||||
|
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
if (!isImageFile) {
|
if (!isImageFile) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -182,7 +182,7 @@ const VideoBox = ({
|
||||||
<ExpoImage
|
<ExpoImage
|
||||||
ref={imageRef}
|
ref={imageRef}
|
||||||
// iOS 优化:使用 memory-disk 策略,但设置较低的内存缓存优先级
|
// iOS 优化:使用 memory-disk 策略,但设置较低的内存缓存优先级
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="disk"
|
||||||
// 添加 recyclingKey 帮助内存回收
|
// 添加 recyclingKey 帮助内存回收
|
||||||
recyclingKey={url}
|
recyclingKey={url}
|
||||||
// iOS 性能优化:允许降采样
|
// iOS 性能优化:允许降采样
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ export const IOS_ID = `${ANDROID_ID}.ios`
|
||||||
export const IOS_UNIVERSAL_LINK = 'duooomi.bowong.cn'
|
export const IOS_UNIVERSAL_LINK = 'duooomi.bowong.cn'
|
||||||
|
|
||||||
// 原生版本,原生代码变更时需要更新此版本号
|
// 原生版本,原生代码变更时需要更新此版本号
|
||||||
export const VERSION = '1.5.0'
|
export const VERSION = '1.2.0'
|
||||||
// JavaScript版本,JS代码变更时需要更新此版本号
|
// JavaScript版本,JS代码变更时需要更新此版本号
|
||||||
export const APP_VERSION = 'dev202602041658'
|
export const APP_VERSION = 'dev202602051033'
|
||||||
|
|
||||||
const ALIPAY_SCHEMA = 'alipay2021006119657394'
|
const ALIPAY_SCHEMA = 'alipay2021006119657394'
|
||||||
const ALIPAY_SCHEMA_SANDBOX = 'alipay9021000158673972'
|
const ALIPAY_SCHEMA_SANDBOX = 'alipay9021000158673972'
|
||||||
|
|
@ -223,6 +223,7 @@ export default ({ config }) => {
|
||||||
url: `https://u.expo.dev/${PROJECT_ID}`,
|
url: `https://u.expo.dev/${PROJECT_ID}`,
|
||||||
fallbackToCacheTimeout: 0,
|
fallbackToCacheTimeout: 0,
|
||||||
checkAutomatically: 'NEVER',
|
checkAutomatically: 'NEVER',
|
||||||
|
channel: 'test',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -717,7 +717,7 @@ const GridItem = memo<GridItemProps>(function GridItem({ item, isSelected, itemW
|
||||||
<Block
|
<Block
|
||||||
className={`relative overflow-hidden border-2 ${isSelected ? 'border-accent' : 'border-black'}`}
|
className={`relative overflow-hidden border-2 ${isSelected ? 'border-accent' : 'border-black'}`}
|
||||||
style={{
|
style={{
|
||||||
transform: [{ skewX: '-6deg' }],
|
// transform: [{ skewX: '-6deg' }],
|
||||||
height: itemWidth,
|
height: itemWidth,
|
||||||
width: itemWidth,
|
width: itemWidth,
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ const Sync = observer(() => {
|
||||||
const coverUrl = gen?.template?.coverImageUrl
|
const coverUrl = gen?.template?.coverImageUrl
|
||||||
return {
|
return {
|
||||||
id: gen?.id,
|
id: gen?.id,
|
||||||
|
itemType: 'post' as const,
|
||||||
|
|
||||||
// 模板静态图片
|
// 模板静态图片
|
||||||
coverUrl: coverUrl,
|
coverUrl: coverUrl,
|
||||||
|
|
@ -142,7 +143,7 @@ const Sync = observer(() => {
|
||||||
// console.log('selectedItem-----------', selectedItem)
|
// console.log('selectedItem-----------', selectedItem)
|
||||||
|
|
||||||
const canSync = useMemo(() => {
|
const canSync = useMemo(() => {
|
||||||
return !!connectedDevice?.id && !!selectedItem?.imageUrl
|
return !!connectedDevice?.id
|
||||||
}, [connectedDevice, selectedItem])
|
}, [connectedDevice, selectedItem])
|
||||||
|
|
||||||
const handleSync = async () => {
|
const handleSync = async () => {
|
||||||
|
|
@ -150,8 +151,12 @@ const Sync = observer(() => {
|
||||||
Toast.show({ title: '请先连接设备' })
|
Toast.show({ title: '请先连接设备' })
|
||||||
return
|
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) {
|
if (transferring) {
|
||||||
Toast.show({ title: '已有文件同步中,请稍后' })
|
Toast.show({ title: '已有文件同步中,请稍后' })
|
||||||
|
|
@ -186,6 +191,8 @@ const Sync = observer(() => {
|
||||||
Toast.showLoading({
|
Toast.showLoading({
|
||||||
renderContent: () => <SyncProgressToast />,
|
renderContent: () => <SyncProgressToast />,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
|
// 同步时禁用返回按钮
|
||||||
|
onBackButtonPress: () => {},
|
||||||
})
|
})
|
||||||
|
|
||||||
bleManager
|
bleManager
|
||||||
|
|
@ -392,29 +399,34 @@ const Sync = observer(() => {
|
||||||
return null
|
return null
|
||||||
}, [loadingMore])
|
}, [loadingMore])
|
||||||
|
|
||||||
const renderHeader = useMemo(() => {
|
// Header 组件
|
||||||
return (
|
const renderHeader = useMemo(
|
||||||
|
() => (
|
||||||
<Block className="z-10">
|
<Block className="z-10">
|
||||||
<HeaderBanner connectedDevice={connectedDevice} onPick={handlePick} />
|
<HeaderBanner connectedDevice={connectedDevice} onPick={handlePick} />
|
||||||
<TopCircleSection selectedItem={selectedItem} onStartConnect={startConnect} />
|
<TopCircleSection selectedItem={selectedItem} onStartConnect={startConnect} />
|
||||||
<FilterButtons isSelectionMode={isSelectionMode} onToggleSelectionMode={toggleSelectionMode} />
|
<FilterButtons isSelectionMode={isSelectionMode} onToggleSelectionMode={toggleSelectionMode} />
|
||||||
</Block>
|
</Block>
|
||||||
)
|
),
|
||||||
}, [connectedDevice, handlePick, startConnect, isSelectionMode, toggleSelectionMode, selectedItem])
|
[connectedDevice, handlePick, selectedItem, startConnect, isSelectionMode, toggleSelectionMode],
|
||||||
|
)
|
||||||
|
|
||||||
const renderItem = ({ item: post }: { item: any }) => {
|
const renderItem = useCallback(
|
||||||
const isSelected = isSelectionMode ? selectedIds.has(post?.id) : selectedItem?.id === post?.id
|
({ item }: { item: any }) => {
|
||||||
|
const isSelected = isSelectionMode ? selectedIds.has(item?.id) : selectedItem?.id === item?.id
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GridItem
|
<GridItem
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
isSelectionMode={isSelectionMode}
|
isSelectionMode={isSelectionMode}
|
||||||
itemWidth={ITEM_WIDTH}
|
itemWidth={ITEM_WIDTH}
|
||||||
post={post}
|
post={item}
|
||||||
onSelect={handleItemSelect}
|
onSelect={handleItemSelect}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
[isSelectionMode, selectedIds, selectedItem?.id, handleItemSelect],
|
||||||
|
)
|
||||||
|
|
||||||
if (!isFocused) {
|
if (!isFocused) {
|
||||||
return null
|
return null
|
||||||
|
|
@ -432,11 +444,14 @@ const Sync = observer(() => {
|
||||||
contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: listPaddingBottom }}
|
contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: listPaddingBottom }}
|
||||||
data={posts}
|
data={posts}
|
||||||
keyExtractor={(item: any) => item?.id}
|
keyExtractor={(item: any) => item?.id}
|
||||||
ListFooterComponent={ListFooter}
|
|
||||||
ListHeaderComponent={renderHeader}
|
ListHeaderComponent={renderHeader}
|
||||||
|
ListFooterComponent={ListFooter}
|
||||||
ListEmptyComponent={<ListEmpty />}
|
ListEmptyComponent={<ListEmpty />}
|
||||||
maxItemsInRecyclePool={0}
|
|
||||||
numColumns={3}
|
numColumns={3}
|
||||||
|
drawDistance={300}
|
||||||
|
maxItemsInRecyclePool={0}
|
||||||
|
// 自动移除不可见的原生视图,停止渲染和解码
|
||||||
|
removeClippedSubviews={true}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl colors={['#FFE500']} refreshing={refreshing} tintColor="#FFE500" onRefresh={onRefresh} />
|
<RefreshControl colors={['#FFE500']} refreshing={refreshing} tintColor="#FFE500" onRefresh={onRefresh} />
|
||||||
|
|
@ -723,12 +738,17 @@ const GridItem = memo(
|
||||||
// 新数据使用webp 旧数据使用mp4
|
// 新数据使用webp 旧数据使用mp4
|
||||||
|
|
||||||
const canShow = post.status === 'completed' || post.status === 'success'
|
const canShow = post.status === 'completed' || post.status === 'success'
|
||||||
|
// 容器高度 = item高度 + 底部间距
|
||||||
|
const containerHeight = itemWidth + 6
|
||||||
return (
|
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
|
<Block
|
||||||
className={`relative overflow-hidden border-2 ${isSelected ? 'shadow-[0px_0px_0px_4px_#FFE500]' : 'shadow-hard-black'} ${isSelected ? 'border-accent' : 'border-black'}`}
|
className={`relative overflow-hidden border-2 ${isSelected ? 'shadow-[0px_0px_0px_4px_#FFE500]' : 'shadow-hard-black'} ${isSelected ? 'border-accent' : 'border-black'}`}
|
||||||
style={{
|
style={{
|
||||||
// transform: [{ skewX: '-6deg' }],
|
|
||||||
height: itemWidth,
|
height: itemWidth,
|
||||||
width: itemWidth,
|
width: itemWidth,
|
||||||
}}
|
}}
|
||||||
|
|
@ -746,9 +766,7 @@ const GridItem = memo(
|
||||||
className="absolute inset-0 z-30 items-center justify-center"
|
className="absolute inset-0 z-30 items-center justify-center"
|
||||||
// style={{ transform: [{ skewX: '6deg' }] }}
|
// style={{ transform: [{ skewX: '6deg' }] }}
|
||||||
>
|
>
|
||||||
<Block
|
<Block className={`size-[32px] items-center justify-center rounded-full`}>
|
||||||
className={`size-[32px] items-center justify-center rounded-full border-[3px] border-black ${isSelected ? 'bg-accent' : 'bg-white/50'}`}
|
|
||||||
>
|
|
||||||
<Ionicons color="black" name="checkmark" size={20} />
|
<Ionicons color="black" name="checkmark" size={20} />
|
||||||
</Block>
|
</Block>
|
||||||
</Block>
|
</Block>
|
||||||
|
|
|
||||||
18
app/auth.tsx
18
app/auth.tsx
|
|
@ -33,12 +33,30 @@ export default function Auth() {
|
||||||
const [currentBranch, setCurrentBranch] = useState<string>('unknown')
|
const [currentBranch, setCurrentBranch] = useState<string>('unknown')
|
||||||
const countdownTimerRef = useRef<ReturnType<typeof setInterval> | null>(null)
|
const countdownTimerRef = useRef<ReturnType<typeof setInterval> | null>(null)
|
||||||
|
|
||||||
|
const { availableUpdate } = Updates.useUpdates()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!Updates.isEnabled) {
|
if (!Updates.isEnabled) {
|
||||||
setCurrentBranch('development')
|
setCurrentBranch('development')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const manifest = Updates.manifest
|
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) {
|
if (manifest?.extra?.eas?.branch) {
|
||||||
setCurrentBranch(manifest.extra.eas.branch)
|
setCurrentBranch(manifest.extra.eas.branch)
|
||||||
} else if (Updates.channel) {
|
} else if (Updates.channel) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
"build:test:android": "eas build --profile test --platform android",
|
"build:test:android": "eas build --profile test --platform android",
|
||||||
"build:production:ios": "eas build --profile production --platform ios",
|
"build:production:ios": "eas build --profile production --platform ios",
|
||||||
"build:production:android": "eas build --profile production --platform android",
|
"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:testB": "dotenv -e .env.test -- eas update --clear-cache --branch test-b",
|
||||||
"update:production": "dotenv -e .env.production -- eas update --clear-cache --channel production",
|
"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",
|
"build:local:development:android": "dotenv -e .env.development -- eas build --profile development --platform android --local",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue