This commit is contained in:
oneao committed 2025-12-03 22:18:09 +08:00
1 parent cf9b01e633
commit 4dcac7b5a0
16 files changed
+115 -45

No files matched your search

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