refactor(navigation): consolidate navigation with href helpers and extract push device hook

- Migrate all navigation calls from magic strings to centralized href helpers
- Extract inline device registration logic into useRegisterPushDevice hook
- Remove unused terms and privacy policy routes from profile stack
- Add hrefTradeDetail helper for trade detail navigation
- Restore routePayloadCache.stashSystemMessage for group request/invite handling
- Change desktop shell tab navigation from replace to push
This commit is contained in:
lafay
2026-06-12 23:42:09 +08:00
parent 1f7e25349f
commit 1e05d2bd54
19 changed files with 312 additions and 473 deletions

View File

@@ -716,7 +716,7 @@ export const HomeScreen: React.FC = () => {
// 跳转到发帖页面(使用 Modal 方式)
const handleCreatePost = () => {
if (!isAuthenticated) {
router.push('/login');
router.push(hrefs.hrefAuthLogin());
return;
}
if (!isVerified) {
@@ -1052,7 +1052,7 @@ export const HomeScreen: React.FC = () => {
floatingButtonBottom !== undefined && { bottom: floatingButtonBottom },
]}
onPress={homeTab === 'market' ? () => {
if (!isAuthenticated) { router.push('/login'); return; }
if (!isAuthenticated) { router.push(hrefs.hrefAuthLogin()); return; }
if (!isVerified) { router.push(hrefs.hrefVerificationGuide()); return; }
setShowCreateTrade(true);
} : handleCreatePost}

View File

@@ -14,6 +14,7 @@ import type {
} from '../../types/trade';
import { useRouter } from 'expo-router';
import { useResponsive, useResponsiveSpacing } from '../../hooks';
import * as hrefs from '../../navigation/hrefs';
type TradeFilterType = 'all' | 'sell' | 'buy';
@@ -137,7 +138,7 @@ export function MarketView({
}, [isLoadingMore, hasMore, cursor, filterType, selectedCategory]);
const handlePressItem = useCallback((id: string) => {
router.push(`/trade/${id}` as any);
router.push(hrefs.hrefTradeDetail(id));
}, [router]);
const handleFavorite = useCallback(async (id: string) => {

View File

@@ -472,7 +472,7 @@ export const SearchScreen: React.FC<SearchScreenProps> = ({ onBack, homeTab = 's
<TradeCard
item={item}
variant="list"
onPress={(id) => router.push(`/trade/${id}` as any)}
onPress={(id) => router.push(hrefs.hrefTradeDetail(id))}
/>
</View>
)}

View File

@@ -38,7 +38,7 @@ import { SystemMessageItem } from '../../components/business';
import { Text, ResponsiveContainer, AppBackButton } from '../../components/common';
import { useCursorPagination } from '../../hooks/useCursorPagination';
import * as hrefs from '../../navigation/hrefs';
import { useMessageManagerSystemUnreadCount } from '../../stores';
import { useMessageManagerSystemUnreadCount, routePayloadCache } from '../../stores';
import { messageManager } from '../../stores/message';
const MESSAGE_TYPES = [
@@ -331,8 +331,10 @@ export const NotificationsScreen: React.FC<{ onBack?: () => void }> = ({ onBack
router.push(hrefs.hrefUserProfile(extra_data.actor_id_str));
}
} else if (system_type === 'group_join_apply') {
routePayloadCache.stashSystemMessage(message);
router.push(hrefs.hrefGroupRequestDetail(message));
} else if (system_type === 'group_invite') {
routePayloadCache.stashSystemMessage(message);
router.push(hrefs.hrefGroupInviteDetail(message));
}
// 其他类型暂不处理跳转