feat: implement user balance management with hooks and store

This commit is contained in:
imeepos
2026-01-26 12:57:21 +08:00
parent 2757b68756
commit 3fd445bb6e
7 changed files with 489 additions and 215 deletions

View File

@@ -21,6 +21,7 @@ import { signOut } from '@/lib/auth'
import { useTemplateGenerations, type TemplateGeneration } from '@/hooks'
import { MySkeleton } from '@/components/skeleton/MySkeleton'
import { useSession } from '@/lib/auth'
import { useUserBalance } from '@/hooks/use-user-balance'
const { width: screenWidth } = Dimensions.get('window')
const GALLERY_GAP = 2
@@ -38,6 +39,9 @@ export default function My() {
const { t, i18n } = useTranslation()
const [editDrawerVisible, setEditDrawerVisible] = useState(false)
// 获取积分余额
const { balance } = useUserBalance()
// 获取当前登录用户信息
const { data: session } = useSession()
const userName = session?.user?.name || session?.user?.username || '用户'
@@ -133,7 +137,7 @@ export default function My() {
onPress={() => router.push('/membership' as any)}
>
<PointsIcon />
<Text style={styles.pointsPillText}>60</Text>
<Text style={styles.pointsPillText}>{balance}</Text>
</Pressable>
<Dropdown
options={settingsOptions}