fix:蓝牙全局单例,test环境变量更新
This commit is contained in:
parent
232af6c4cd
commit
78dbdcf817
|
|
@ -3,4 +3,4 @@ EXPO_PUBLIC_ENV=development
|
|||
|
||||
EXPO_PUBLIC_OWNER_ID=x3xbTCWf7dbtWu4gGU2TeI054L77xtkt
|
||||
EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
|
||||
|
|
@ -2,6 +2,6 @@ EXPO_PUBLIC_API_URL=https://staging.example.com
|
|||
EXPO_PUBLIC_ENV=production
|
||||
|
||||
|
||||
EXPO_PUBLIC_OWNER_ID=
|
||||
EXPO_PUBLIC_INDEX_GROUP_ID=
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=
|
||||
EXPO_PUBLIC_OWNER_ID=x3xbTCWf7dbtWu4gGU2TeI054L77xtkt
|
||||
EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
|
||||
|
|
@ -2,5 +2,5 @@ EXPO_PUBLIC_API_URL=https://staging.example.com
|
|||
EXPO_PUBLIC_ENV=test
|
||||
|
||||
EXPO_PUBLIC_OWNER_ID=x3xbTCWf7dbtWu4gGU2TeI054L77xtkt
|
||||
EXPO_PUBLIC_INDEX_GROUP_ID=cat_iw83x5bg54fmjgvciju
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=cmjmpwop30009dhdpu3qyfvuo
|
||||
EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
|
||||
EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
|
||||
|
|
@ -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 = 'dev202601071100'
|
||||
export const APP_VERSION = 'dev202601081220'
|
||||
export const ALIPAY_SCHEMA = 'alipay2021006119657394'
|
||||
export const ALIPAY_SCHEMA_SANDBOX = '9021000158673972'
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ import { KeyboardAwareScrollView } from 'react-native-keyboard-controller'
|
|||
import { imgPicker } from '@/@share/apis'
|
||||
import { Block, Toast, VideoBox } from '@/@share/components'
|
||||
import { APP_VERSION } from '@/app.constants'
|
||||
import { BLE_UUIDS, PROTOCOL_VERSION, useBleExplorer } from '@/ble'
|
||||
import { BLE_UUIDS, PROTOCOL_VERSION } from '@/ble'
|
||||
import { bleManager } from '@/ble/managers/bleManager'
|
||||
import { ThemedText } from '@/components/themed-text'
|
||||
import { ThemedView } from '@/components/themed-view'
|
||||
import { userStore } from '@/stores'
|
||||
import { bleStore, userStore } from '@/stores'
|
||||
import { uploadFile } from '@/utils'
|
||||
import { buildCdnUrl } from '@/utils/getCDNKey'
|
||||
|
||||
|
|
@ -31,19 +32,22 @@ export default observer(function TabTwoScreen() {
|
|||
discoveredDevices,
|
||||
loading,
|
||||
error,
|
||||
startScan,
|
||||
stopScan,
|
||||
connectToDevice,
|
||||
disconnectDevice,
|
||||
getDeviceInfo,
|
||||
getDeviceVersion,
|
||||
bindDevice,
|
||||
unBindDevice,
|
||||
transferMediaSingle,
|
||||
deleteFile,
|
||||
bleSeesionId,
|
||||
|
||||
contents,
|
||||
} = useBleExplorer()
|
||||
} = bleStore.state
|
||||
|
||||
const bleSessionId = bleStore.bleSessionId
|
||||
|
||||
const startScan = () => bleManager.startScan()
|
||||
const stopScan = () => bleManager.stopScan()
|
||||
const connectToDevice = (device: any) => bleManager.connectToDevice(device)
|
||||
const disconnectDevice = () => bleManager.disconnectDevice()
|
||||
const getDeviceInfo = () => bleManager.getDeviceInfo()
|
||||
const getDeviceVersion = () => bleManager.getDeviceVersion()
|
||||
const bindDevice = (userId: string) => bleManager.bindDevice(userId)
|
||||
const unBindDevice = (userId: string) => bleManager.unBindDevice(userId)
|
||||
const transferMediaSingle = (url: string) => bleManager.transferMediaSingle(url)
|
||||
const deleteFile = (fileName: string) => bleManager.deleteFile(fileName)
|
||||
|
||||
const [imageUri, setImageUri] = useState(
|
||||
'file:///data/user/0/com.bowong.duooomi/cache/ImageManipulator/153903d9-f5e9-4e65-9c7d-f7bedd574f3c.jpg',
|
||||
|
|
@ -226,13 +230,13 @@ export default observer(function TabTwoScreen() {
|
|||
<ThemedView style={styles.titleContainer}>
|
||||
<ThemedText type="title">BLE Explorer</ThemedText>
|
||||
<ThemedText>插件当前版本号: {APP_VERSION}</ThemedText>
|
||||
<ThemedText>Session ID: {bleSeesionId}</ThemedText>
|
||||
<ThemedText>Session ID: {bleSessionId}</ThemedText>
|
||||
<TextInput
|
||||
editable={true}
|
||||
placeholder=""
|
||||
placeholderTextColor="#999"
|
||||
style={styles.input}
|
||||
value={bleSeesionId}
|
||||
value={bleSessionId}
|
||||
/>
|
||||
</ThemedView>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import { useTemplates } from '@/hooks/data/use-templates'
|
|||
import { userBalanceStore, userStore } from '@/stores'
|
||||
import { screenHeight, screenWidth, uploadFile } from '@/utils'
|
||||
|
||||
const CATEGORY_ID = 'cmk3qbw9p0008j2eb84etgxcb'
|
||||
const CATEGORY_ID = process.env.EXPO_PUBLIC_GENERATE_GROUP_ID
|
||||
|
||||
type Template = {
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -380,7 +380,13 @@ const Index = observer(function Index() {
|
|||
rightSlot={
|
||||
<GooActions
|
||||
gooPoints={balance}
|
||||
onAddGoo={() => router.push('/pointList')}
|
||||
onAddGoo={() => {
|
||||
if (!isAuthenticated) {
|
||||
router.push('/auth')
|
||||
} else {
|
||||
router.push('/pointList')
|
||||
}
|
||||
}}
|
||||
onOpenSearch={() => setIsSearchOpen(true)}
|
||||
/>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTim
|
|||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
|
||||
import { imgPicker } from '@/@share/apis'
|
||||
import { useBleExplorer } from '@/ble'
|
||||
import { bleManager } from '@/ble/managers/bleManager'
|
||||
import BannerSection from '@/components/BannerSection'
|
||||
import { useTemplateActions } from '@/hooks/actions/use-template-actions'
|
||||
import { useTemplateGenerations } from '@/hooks/data/use-template-generations'
|
||||
import { userStore } from '@/stores'
|
||||
import { bleStore, userStore } from '@/stores'
|
||||
import { screenWidth, uploadFile } from '@/utils'
|
||||
import { cn } from '@/utils/cn'
|
||||
|
||||
|
|
@ -45,18 +45,7 @@ const Sync = observer(() => {
|
|||
const [isSelectionMode, setIsSelectionMode] = useState(false)
|
||||
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set())
|
||||
|
||||
const {
|
||||
connectedDevice,
|
||||
discoveredDevices,
|
||||
isScanning,
|
||||
|
||||
startScan,
|
||||
stopScan,
|
||||
connectToDevice,
|
||||
disconnectDevice,
|
||||
|
||||
transferMediaSingle,
|
||||
} = useBleExplorer()
|
||||
const { connectedDevice, discoveredDevices, isScanning } = bleStore.state
|
||||
|
||||
const itemWidth = Math.floor((screenWidth - 12 * 2 - 12 * 2) / 3)
|
||||
|
||||
|
|
@ -123,32 +112,30 @@ const Sync = observer(() => {
|
|||
// console.log('selectedItem-----------', selectedItem)
|
||||
|
||||
// 事件处理函数
|
||||
const handleConnectToggle = useCallback(
|
||||
async (item: any) => {
|
||||
if (item.connected) {
|
||||
disconnectDevice()
|
||||
} else {
|
||||
await disconnectDevice()
|
||||
Toast.showLoading({
|
||||
title: '连接中...',
|
||||
duration: 30e3,
|
||||
const handleConnectToggle = useCallback(async (item: any) => {
|
||||
if (item.connected) {
|
||||
bleManager.disconnectDevice()
|
||||
} else {
|
||||
await bleManager.disconnectDevice()
|
||||
Toast.showLoading({
|
||||
title: '连接中...',
|
||||
duration: 30e3,
|
||||
})
|
||||
bleManager
|
||||
.connectToDevice(item)
|
||||
.then(() => {
|
||||
console.log('设备连接成功')
|
||||
})
|
||||
connectToDevice(item)
|
||||
.then(() => {
|
||||
console.log('设备连接成功')
|
||||
.catch(() => {
|
||||
Toast.show({
|
||||
title: '设备连接失败',
|
||||
})
|
||||
.catch(() => {
|
||||
Toast.show({
|
||||
title: '设备连接失败',
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
Toast.hideLoading()
|
||||
})
|
||||
}
|
||||
},
|
||||
[connectToDevice, disconnectDevice],
|
||||
)
|
||||
})
|
||||
.finally(() => {
|
||||
Toast.hideLoading()
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
const canSync = useMemo(() => {
|
||||
return !!connectedDevice?.id && !!selectedItem?.imageUrl
|
||||
|
|
@ -177,7 +164,8 @@ const Sync = observer(() => {
|
|||
duration: 0,
|
||||
})
|
||||
|
||||
transferMediaSingle(selectedItem?.url)
|
||||
bleManager
|
||||
.transferMediaSingle(selectedItem?.url)
|
||||
.then(() => {
|
||||
Toast.show({ title: '同步成功' })
|
||||
})
|
||||
|
|
@ -185,7 +173,7 @@ const Sync = observer(() => {
|
|||
Toast.hideLoading()
|
||||
Toast.show({ title: '同步失败' })
|
||||
})
|
||||
}, [canSync, selectedItem, transferMediaSingle])
|
||||
}, [canSync, selectedItem])
|
||||
|
||||
const handlePick = useCallback(async () => {
|
||||
const assetList = await imgPicker({ maxImages: 1, type: ImagePicker.MediaTypeOptions.All, resultType: 'asset' })
|
||||
|
|
@ -223,15 +211,15 @@ const Sync = observer(() => {
|
|||
|
||||
const startConnect = useCallback(() => {
|
||||
setViewState('manager')
|
||||
startScan()
|
||||
}, [startScan])
|
||||
bleManager.startScan()
|
||||
}, [])
|
||||
|
||||
// 当离开设备管理页面时停止扫描
|
||||
useEffect(() => {
|
||||
if (viewState !== 'manager' && isScanning) {
|
||||
stopScan()
|
||||
bleManager.stopScan()
|
||||
}
|
||||
}, [viewState, isScanning, stopScan])
|
||||
}, [viewState, isScanning])
|
||||
|
||||
const handleGenAgain = useCallback(() => {
|
||||
if (!selectedItem?.templateId) {
|
||||
|
|
@ -442,7 +430,7 @@ const Sync = observer(() => {
|
|||
onConnectToggle={handleConnectToggle}
|
||||
onBack={() => {
|
||||
setViewState('home')
|
||||
stopScan()
|
||||
bleManager.stopScan()
|
||||
}}
|
||||
/>
|
||||
</Block>
|
||||
|
|
@ -689,7 +677,7 @@ const FABButtons = memo(
|
|||
|
||||
// ============ 主要组件部分 ============
|
||||
const HeaderBanner = observer(({ connectedDevice, onPick }: { connectedDevice: any; onPick: () => void }) => {
|
||||
const { user, isAuthenticated, signOut, session } = userStore
|
||||
const { user, isAuthenticated, signOut } = userStore
|
||||
|
||||
// console.log('user-----------', user)
|
||||
// console.log('session--------', session)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { KeyboardProvider } from 'react-native-keyboard-controller'
|
|||
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'
|
||||
|
||||
import { ModalPortal } from '@/@share/components'
|
||||
import { bleManager } from '@/ble/managers/ble-manager'
|
||||
import { bleManager } from '@/ble/managers/bleManager'
|
||||
import { HotUpdate } from '@/components/hot-update'
|
||||
import { useColorScheme } from '@/hooks/use-color-scheme'
|
||||
import { setupGlobalFetchLogger } from '@/lib/fetch-logger'
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class UserStore {
|
|||
signUp = authSignUp
|
||||
|
||||
// 登出方法
|
||||
async signOut() {
|
||||
signOut = async () => {
|
||||
this.setLoading(true)
|
||||
try {
|
||||
await authSignOut()
|
||||
|
|
|
|||
Loading…
Reference in New Issue