feat: 更新应用名称为“Out Live”,删除推送通知使用指南和喝水记录API修复测试文档,优化饮水设置页面,添加登录状态检查

This commit is contained in:
2025-09-07 10:03:37 +08:00
parent 2e7daae519
commit aaa34a7a07
13 changed files with 105 additions and 550 deletions

View File

@@ -3,6 +3,7 @@ import { usePathname, useRouter } from 'expo-router';
import { useCallback } from 'react';
import { Alert } from 'react-native';
import { ROUTES } from '@/constants/Routes';
import { useAppDispatch, useAppSelector } from '@/hooks/redux';
import { api } from '@/services/api';
import { logout as logoutAction } from '@/store/userSlice';
@@ -24,7 +25,7 @@ export function useAuthGuard() {
const ensureLoggedIn = useCallback(async (options?: EnsureOptions): Promise<boolean> => {
if (isLoggedIn) return true;
const redirectTo = options?.redirectTo ?? currentPath ?? '/(tabs)';
const redirectTo = options?.redirectTo ?? currentPath ?? ROUTES.TAB_STATISTICS;
const paramsJson = options?.redirectParams ? JSON.stringify(options.redirectParams) : undefined;
router.push({
@@ -62,7 +63,7 @@ export function useAuthGuard() {
try {
// 调用 Redux action 清除本地状态和缓存
await dispatch(logoutAction()).unwrap();
// 跳转到登录页面
router.push('/auth/login');
} catch (error) {
@@ -95,13 +96,13 @@ export function useAuthGuard() {
try {
// 调用注销账号API
await api.delete('/api/users/delete-account');
// 清除额外的本地数据
await AsyncStorage.multiRemove(['@user_personal_info', '@onboarding_completed']);
// 执行退出登录逻辑
await dispatch(logoutAction()).unwrap();
Alert.alert('账号已注销', '您的账号已成功注销', [
{
text: '确定',