feat(home): integrate PagerView for tab navigation and add verification redirect
All checks were successful
Frontend CI / build-and-push-web (push) Successful in 9m20s
Frontend CI / ota-android (push) Successful in 14m32s
Frontend CI / build-android-apk (push) Successful in 1h17m23s

Replace custom gesture handling with PagerView component for smoother tab
switching on home screen. Add verification required redirects in API and
WebSocket services that automatically navigate users to the verification
guide when receiving VERIFICATION_REQUIRED error codes.

BREAKING CHANGE: API and WS services now require router to be set via
setExpoRouter/setRouter for navigation to work properly
This commit is contained in:
lafay
2026-04-08 02:38:48 +08:00
parent 25194313ae
commit 96a5207cf8
7 changed files with 171 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
import { AppState, AppStateStatus } from 'react-native';
import { api, WS_URL } from './api';
import { hrefVerificationGuide } from '../navigation/hrefs';
import { MessageCategory, SystemMessageType, SystemMessageExtraData, MessageSegment } from '../types/dto';
import { systemNotificationService } from './systemNotificationService';
@@ -407,11 +408,15 @@ class WebSocketService {
// 处理错误消息 - emit 到上层处理
if (msg.type === 'error') {
console.error('WebSocket error:', msg.payload);
const errorCode: string = msg.payload?.code || 'unknown';
const err: WSErrorMessage = {
type: 'error',
code: msg.payload?.code || 'unknown',
code: errorCode,
message: msg.payload?.message || 'Unknown error',
};
if (errorCode === 'VERIFICATION_REQUIRED') {
this.handleVerificationRequired();
}
this.emit('error', err);
return;
}
@@ -1112,6 +1117,25 @@ class WebSocketService {
this.lastActivityAt = Date.now();
}
private verificationModalShown = false;
private handleVerificationRequired(): void {
if (this.verificationModalShown) return;
this.verificationModalShown = true;
if (this.routerRef) {
this.routerRef.push(hrefVerificationGuide());
}
setTimeout(() => {
this.verificationModalShown = false;
}, 3000);
}
private routerRef: any = null;
setRouter(router: any): void {
this.routerRef = router;
}
private startHeartbeat(): void {
this.stopHeartbeat();
this.heartbeatTimer = setInterval(() => {