feat(client): 登录历史下拉、macOS 兼容修复、UI 优化

- 替换 flutter_secure_storage 为 shared_preferences,解决 macOS Keychain 签名报错
- 登录页门店编号/用户名支持历史下拉(最多5条,LRU 淘汰),使用 Overlay + CompositedTransformFollower 实现浮层
- logout 仅删除 auth token,保留登录历史
- AppShell 时钟抽为独立 _ClockWidget,避免每秒 setState 导致 TabBarView 叠影
- ShellRoute 子路由改用 NoTransitionPage,消除切换页面时的过渡动画叠影
- 新增 auth_state_test、auth_repository_test、login_screen_test 共 14 个单元/Widget 测试

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-04-05 01:21:40 +08:00
parent cc687ae0c3
commit 37112d6599
15 changed files with 895 additions and 407 deletions
@@ -0,0 +1,36 @@
import 'package:shared_preferences/shared_preferences.dart';
/// Stores up to [_maxItems] recently used hotel codes and usernames.
/// List is ordered most-recent-first; least-recently-used entry is evicted
/// when the list exceeds the max.
class LoginHistoryStorage {
static const int _maxItems = 5;
static const String _hotelKey = 'login_history_hotels';
static const String _usernameKey = 'login_history_usernames';
static Future<List<String>> getHotelCodes() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getStringList(_hotelKey) ?? [];
}
static Future<List<String>> getUsernames() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getStringList(_usernameKey) ?? [];
}
/// Call after a successful login to persist both values.
static Future<void> record(String hotelCode, String username) async {
final prefs = await SharedPreferences.getInstance();
await _push(prefs, _hotelKey, hotelCode);
await _push(prefs, _usernameKey, username);
}
static Future<void> _push(
SharedPreferences prefs, String key, String value) async {
final list = prefs.getStringList(key) ?? [];
list.remove(value); // move to front if already present
list.insert(0, value);
if (list.length > _maxItems) list.removeLast();
await prefs.setStringList(key, list);
}
}