diff --git a/.env.development b/.env.development
index cbe8f51..74ae18a 100644
--- a/.env.development
+++ b/.env.development
@@ -3,4 +3,4 @@ EXPO_PUBLIC_ENV=development
EXPO_PUBLIC_OWNER_ID=x3xbTCWf7dbtWu4gGU2TeI054L77xtkt
EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
-EXPO_PUBLIC_GENERATE_GROUP_ID=
\ No newline at end of file
+EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
\ No newline at end of file
diff --git a/.env.production b/.env.production
index a553806..3dc295d 100644
--- a/.env.production
+++ b/.env.production
@@ -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=
\ No newline at end of file
+EXPO_PUBLIC_OWNER_ID=x3xbTCWf7dbtWu4gGU2TeI054L77xtkt
+EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
+EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
\ No newline at end of file
diff --git a/.env.test b/.env.test
index 232de93..682ee62 100644
--- a/.env.test
+++ b/.env.test
@@ -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
\ No newline at end of file
+EXPO_PUBLIC_INDEX_GROUP_ID=cmjto2jdq02egeqecpfehyggs
+EXPO_PUBLIC_GENERATE_GROUP_ID=cmk3qbw9p0008j2eb84etgxcb
\ No newline at end of file
diff --git a/app.constants.js b/app.constants.js
index 04f4ca6..d8e8ec7 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 = 'dev202601071100'
+export const APP_VERSION = 'dev202601081220'
export const ALIPAY_SCHEMA = 'alipay2021006119657394'
export const ALIPAY_SCHEMA_SANDBOX = '9021000158673972'
diff --git a/app/(tabs)/explore.tsx b/app/(tabs)/explore.tsx
index 8ec67e4..ecdb458 100644
--- a/app/(tabs)/explore.tsx
+++ b/app/(tabs)/explore.tsx
@@ -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() {
BLE Explorer
插件当前版本号: {APP_VERSION}
- Session ID: {bleSeesionId}
+ Session ID: {bleSessionId}
diff --git a/app/(tabs)/generate.tsx b/app/(tabs)/generate.tsx
index 9ff3182..34100b2 100644
--- a/app/(tabs)/generate.tsx
+++ b/app/(tabs)/generate.tsx
@@ -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
diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx
index 5d23dd9..60c6533 100644
--- a/app/(tabs)/index.tsx
+++ b/app/(tabs)/index.tsx
@@ -380,7 +380,13 @@ const Index = observer(function Index() {
rightSlot={
router.push('/pointList')}
+ onAddGoo={() => {
+ if (!isAuthenticated) {
+ router.push('/auth')
+ } else {
+ router.push('/pointList')
+ }
+ }}
onOpenSearch={() => setIsSearchOpen(true)}
/>
}
diff --git a/app/(tabs)/sync.tsx b/app/(tabs)/sync.tsx
index 240bb66..07e1326 100644
--- a/app/(tabs)/sync.tsx
+++ b/app/(tabs)/sync.tsx
@@ -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>(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()
}}
/>
@@ -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)
diff --git a/app/_layout.tsx b/app/_layout.tsx
index 0b3d282..cc723e2 100644
--- a/app/_layout.tsx
+++ b/app/_layout.tsx
@@ -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'
diff --git a/ble/managers/ble-manager.ts b/ble/managers/bleManager.ts
similarity index 100%
rename from ble/managers/ble-manager.ts
rename to ble/managers/bleManager.ts
diff --git a/stores/UserStore.ts b/stores/UserStore.ts
index 9deb2bd..dc3f16d 100644
--- a/stores/UserStore.ts
+++ b/stores/UserStore.ts
@@ -81,7 +81,7 @@ class UserStore {
signUp = authSignUp
// 登出方法
- async signOut() {
+ signOut = async () => {
this.setLoading(true)
try {
await authSignOut()