fix(mobile-app): 不依赖本地状态,直接显示序列号

问题:用户有序列号但 isAccountCreated 为 false 时显示"审核中"

修复:
1. _buildSerialNumberOrStatus(): 只要有有效序列号就直接显示
2. _checkAndStartWalletPolling(): 只要有序列号就调用 API 检查钱包状态
3. 不再依赖本地的 isAccountCreated/isWalletReady 状态

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-22 02:05:27 -08:00
parent 8fa975a19e
commit fefaeb29d6
1 changed files with 38 additions and 46 deletions

View File

@ -801,47 +801,48 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
debugPrint('[ProfilePage] authState.isAccountCreated: ${authState.isAccountCreated}'); debugPrint('[ProfilePage] authState.isAccountCreated: ${authState.isAccountCreated}');
debugPrint('[ProfilePage] _serialNumber: $_serialNumber'); debugPrint('[ProfilePage] _serialNumber: $_serialNumber');
// // serialNumber API
if (authState.isWalletReady) { // isAccountCreated
debugPrint('[ProfilePage] Wallet already ready (local), skip polling'); if (_serialNumber.isEmpty || _serialNumber == '--') {
debugPrint('[ProfilePage] Skip wallet check - no valid serialNumber');
return; return;
} }
// API // API
if (authState.isAccountCreated && _serialNumber.isNotEmpty && _serialNumber != '--') { debugPrint('[ProfilePage] Checking wallet status from API...');
debugPrint('[ProfilePage] Checking wallet status from API...'); try {
try { final accountService = ref.read(accountServiceProvider);
final accountService = ref.read(accountServiceProvider); final walletInfo = await accountService.getWalletInfo(_serialNumber);
final walletInfo = await accountService.getWalletInfo(_serialNumber);
if (walletInfo.isReady) { debugPrint('[ProfilePage] Wallet status from API: isReady=${walletInfo.isReady}, isGenerating=${walletInfo.isGenerating}');
//
debugPrint('[ProfilePage] Wallet is ready, updating local storage');
final secureStorage = ref.read(secureStorageProvider);
await secureStorage.write(key: StorageKeys.isWalletReady, value: 'true');
// authProvider if (walletInfo.isReady) {
await ref.read(authProvider.notifier).checkAuthStatus(); //
debugPrint('[ProfilePage] Wallet is ready, updating local storage');
final secureStorage = ref.read(secureStorageProvider);
await secureStorage.write(key: StorageKeys.isWalletReady, value: 'true');
await secureStorage.write(key: StorageKeys.isAccountCreated, value: 'true');
// walletStatusProvider // authProvider
ref.read(walletStatusProvider.notifier).stopPolling(); await ref.read(authProvider.notifier).checkAuthStatus();
// UI // walletStatusProvider
if (mounted) { ref.read(walletStatusProvider.notifier).stopPolling();
setState(() {});
} // UI
return; if (mounted) {
setState(() {});
} }
} catch (e) { return;
debugPrint('[ProfilePage] Failed to check wallet status: $e');
} }
// //
debugPrint('[ProfilePage] Wallet not ready, starting polling'); debugPrint('[ProfilePage] Wallet not ready, starting polling');
await ref.read(walletStatusProvider.notifier).startPolling(); await ref.read(walletStatusProvider.notifier).startPolling();
} else { } catch (e) {
debugPrint('[ProfilePage] Skip wallet check - conditions not met'); debugPrint('[ProfilePage] Failed to check wallet status: $e');
debugPrint('[ProfilePage] isAccountCreated=${authState.isAccountCreated}, serialNumber=$_serialNumber'); // API
await ref.read(walletStatusProvider.notifier).startPolling();
} }
} }
@ -4073,8 +4074,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
final walletStatus = ref.watch(walletStatusProvider); final walletStatus = ref.watch(walletStatusProvider);
final authState = ref.watch(authProvider); final authState = ref.watch(authProvider);
// //
if (authState.isWalletReady || walletStatus.isReady) { // isWalletReady/isAccountCreated
if (_serialNumber.isNotEmpty && _serialNumber != '--') {
return Row( return Row(
children: [ children: [
Text( Text(
@ -4099,8 +4101,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
); );
} }
// "账号创建审核中" // walletStatus API
if (authState.isAccountCreated && !authState.isWalletReady) { if (walletStatus.isGenerating) {
return Row( return Row(
children: [ children: [
const SizedBox( const SizedBox(
@ -4113,7 +4115,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Text( Text(
'账号创建审核中', '钱包生成中...',
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontFamily: 'Inter', fontFamily: 'Inter',
@ -4126,26 +4128,16 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
); );
} }
// unknown/generating状态"创建账号审核中..." // "--"
return Row( return Row(
children: [ children: [
const SizedBox(
width: 12,
height: 12,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
),
const SizedBox(width: 8),
Text( Text(
'创建账号审核中...', '序列号: --',
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontFamily: 'Inter', fontFamily: 'Inter',
height: 1.5, height: 1.5,
color: Color(0xFFD4AF37), color: Color(0xCC5D4037),
fontStyle: FontStyle.italic,
), ),
), ),
], ],