u
This commit is contained in:
1 parent
1b1a54f7dd
commit
fc005e0fb4
22 files changed
+300
-193
No files matched your search
@@ -55,12 +55,12 @@ export default function RootLayout() {
|
||||
}, [pathname])
|
||||
|
||||
useEffect(() => {
|
||||
if (!fontsLoaded)
|
||||
if (!fontsLoaded) {
|
||||
return
|
||||
|
||||
appStore.init().finally(() => {
|
||||
SplashScreen.hideAsync()
|
||||
})
|
||||
}
|
||||
SplashScreen.hideAsync()
|
||||
// appStore.init().finally(() => {
|
||||
// })
|
||||
}, [fontsLoaded])
|
||||
|
||||
return (
|
||||
|
||||
@@ -117,6 +117,8 @@ export default function Auth() {
|
||||
// avatar: onGetUserInfo.figureurlQq_2 || onGetUserInfo.figureurl_2,
|
||||
// })
|
||||
|
||||
// console.log(loginRes)
|
||||
|
||||
// if (loginRes.isSuccess) {
|
||||
// userStore.setUserInfo({
|
||||
// token: loginRes.data.token,
|
||||
@@ -182,15 +184,15 @@ export default function Auth() {
|
||||
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NjY3ODU5ODIxNjUwNjEsImlhdCI6MTc2OTM0ODI0Nn0.17ZNaHD3HSLM8dVn_JQK-gvsG9MKj47IRYV9D4xZkzs
|
||||
|
||||
userStore.setUserInfo({
|
||||
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NzgxMTUwMzIxMDA5MzMsImlhdCI6MTc3MjExMDQ5N30.Ab7_YNwftJigktnPt8f-FwwcLeS45CkrH0jT2jLjRtA',
|
||||
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo3NzgxMTUwMzIxMDA5MzMsImlhdCI6MTc3MjE5MDQ0Mn0.GF611RBvU47QuW2s4kOcdvh88ieIbHu7M_SmWeBOqLY',
|
||||
id: 778115032100933,
|
||||
nickname: 'Zhang',
|
||||
avatar: 'http://thirdqq.qlogo.cn/ek_qqapp/AQHVialeUibE42oV8RvTTVZ4tyRlPYeJrUibWTwtCPfV68E4rSzn9cw00GkXQ3QDTiawwhjoqQb7/100',
|
||||
})
|
||||
|
||||
appStore.init()
|
||||
// appStore.init()
|
||||
|
||||
router.push('/')
|
||||
router.replace('/')
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Space } from '@/types/space/space'
|
||||
import { useCallback, useState } from 'react'
|
||||
import type { UserSpace } from '@/types/space'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Pressable, Text, View } from 'react-native'
|
||||
import Animated, { useAnimatedRef } from 'react-native-reanimated'
|
||||
import Sortable from 'react-native-sortables'
|
||||
@@ -9,9 +9,12 @@ import { AModal } from '@/components/common/ao/index'
|
||||
import EmptyState from '@/components/common/EmptyStatus'
|
||||
import CustomHeader from '@/components/custom/Header'
|
||||
import { Badge, BadgeText } from '@/components/ui/badge'
|
||||
import { createSpaceApi } from '@/request/api/space/space'
|
||||
import { createSpaceApi, listUserSpacesApi } from '@/request/api/space/index'
|
||||
import { useUserStore } from '@/store/user'
|
||||
|
||||
export default function AuthSpace() {
|
||||
const userStore = useUserStore()
|
||||
|
||||
const scrollableRef = useAnimatedRef<Animated.ScrollView>()
|
||||
|
||||
const [selectedId, setSelectedId] = useState<number | null>(null)
|
||||
@@ -22,74 +25,18 @@ export default function AuthSpace() {
|
||||
name: '',
|
||||
})
|
||||
|
||||
const spaces: Space[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'A 的空间',
|
||||
role: 1,
|
||||
member_count: 8,
|
||||
is_default: 1,
|
||||
sort_number: 1,
|
||||
user_name: '张三',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'B 的空间',
|
||||
role: 2,
|
||||
member_count: 5,
|
||||
is_default: 0,
|
||||
sort_number: 2,
|
||||
user_name: '李四',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'C 的空间',
|
||||
role: 3,
|
||||
member_count: 12,
|
||||
is_default: 0,
|
||||
sort_number: 3,
|
||||
user_name: '王五',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'D 的空间',
|
||||
role: 2,
|
||||
member_count: 6,
|
||||
is_default: 0,
|
||||
sort_number: 4,
|
||||
user_name: '赵六',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'E 的空间',
|
||||
role: 1,
|
||||
member_count: 3,
|
||||
is_default: 0,
|
||||
sort_number: 5,
|
||||
user_name: '钱七',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'F 的空间',
|
||||
role: 2,
|
||||
member_count: 9,
|
||||
is_default: 0,
|
||||
sort_number: 6,
|
||||
user_name: '孙八',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'G 的空间',
|
||||
role: 3,
|
||||
member_count: 4,
|
||||
is_default: 0,
|
||||
sort_number: 7,
|
||||
user_name: '周九',
|
||||
},
|
||||
]
|
||||
const [spaces, setSpaces] = useState<UserSpace[]>([])
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item }: { item: Space }) => (
|
||||
function listUserSpaces() {
|
||||
listUserSpacesApi().then((res) => {
|
||||
if (res.isSuccess) {
|
||||
setSpaces(res.data.spaces)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const renderItem
|
||||
= ({ item }: { item: UserSpace }) => (
|
||||
<Pressable
|
||||
key={item.id}
|
||||
onPress={() => setSelectedId(item.id)}
|
||||
@@ -112,22 +59,31 @@ export default function AuthSpace() {
|
||||
{item.name}
|
||||
</Text>
|
||||
|
||||
<Badge size="sm" variant="solid" action="muted">
|
||||
<BadgeText>创建者</BadgeText>
|
||||
</Badge>
|
||||
{
|
||||
item.owner_id === userStore.userInfo.id && (
|
||||
<Badge size="sm" variant="solid" action="muted">
|
||||
<BadgeText>创建者</BadgeText>
|
||||
</Badge>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
item.is_default === 1 && (
|
||||
<Badge size="sm" variant="solid" action="info">
|
||||
<BadgeText>默认</BadgeText>
|
||||
</Badge>
|
||||
)
|
||||
}
|
||||
|
||||
<Badge size="sm" variant="solid" action="info">
|
||||
<BadgeText>默认</BadgeText>
|
||||
</Badge>
|
||||
</View>
|
||||
|
||||
<View className="flex-row items-center gap-3 mt-2">
|
||||
<View className="flex-row gap-1">
|
||||
<LucideIcon icon="UserRound" size={12} />
|
||||
<Text
|
||||
className={`text-xs `}
|
||||
className="text-xs"
|
||||
>
|
||||
用户A
|
||||
{item.user_name}
|
||||
</Text>
|
||||
</View>
|
||||
<View className="flex-row gap-1">
|
||||
@@ -135,7 +91,7 @@ export default function AuthSpace() {
|
||||
<Text
|
||||
className={`text-xs `}
|
||||
>
|
||||
0
|
||||
{item.member_count}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
@@ -148,9 +104,11 @@ export default function AuthSpace() {
|
||||
className="p-1"
|
||||
/>
|
||||
</Pressable>
|
||||
),
|
||||
[],
|
||||
)
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
listUserSpaces()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-white">
|
||||
@@ -186,6 +144,7 @@ export default function AuthSpace() {
|
||||
|
||||
<Animated.ScrollView
|
||||
className="flex-1"
|
||||
showsVerticalScrollIndicator={false}
|
||||
ref={scrollableRef}
|
||||
>
|
||||
{spaces.length === 0
|
||||
@@ -256,18 +215,18 @@ export default function AuthSpace() {
|
||||
toast.warning('请输入空间名称')
|
||||
return
|
||||
}
|
||||
|
||||
await createSpaceApi({
|
||||
name: createForm.name,
|
||||
user_name: userStore.userInfo.nickname,
|
||||
sort_number: 0,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
if (res.isSuccess) {
|
||||
toast.success('创建成功')
|
||||
setCreateOpen(false)
|
||||
setCreateForm({
|
||||
name: '',
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SpaceMember } from '@/types/space/space'
|
||||
import type { SpaceMember } from '@/types/space'
|
||||
import * as Clipboard from 'expo-clipboard'
|
||||
import { useState } from 'react'
|
||||
import { FlatList, TouchableHighlight, TouchableOpacity, View } from 'react-native'
|
||||
@@ -28,7 +28,7 @@ import { HStack } from '@/components/ui/hstack'
|
||||
import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon'
|
||||
import { Text } from '@/components/ui/text'
|
||||
import { VStack } from '@/components/ui/vstack'
|
||||
import { dissolveSpaceApi, exitSpaceApi, removeSpaceMemberApi } from '@/request/api/space/space'
|
||||
import { dissolveSpaceApi, exitSpaceApi, removeSpaceMemberApi } from '@/request/api/space/index'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { formatRelativeTime } from '@/utils/time'
|
||||
import { toast } from '@/utils/toast'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { SpaceMember } from '@/types/space/space'
|
||||
import type { SpaceMember } from '@/types/space'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { View } from 'react-native'
|
||||
import CustomHeader from '@/components/custom/Header'
|
||||
import { createSpaceApi, joinSpaceApi, listSpaceMembersApi } from '@/request/api/space/space'
|
||||
import { createSpaceApi, joinSpaceApi, listSpaceMembersApi } from '@/request/api/space/index'
|
||||
import { useSpaceStore } from '@/store/space'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import JoinSpace from './components/JoinSpace'
|
||||
|
||||
Reference in new issue
Block a user