feat(auth): implement multi-step registration process and enhance background services
All checks were successful
Frontend CI / ota-android (push) Successful in 13m20s
Frontend CI / build-and-push-web (push) Successful in 14m23s
Frontend CI / build-android-apk (push) Successful in 59m10s

- Updated RegisterScreen to support a multi-step registration flow with components for email input, verification, and profile setup.
- Added new components: VerificationCodeInput, StepIndicator, and corresponding types for step management.
- Enhanced background service to check authentication status before executing tasks, improving app reliability.
- Updated TypeScript configuration to include module resolution and JSON module support.

This update significantly improves the user registration experience and ensures background tasks are only executed for authenticated users.
This commit is contained in:
lafay
2026-04-01 04:48:38 +08:00
parent 5614b4078a
commit c771bd9755
13 changed files with 1659 additions and 463 deletions

View File

@@ -32,9 +32,18 @@ const BACKGROUND_INTERVAL = 15; // 15 分钟
let isInitialized = false;
let appStateSubscription: any = null;
// 导入 api 用于检查认证状态
import { api } from './api';
// 定义后台任务
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
try {
// 检查是否已认证
const token = await api.getToken();
if (!token) {
return BackgroundFetch.BackgroundFetchResult.NoData;
}
// 检查 SSE 连接状态
if (!wsService.isConnected()) {
await wsService.connect();
@@ -51,6 +60,12 @@ TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
// SSE 保活任务
TaskManager.defineTask(REALTIME_KEEPALIVE_TASK, async () => {
try {
// 检查是否已认证
const token = await api.getToken();
if (!token) {
return BackgroundFetch.BackgroundFetchResult.NoData;
}
if (!wsService.isConnected()) {
await wsService.connect();
}
@@ -116,9 +131,13 @@ function setupAppStateListener(): void {
return;
}
appStateSubscription = AppState.addEventListener('change', (nextAppState: AppStateStatus) => {
void nextAppState;
appStateSubscription = AppState.addEventListener('change', async (nextAppState: AppStateStatus) => {
if (nextAppState === 'active') {
// 检查是否已认证
const token = await api.getToken();
if (!token) {
return;
}
// App 回到前台,确保连接
if (!wsService.isConnected()) {
wsService.connect();

View File

@@ -335,9 +335,9 @@ class WebSocketService {
try {
const token = await api.getToken();
if (!token) {
console.error('[WebSocket] No token available');
console.log('[WebSocket] No token available, skipping connection');
this.isConnecting = false;
this.scheduleReconnect();
// 没有 token 时不要重连,等待用户登录后再连接
return false;
}