u
This commit is contained in:
1 parent
cf9b01e633
commit
4dcac7b5a0
16 files changed
+139
-69
No files matched your search
@@ -74,7 +74,7 @@ export default function RootLayout() {
|
||||
|
||||
// 隐藏 splash
|
||||
SplashScreen.hideAsync()
|
||||
}, [fontsLoaded, userStore, moneyCategoryStore, router])
|
||||
}, [fontsLoaded])
|
||||
|
||||
return (
|
||||
<MenuProvider>
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ export default function SpaceInviteAndMembers() {
|
||||
return (
|
||||
<>
|
||||
<AccordionTitleText className="font-semibold text-lg">
|
||||
我的邀请码
|
||||
邀请码
|
||||
</AccordionTitleText>
|
||||
{isExpanded
|
||||
? (
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react'
|
||||
import { View } from 'react-native'
|
||||
import CustomHeader from '@/components/custom/Header'
|
||||
|
||||
import { useSpaceStore } from '@/store/space'
|
||||
import JoinSpace from './components/JoinSpace'
|
||||
import SpaceHome from './components/SpaceHome'
|
||||
import SpaceInviteAndMembers from './components/SpaceInviteAndMembers'
|
||||
@@ -10,12 +9,11 @@ import SpaceInviteAndMembers from './components/SpaceInviteAndMembers'
|
||||
import StepFade from './components/StepFade'
|
||||
|
||||
export default function PagerWithTab() {
|
||||
const spaceStore = useSpaceStore()
|
||||
const [step, setStep] = useState<'join' | 'invite' | 'home'>('home')
|
||||
|
||||
useEffect(() => {
|
||||
spaceStore.init()
|
||||
}, [])
|
||||
function createSpace() {
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1">
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ViewStyle } from 'react-native'
|
||||
import { Stack, useRouter } from 'expo-router'
|
||||
import React from 'react'
|
||||
import { Image, Text, TouchableOpacity, View } from 'react-native'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { LucideIcon } from '../common/ao'
|
||||
|
||||
export type StackScreenProps = React.ComponentProps<typeof Stack.Screen>
|
||||
@@ -63,41 +63,48 @@ export default function CustomHeader(props: CustomHeaderProps) {
|
||||
...screenProps?.options,
|
||||
headerShown: true,
|
||||
header: () => (
|
||||
<View
|
||||
className={`flex-row items-center h-24 px-2 ${className} `}
|
||||
<SafeAreaView
|
||||
className={`${className}`}
|
||||
style={[
|
||||
{ paddingTop: safeArea ? insets.top : 0 },
|
||||
style,
|
||||
]}
|
||||
>
|
||||
{
|
||||
left || (
|
||||
<View className="w-10 h-full justify-center">
|
||||
<TouchableOpacity onPress={() => router.back()}>
|
||||
<LucideIcon icon="ArrowLeft" size={24} clickable={false} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
{/* 左侧 */}
|
||||
<View
|
||||
className="flex-row items-center px-2"
|
||||
style={[
|
||||
{ height: 48 },
|
||||
]}
|
||||
>
|
||||
{
|
||||
left || (
|
||||
<View className="w-10 h-full justify-center">
|
||||
<TouchableOpacity onPress={() => router.back()}>
|
||||
<LucideIcon icon="ChevronLeft" size={28} clickable={false} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
{/* 左侧 */}
|
||||
|
||||
{/* 标题 */}
|
||||
<View className="flex-1 items-center justify-center">
|
||||
{typeof title === 'string'
|
||||
? <Text className="text-xl">{title}</Text>
|
||||
: title}
|
||||
</View>
|
||||
|
||||
{right || (
|
||||
<View className="w-10 h-full items-center justify-center">
|
||||
<Image
|
||||
source={require('@/static/images/logo.png')}
|
||||
style={{ width: 22, height: 22 }}
|
||||
/>
|
||||
{/* 标题 */}
|
||||
<View className="flex-1 items-center justify-center">
|
||||
{typeof title === 'string'
|
||||
? <Text className="text-xl">{title}</Text>
|
||||
: title}
|
||||
</View>
|
||||
)}
|
||||
|
||||
</View>
|
||||
{right || (
|
||||
<View className="w-10 h-full items-center justify-center">
|
||||
<Image
|
||||
source={require('@/static/images/logo.png')}
|
||||
style={{ width: 22, height: 22 }}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -31,8 +31,8 @@ function isWhiteListed(url: string) {
|
||||
}
|
||||
|
||||
const alovaInstance = createAlova({
|
||||
// baseURL: 'http://192.168.5.6:8086/app',
|
||||
baseURL: 'http://192.168.1.136:8086/app',
|
||||
baseURL: 'http://192.168.5.6:8086/app',
|
||||
// baseURL: 'http://192.168.1.136:8086/app',
|
||||
requestAdapter: axiosRequestAdapter(),
|
||||
timeout: 5000,
|
||||
cacheFor: null,
|
||||
|
||||
@@ -35,6 +35,7 @@ export const useMoneyCategoryStore = create<MoneyCategoryStore>()(
|
||||
set({ categories: get().categories.filter(c => c.id !== id) }),
|
||||
|
||||
init: async () => {
|
||||
|
||||
try {
|
||||
await queryMoneyCategoryApi().then((res) => {
|
||||
if (res.isSuccess) {
|
||||
|
||||
+3
-2
@@ -21,8 +21,9 @@ declare global {
|
||||
}
|
||||
|
||||
interface UserSpace {
|
||||
id: number
|
||||
name: string
|
||||
space_id: number
|
||||
space_name: string
|
||||
invite_code: string
|
||||
role: number
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,9 @@ export interface GetUserSpaceParams {
|
||||
|
||||
}
|
||||
export interface GetUserSpaceResult {
|
||||
id: number
|
||||
name: string
|
||||
space_id: number
|
||||
space_name: string
|
||||
role: number
|
||||
invite_code: string
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) {
|
||||
|
||||
userID := middleware.GetUserID(ctx)
|
||||
|
||||
spaceByUserId, err := db.Queries.GetSpaceByUserId(ctx, userID)
|
||||
spaceByUserId, err := db.Queries.GetUserSpaceDetail(ctx, userID)
|
||||
|
||||
if err != nil {
|
||||
if errorx.IsNotFound(err) {
|
||||
@@ -313,9 +313,10 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) {
|
||||
}
|
||||
}
|
||||
|
||||
resp.Id = spaceByUserId.ID
|
||||
resp.Name = spaceByUserId.Name.String
|
||||
resp.InviteCode = spaceByUserId.InviteCode
|
||||
resp.SpaceId = spaceByUserId.SpaceID
|
||||
resp.SpaceName = spaceByUserId.SpaceName.String
|
||||
resp.InviteCode = spaceByUserId.SpaceInviteCode
|
||||
resp.Role = spaceByUserId.Role
|
||||
|
||||
response.Success(c).Data(resp).Send()
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v4.25.3
|
||||
// protoc v6.33.1
|
||||
// source: api.proto
|
||||
|
||||
package api
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v4.25.3
|
||||
// protoc v6.33.1
|
||||
// source: space.proto
|
||||
|
||||
package space
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v4.25.3
|
||||
// protoc v6.33.1
|
||||
// source: space/space_types.proto
|
||||
|
||||
package space
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v4.25.3
|
||||
// protoc v6.33.1
|
||||
// source: space/space_user_types.proto
|
||||
|
||||
package space
|
||||
@@ -573,9 +573,10 @@ type GetUserSpaceResult struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id"`
|
||||
Name string `protobuf:"bytes,2,opt,name=Name,proto3" form:"name" json:"name"`
|
||||
SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" form:"space_id" json:"space_id"`
|
||||
SpaceName string `protobuf:"bytes,2,opt,name=SpaceName,proto3" form:"space_name" json:"space_name"`
|
||||
InviteCode string `protobuf:"bytes,3,opt,name=InviteCode,proto3" form:"invite_code" json:"invite_code"`
|
||||
Role int32 `protobuf:"varint,4,opt,name=Role,proto3" form:"role" json:"role"`
|
||||
}
|
||||
|
||||
func (x *GetUserSpaceResult) Reset() {
|
||||
@@ -610,16 +611,16 @@ func (*GetUserSpaceResult) Descriptor() ([]byte, []int) {
|
||||
return file_space_space_user_types_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *GetUserSpaceResult) GetId() int64 {
|
||||
func (x *GetUserSpaceResult) GetSpaceId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
return x.SpaceId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetUserSpaceResult) GetName() string {
|
||||
func (x *GetUserSpaceResult) GetSpaceName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
return x.SpaceName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -631,6 +632,13 @@ func (x *GetUserSpaceResult) GetInviteCode() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetUserSpaceResult) GetRole() int32 {
|
||||
if x != nil {
|
||||
return x.Role
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_space_space_user_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_space_space_user_types_proto_rawDesc = []byte{
|
||||
@@ -683,17 +691,21 @@ var file_space_space_user_types_proto_rawDesc = []byte{
|
||||
0x1b, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73,
|
||||
0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0x0a, 0x12,
|
||||
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61,
|
||||
0x6d, 0x73, 0x22, 0x7b, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61,
|
||||
0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x16, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 0x52, 0x02, 0x49, 0x64,
|
||||
0x12, 0x1c, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08,
|
||||
0xca, 0xbb, 0x18, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2f,
|
||||
0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x5f, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x42,
|
||||
0x22, 0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65,
|
||||
0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70,
|
||||
0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70,
|
||||
0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70, 0x61,
|
||||
0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xca, 0xbb, 0x18, 0x08,
|
||||
0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49,
|
||||
0x64, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x5f,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x08,
|
||||
0xca, 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x22,
|
||||
0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d,
|
||||
0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70, 0x61,
|
||||
0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -35,3 +35,15 @@ ORDER BY su.join_time ASC;
|
||||
-- name: GetSpaceUserByUserId :one
|
||||
SELECT * FROM space_user WHERE user_id = $1;
|
||||
|
||||
-- name: GetUserSpaceDetail :one
|
||||
SELECT
|
||||
s.id AS space_id,
|
||||
s.name AS space_name,
|
||||
s.invite_code AS space_invite_code,
|
||||
su.id AS space_user_id,
|
||||
su.user_id,
|
||||
su.role
|
||||
FROM space_user su
|
||||
JOIN space s ON su.space_id = s.id
|
||||
WHERE su.user_id = $1;
|
||||
|
||||
@@ -48,6 +48,42 @@ func (q *Queries) GetSpaceUserByUserId(ctx context.Context, userID int64) (Space
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserSpaceDetail = `-- name: GetUserSpaceDetail :one
|
||||
SELECT
|
||||
s.id AS space_id,
|
||||
s.name AS space_name,
|
||||
s.invite_code AS space_invite_code,
|
||||
su.id AS space_user_id,
|
||||
su.user_id,
|
||||
su.role
|
||||
FROM space_user su
|
||||
JOIN space s ON su.space_id = s.id
|
||||
WHERE su.user_id = $1
|
||||
`
|
||||
|
||||
type GetUserSpaceDetailRow struct {
|
||||
SpaceID int64
|
||||
SpaceName pgtype.Text
|
||||
SpaceInviteCode string
|
||||
SpaceUserID int64
|
||||
UserID int64
|
||||
Role int32
|
||||
}
|
||||
|
||||
func (q *Queries) GetUserSpaceDetail(ctx context.Context, userID int64) (GetUserSpaceDetailRow, error) {
|
||||
row := q.db.QueryRow(ctx, getUserSpaceDetail, userID)
|
||||
var i GetUserSpaceDetailRow
|
||||
err := row.Scan(
|
||||
&i.SpaceID,
|
||||
&i.SpaceName,
|
||||
&i.SpaceInviteCode,
|
||||
&i.SpaceUserID,
|
||||
&i.UserID,
|
||||
&i.Role,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertSpaceUser = `-- name: InsertSpaceUser :exec
|
||||
INSERT INTO space_user(id,space_id,user_id,role)
|
||||
VALUES ($1,$2,$3,$4)
|
||||
|
||||
@@ -63,7 +63,8 @@ message GetUserSpaceParams{
|
||||
|
||||
}
|
||||
message GetUserSpaceResult{
|
||||
int64 Id = 1[(api.body)="id"];
|
||||
string Name = 2[(api.body)="name"];
|
||||
int64 SpaceId = 1[(api.body)="space_id"];
|
||||
string SpaceName = 2[(api.body)="space_name"];
|
||||
string InviteCode = 3[(api.body)="invite_code"];
|
||||
int32 Role = 4[(api.body)="role"];
|
||||
}
|
||||
Reference in new issue
Block a user