From c7d7255312a0a1305ed6f15f2d6b6437696ec160 Mon Sep 17 00:00:00 2001 From: richarjiang Date: Mon, 18 Aug 2025 19:08:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E5=92=8C=E6=96=B0=E5=A2=9E=E6=8E=A2=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将标签页中的“首页”改为“探索”,并更新相关逻辑 - 新增探索页面,展示推荐文章和训练计划 - 优化教练页面的导航,确保用户体验一致性 - 移除不再使用的代码,简化项目结构 - 更新路由常量,确保路径管理集中化 --- app/(tabs)/_layout.tsx | 6 ++-- app/(tabs)/{index.tsx => explore.tsx} | 0 app/onboarding/index.tsx | 6 ++-- app/profile/goals.tsx | 45 --------------------------- constants/Routes.ts | 28 ++++++++--------- 5 files changed, 20 insertions(+), 65 deletions(-) rename app/(tabs)/{index.tsx => explore.tsx} (100%) diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index e7effff..ee1595a 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -19,7 +19,7 @@ export default function TabLayout() { initialRouteName="coach" screenOptions={({ route }) => { const routeName = route.name; - const isSelected = (routeName === 'index' && pathname === ROUTES.TAB_HOME) || + const isSelected = (routeName === 'explore' && pathname === ROUTES.TAB_EXPLORE) || (routeName === 'coach' && pathname === ROUTES.TAB_COACH) || (routeName === 'statistics' && pathname === ROUTES.TAB_STATISTICS) || pathname.includes(routeName); @@ -40,7 +40,7 @@ export default function TabLayout() { // 基于 routeName 设置图标与标题,避免 tabBarIcon 的包装导致文字裁剪 const getIconAndTitle = () => { switch (routeName) { - case 'index': + case 'explore': return { icon: 'magnifyingglass.circle.fill', title: '发现' } as const; case 'coach': return { icon: 'person.3.fill', title: 'Bot' } as const; @@ -157,7 +157,7 @@ export default function TabLayout() { }} /> { diff --git a/app/(tabs)/index.tsx b/app/(tabs)/explore.tsx similarity index 100% rename from app/(tabs)/index.tsx rename to app/(tabs)/explore.tsx diff --git a/app/onboarding/index.tsx b/app/onboarding/index.tsx index 751c1e8..2d5971a 100644 --- a/app/onboarding/index.tsx +++ b/app/onboarding/index.tsx @@ -1,5 +1,6 @@ import { ThemedText } from '@/components/ThemedText'; import { ThemedView } from '@/components/ThemedView'; +import { ROUTES } from '@/constants/Routes'; import { useColorScheme } from '@/hooks/useColorScheme'; import { useThemeColor } from '@/hooks/useThemeColor'; import AsyncStorage from '@react-native-async-storage/async-storage'; @@ -13,7 +14,6 @@ import { TouchableOpacity, View } from 'react-native'; -import { ROUTES } from '@/constants/Routes'; const { width, height } = Dimensions.get('window'); @@ -30,10 +30,10 @@ export default function WelcomeScreen() { const handleSkip = async () => { try { await AsyncStorage.setItem('@onboarding_completed', 'true'); - router.replace(ROUTES.TAB_HOME); + router.replace(ROUTES.TAB_COACH); } catch (error) { console.error('保存引导状态失败:', error); - router.replace(ROUTES.TAB_HOME); + router.replace(ROUTES.TAB_COACH); } }; diff --git a/app/profile/goals.tsx b/app/profile/goals.tsx index 5fd738e..5622c9d 100644 --- a/app/profile/goals.tsx +++ b/app/profile/goals.tsx @@ -1,7 +1,6 @@ import { HeaderBar } from '@/components/ui/HeaderBar'; import { Colors } from '@/constants/Colors'; import { useColorScheme } from '@/hooks/useColorScheme'; -import { Ionicons } from '@expo/vector-icons'; import AsyncStorage from '@react-native-async-storage/async-storage'; import * as Haptics from 'expo-haptics'; import { useRouter } from 'expo-router'; @@ -305,50 +304,6 @@ export default function GoalsScreen() { 建议范围 {STEPS_RANGE.min.toLocaleString()}-{STEPS_RANGE.max.toLocaleString()},步进 {STEPS_RANGE.step} - - - {PURPOSE_OPTIONS.map((opt) => { - const active = purposes.includes(opt.id); - return ( - togglePurpose(opt.id)} - > - - - - - {opt.label} - - - ); - })} - - {purposes.length > 0 && ( - 已选择 {purposes.length} 项 - )} - diff --git a/constants/Routes.ts b/constants/Routes.ts index ae9e997..12ef5cb 100644 --- a/constants/Routes.ts +++ b/constants/Routes.ts @@ -1,38 +1,38 @@ // 应用路由常量定义 export const ROUTES = { // Tab路由 - TAB_HOME: '/', + TAB_EXPLORE: '/explore', TAB_COACH: '/coach', TAB_STATISTICS: '/statistics', TAB_PERSONAL: '/personal', - + // 训练相关路由 WORKOUT_TODAY: '/workout/today', WORKOUT_CREATE_SESSION: '/workout/create-session', WORKOUT_SESSION: '/workout/session', - + // 训练计划相关路由 TRAINING_PLAN: '/training-plan', - + // 体态评估路由 AI_POSTURE_ASSESSMENT: '/ai-posture-assessment', - + // 挑战路由 CHALLENGE: '/challenge', CHALLENGE_DAY: '/challenge/day', - + // 文章路由 ARTICLE: '/article', - + // 用户相关路由 AUTH_LOGIN: '/auth/login', PROFILE_EDIT: '/profile/edit', PROFILE_GOALS: '/profile/goals', - + // 法律相关路由 LEGAL_USER_AGREEMENT: '/legal/user-agreement', LEGAL_PRIVACY_POLICY: '/legal/privacy-policy', - + // 引导页路由 ONBOARDING: '/onboarding', ONBOARDING_PERSONAL_INFO: '/onboarding/personal-info', @@ -42,17 +42,17 @@ export const ROUTES = { export const ROUTE_PARAMS = { // 训练会话参数 WORKOUT_SESSION_ID: 'id', - + // 训练计划参数 TRAINING_PLAN_ID: 'planId', TRAINING_PLAN_TAB: 'tab', - + // 挑战日参数 CHALLENGE_DAY: 'day', - + // 文章参数 ARTICLE_ID: 'id', - + // 重定向参数 REDIRECT_TO: 'redirectTo', REDIRECT_PARAMS: 'redirectParams', @@ -62,7 +62,7 @@ export const ROUTE_PARAMS = { export const QUERY_PARAMS = { // 训练计划查询参数 TRAINING_PLAN_TAB_SCHEDULE: 'schedule', - + // 教练页面参数 COACH_NAME: 'name', } as const; \ No newline at end of file