fix(app): account-switch data residue + empty-albums pull-to-refresh

- 换账号数据残留(用户报告):albumListProvider 非 autoDispose 且首页
  IndexedStack 常驻——登出与登录成功两处显式 invalidate(任务库本就按账号
  隔离键隔离,不受影响)
- 空相册无法下拉刷新(用户报告):空态原本直接 return EmptyState 无
  RefreshIndicator——被拉进相册后无法手动刷新;空态改入可滚动容器承载
  下拉刷新(保留新建入口)
- 397/397 全绿、analyze 0

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-23 12:05:25 +08:00
parent c1869d7314
commit 20321f1b93
3 changed files with 85 additions and 60 deletions
+16 -11
View File
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../app/locale_controller.dart';
import '../core/api_client.dart';
import '../features/albums/providers.dart';
import '../features/uploads/engine_scope.dart';
import '../features/uploads/queue_controller.dart';
import '../l10n/app_localizations.dart';
@@ -136,9 +137,7 @@ class SettingsTab extends ConsumerWidget {
child: SingleChildScrollView(
// 长文案/大字体下允许滚动,面板不做固定高度。
child: Padding(
padding: const EdgeInsets.fromLTRB(
kSpace24, 0, kSpace24, kSpace24,
),
padding: const EdgeInsets.fromLTRB(kSpace24, 0, kSpace24, kSpace24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -206,6 +205,10 @@ class SettingsTab extends ConsumerWidget {
await ref.read(apiClientProvider).logout();
// 会话账号失效 → 引擎 stop(任务保留库内,见 engine_scope.dart)。
await ref.read(sessionAccountProvider.notifier).refresh();
// 账号级缓存失效(2026-09-23 用户报告:换账号后相册列表仍是上一账号数据
// ——首页 IndexedStack 三 tab 常驻不销毁,非 autoDispose 的列表 Provider
// 必须显式失效;任务库已按账号隔离键隔离,无需清)。
ref.invalidate(albumListProvider);
if (!context.mounted) return;
Navigator.of(context).pushNamedAndRemoveUntil('/login', (route) => false);
}
@@ -226,7 +229,10 @@ class SettingsTab extends ConsumerWidget {
// ── 账号摘要卡(只读展示,非编辑入口) ─────────────────
Padding(
padding: const EdgeInsets.fromLTRB(
kSpace16, kSpace8, kSpace16, kSpace8,
kSpace16,
kSpace8,
kSpace16,
kSpace8,
),
child: SectionHeader(title: l10n.settingsSectionAccount),
),
@@ -263,7 +269,10 @@ class SettingsTab extends ConsumerWidget {
// ── 通用:语言 / 改密 / 上传帮助 / 版本 ──────────────────
Padding(
padding: const EdgeInsets.fromLTRB(
kSpace16, kSpace24, kSpace16, kSpace8,
kSpace16,
kSpace24,
kSpace16,
kSpace8,
),
child: SectionHeader(title: l10n.settingsSectionGeneral),
),
@@ -323,8 +332,7 @@ class SettingsTab extends ConsumerWidget {
foregroundColor: theme.colorScheme.error,
minimumSize: const Size(48, 48),
),
onPressed: () =>
_confirmLogout(context, ref, unfinishedTasks),
onPressed: () => _confirmLogout(context, ref, unfinishedTasks),
child: Text(l10n.logout),
),
),
@@ -351,10 +359,7 @@ class _AccountAvatar extends StatelessWidget {
radius: 24,
backgroundColor: scheme.primary,
foregroundColor: scheme.onPrimary,
child: Text(
initial,
style: Theme.of(context).textTheme.titleMedium,
),
child: Text(initial, style: Theme.of(context).textTheme.titleMedium),
);
}
}