From 1a6df3c80604e0d79daa4ca70f0c6d882ebb761c Mon Sep 17 00:00:00 2001 From: imeepos Date: Tue, 13 Jan 2026 15:55:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(tabs)/index.tsx | 31 ++++++++---------- app/_layout.tsx | 1 + app/auth.tsx | 76 +++++++++++++++++++++++++++++++++++++++++-- lib/auth.ts | 3 ++ lib/storage.native.ts | 14 -------- tmpclaude-4100-cwd | 1 + 6 files changed, 91 insertions(+), 35 deletions(-) create mode 100644 tmpclaude-4100-cwd diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 82c3727..0aecba8 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,24 +1,23 @@ -import { useState, useRef, useEffect } from 'react' +import { Image } from 'expo-image' +import { LinearGradient } from 'expo-linear-gradient' +import { useRouter } from 'expo-router' +import { StatusBar } from 'expo-status-bar' +import { useEffect, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' import { - View, - Text, - StyleSheet, + Animated, Dimensions, - ScrollView, + Platform, Pressable, StatusBar as RNStatusBar, - Animated, - Platform, + ScrollView, + StyleSheet, + Text, + View, } from 'react-native' -import { StatusBar } from 'expo-status-bar' -import { LinearGradient } from 'expo-linear-gradient' import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' -import { Image } from 'expo-image' -import { useRouter } from 'expo-router' -import { useTranslation } from 'react-i18next' -import { PointsIcon, SearchIcon, DownArrowIcon, WhiteStarIcon } from '@/components/icon' -import { AuthForm } from '@/components/blocks/AuthForm' +import { DownArrowIcon, PointsIcon, SearchIcon, WhiteStarIcon } from '@/components/icon' import { useActivates } from '@/hooks/use-activates' const { width: screenWidth } = Dimensions.get('window') @@ -279,10 +278,6 @@ export default function HomeScreen() { {renderTabs()} - - - - {/* 内容网格 */} + diff --git a/app/auth.tsx b/app/auth.tsx index 26148c8..8e6fb95 100644 --- a/app/auth.tsx +++ b/app/auth.tsx @@ -1,5 +1,75 @@ +import React, { useEffect } from 'react' +import { View, StyleSheet, StatusBar as RNStatusBar } from 'react-native' +import { StatusBar } from 'expo-status-bar' +import { SafeAreaView } from 'react-native-safe-area-context' +import { useRouter } from 'expo-router' +import { LinearGradient } from 'expo-linear-gradient' +import { AuthForm } from '@/components/blocks/AuthForm' +import { useSession } from '@/lib/auth' +export default function Auth() { + const router = useRouter() + const { data: session, isPending } = useSession() -export default () => { - return null; -} \ No newline at end of file + useEffect(() => { + // 如果用户已登录,跳转到首页 + if (session?.user) { + router.replace('/(tabs)' as any) + } + }, [session, router]) + + // 会话加载中显示空白 + if (isPending) { + return ( + + + + ) + } + + // 如果已登录,不显示内容(等待跳转) + if (session?.user) { + return null + } + + const handleSuccess = () => { + router.replace('/(tabs)' as any) + } + + return ( + + + + + + + + + + + ) +} + +const styles = StyleSheet.create({ + background: { + flex: 1, + width: '100%', + height: '100%', + }, + container: { + flex: 1, + backgroundColor: 'transparent', + }, + content: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + paddingHorizontal: 20, + }, +}) diff --git a/lib/auth.ts b/lib/auth.ts index d761861..7febea8 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -83,6 +83,9 @@ export const authClient = createAuthClient({ storage, scheme: 'duooomi', fetchOptions: { + headers: { + "x-ownerid": "" + }, auth: { type: 'Bearer', token: async () => { diff --git a/lib/storage.native.ts b/lib/storage.native.ts index 3f1fa28..8b13789 100644 --- a/lib/storage.native.ts +++ b/lib/storage.native.ts @@ -1,15 +1 @@ -import * as SecureStore from "expo-secure-store"; -export const storage = { - async getItem(key: string): Promise { - return await SecureStore.getItemAsync(key); - }, - - async setItem(key: string, value: string): Promise { - await SecureStore.setItemAsync(key, value); - }, - - async removeItem(key: string): Promise { - await SecureStore.deleteItemAsync(key); - }, -}; diff --git a/tmpclaude-4100-cwd b/tmpclaude-4100-cwd new file mode 100644 index 0000000..71505f0 --- /dev/null +++ b/tmpclaude-4100-cwd @@ -0,0 +1 @@ +/c/Users/imeep/Desktop/shopify/expo-popcore-app