diff --git a/app.constants.js b/app.constants.js index 9dcbee2..04f4ca6 100644 --- a/app.constants.js +++ b/app.constants.js @@ -8,6 +8,6 @@ export const ANDROID_ID = 'com.duomi.duooomi' export const IOS_ID = ANDROID_ID export const IOS_UNIVERSAL_LINK = 'duooomi.bowong.cn' export const OWNER_ID = 'x3xbTCWf7dbtWu4gGU2TeI054L77xtkt' -export const APP_VERSION = 'dev202512311544' +export const APP_VERSION = 'dev202601071100' export const ALIPAY_SCHEMA = 'alipay2021006119657394' export const ALIPAY_SCHEMA_SANDBOX = '9021000158673972' diff --git a/app/(tabs)/explore.tsx b/app/(tabs)/explore.tsx index 20f8170..d25de90 100644 --- a/app/(tabs)/explore.tsx +++ b/app/(tabs)/explore.tsx @@ -4,6 +4,7 @@ import * as FileSystem from 'expo-file-system/legacy' import { Image } from 'expo-image' import * as ImagePicker from 'expo-image-picker' import * as MediaLibrary from 'expo-media-library' +import { observer } from 'mobx-react-lite' import React, { useState } from 'react' import { Button, StyleSheet, TextInput } from 'react-native' import { KeyboardAwareScrollView } from 'react-native-keyboard-controller' @@ -14,9 +15,12 @@ import { APP_VERSION } from '@/app.constants' import { BLE_UUIDS, PROTOCOL_VERSION, useBleExplorer } from '@/ble' import { ThemedText } from '@/components/themed-text' import { ThemedView } from '@/components/themed-view' +import { userStore } from '@/stores' import { uploadFile } from '@/utils' +import { buildCdnUrl } from '@/utils/getCDNKey' -export default function TabTwoScreen() { +export default observer(function TabTwoScreen() { + const { user } = userStore const { isScanning, isConnected, @@ -45,7 +49,7 @@ export default function TabTwoScreen() { const [imageUri, setImageUri] = useState( 'file:///data/user/0/com.bowong.duooomi/cache/ImageManipulator/153903d9-f5e9-4e65-9c7d-f7bedd574f3c.jpg', ) - const [userId, setUserId] = useState('01duHavK1CMW7pawcgOtB5aUqQeHPeni') + const [userId, setUserId] = useState(user?.id ?? '01duHavK1CMW7pawcgOtB5aUqQeHPeni') // 查询设备版本 const queryDeviceVersion = async () => { @@ -137,7 +141,11 @@ export default function TabTwoScreen() { try { const assetList = await imgPicker({ maxImages: 1, type: ImagePicker.MediaTypeOptions.All, resultType: 'asset' }) - const asset = assetList[0] + const asset = assetList[0] as ImagePicker.ImagePickerAsset + if (!asset) { + console.warn('No asset selected') + return + } // return if (asset?.uri) { @@ -147,7 +155,7 @@ export default function TabTwoScreen() { const url = await uploadFile({ uri: asset.uri, mimeType: asset.mimeType, - fileName: asset.fileName, + fileName: asset.fileName ?? undefined, }) transferMediaSingle(url) @@ -155,15 +163,18 @@ export default function TabTwoScreen() { Toast?.show({ title: '文件传输完成' }) }) .catch((error) => { - if (error === 'no_space') { + const { status } = error || {} + if (!status) { + Toast?.show({ title: `文件传输失败` }) + return + } + + if (status === 'no_space') { Toast?.show({ title: '文件传输失败, 设备存储空间不足' }) - return } - if (error === 'duplicated') { + if (status === 'duplicated') { Toast?.show({ title: '文件传输失败, 设备已存在相同文件' }) - return } - Toast?.show({ title: `文件传输失败,${error}` }) }) .finally(() => { Toast.hideLoading() @@ -370,14 +381,15 @@ export default function TabTwoScreen() { // .fill('https://cdn.roasmax.cn/material/8836b879f2d44af48eef8da82d13a755.mp4') contents.map((item, index) => { console.log('item-----------', item) - + const url = buildCdnUrl(item) + if (!url) return null const Width = 100 return ( {item} - +