diff --git a/eas.json b/eas.json index babe5b7..e11bfb3 100644 --- a/eas.json +++ b/eas.json @@ -8,6 +8,9 @@ "distribution": "internal" }, "preview": { + "android": { + "buildType": "apk" + }, "distribution": "internal" }, "production": {} diff --git a/package.json b/package.json index 6fe4d68..c11853a 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "react-native-safe-area-context": "4.6.3", "react-native-screens": "~3.22.0", "react-native-svg": "13.9.0", + "react-native-user-agent": "^2.3.1", "react-native-vector-icons": "^10.0.3", "typescript": "^5.1.3", "zustand": "^4.4.1" diff --git a/src/navigation/index.tsx b/src/navigation/index.tsx index e746022..f0e81bc 100644 --- a/src/navigation/index.tsx +++ b/src/navigation/index.tsx @@ -15,17 +15,20 @@ const Stack = createNativeStackNavigator(); function AppNavigation() { const [isSignIn, setIsSignIn] = useState(false); - const userStore = useUserStore(); + const userInfo = useUserStore(state => state.userInfo); + const getUserInfo = useUserStore(state => state.getUserInfo); + + console.warn("AppNavigation renderings"); useEffect(() => { - userStore.getUserInfo(); + getUserInfo(); }, []); return ( {/**/} - {userStore.userInfo ? ( + {userInfo ? ( <> diff --git a/src/pages/Login/index.tsx b/src/pages/Login/index.tsx index e84f2d8..fe5b6cc 100644 --- a/src/pages/Login/index.tsx +++ b/src/pages/Login/index.tsx @@ -101,10 +101,6 @@ const Index = () => { navigation.navigate("home"); }; - const handlePressTestBtn = () => { - zustandStorage.setItem("test", "a empty test"); - }; - // 登录loading 链接"https://assets.vrchat.com/www/images/loading.gif" if (userStore.loading) { @@ -163,12 +159,6 @@ const Index = () => { > Login - - tempBtn - ); diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index ab6b16c..edc0251 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -11,7 +11,12 @@ import { Image } from "expo-image"; // import {Ionicons} from "@expo/vector-icons"; const Index = () => { - const { userInfo, pressTest, clearUserInfo, logOut, getUserInfo } = useUserStore(); + // const { userInfo, pressTest, clearUserInfo, logOut, getUserInfo } = useUserStore(); + + const userInfo = useUserStore(state => state.userInfo); + const clearUserInfo = useUserStore(state => state.clearUserInfo); + const logOut = useUserStore(state => state.logOut); + const getUserInfo = useUserStore(state => state.getUserInfo); const navigation = useNavigation(); // const navigation = useNavigation>(); @@ -19,7 +24,6 @@ const Index = () => { React.useCallback(() => { getUserInfo(); // const unsubscribe = API.subscribe(userId, user => setUser(user)); - // return () => unsubscribe(); }, []), ); diff --git a/src/utils/request.ts b/src/utils/request.ts index 70acfd2..cbe82f6 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,10 +1,17 @@ import axios from "axios"; import Toast from "react-native-root-toast"; +import UserAgent from "react-native-user-agent"; + +// const ua = UserAgent?.applicationName + "dddddd"; +const ua = UserAgent?.getUserAgent(); // 创建一个axios实例 const instance = axios.create({ baseURL: "https://api.vrchat.cloud/api/1", // 替换成你的API的URL withCredentials: true, // 启用跨域请求时携带cookies + headers: { + "User-Agent": ua, + }, }); instance.interceptors.response.use( @@ -22,8 +29,15 @@ instance.interceptors.response.use( position: Toast.positions.CENTER, }); break; + case 400: + Toast.show(error.response?.data?.error?.message ?? "身份验证失败", { + position: Toast.positions.CENTER, + }); + break; default: - Toast.show("default"); + Toast.show("未知错误", { + position: Toast.positions.CENTER, + }); } return Promise.reject(error.response); } diff --git a/yarn.lock b/yarn.lock index ec9d296..3add51d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5949,6 +5949,11 @@ react-native-svg@13.9.0: css-select "^5.1.0" css-tree "^1.1.3" +react-native-user-agent@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/react-native-user-agent/-/react-native-user-agent-2.3.1.tgz#81308be0026d9d4e50cc8f1126068d58e6745868" + integrity sha512-AIFr1VgJHwgWmMwCOmIGxuBeAaADlouXKc10UyR4fzWneUbt5uIJIoRu2oExlfCtiT8IyCp106khDD5vx7RUjw== + react-native-vector-icons@^10.0.3: version "10.0.3" resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-10.0.3.tgz#369824a3b17994b2cd65edbaa32dbf9540d49678"