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