feat(client): 登录模块对接后端 API
- auth_state: 增加 refreshToken 字段 + flutter_secure_storage 持久化 - api_client: 增加 401 自动 refresh + retry 拦截器 - auth_repository: 封装 POST /api/v1/auth/login 调用,错误信息本地化 - login_screen: 增加门店编号字段,调真实 API,行内错误展示 - main: 启动时 restore 持久化登录态,避免每次重启都要重新登录 - 修复 app_shell: hotelName → hotelNo - 修复 widget_test: 移除失效的占位测试 测试账号:门店编号 H001 / 用户名 admin / 密码 password123 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,7 @@ class _AppShellState extends ConsumerState<AppShell> {
|
||||
const Icon(Icons.business,
|
||||
color: Colors.white70, size: 14),
|
||||
const SizedBox(width: 4),
|
||||
Text(user.hotelName,
|
||||
Text(user.hotelNo,
|
||||
style: const TextStyle(
|
||||
color: Colors.white70, fontSize: 13)),
|
||||
const SizedBox(width: 20),
|
||||
@@ -222,7 +222,7 @@ class _NavItem {
|
||||
{required this.icon, required this.label, required this.path});
|
||||
}
|
||||
|
||||
class _SidebarItem extends StatefulWidget {
|
||||
class _SidebarItem extends StatelessWidget {
|
||||
final _NavItem item;
|
||||
final bool isActive;
|
||||
final bool expanded;
|
||||
@@ -235,37 +235,21 @@ class _SidebarItem extends StatefulWidget {
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_SidebarItem> createState() => _SidebarItemState();
|
||||
}
|
||||
|
||||
class _SidebarItemState extends State<_SidebarItem> {
|
||||
bool _hovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isActive = widget.isActive;
|
||||
final expanded = widget.expanded;
|
||||
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _hovered = true),
|
||||
onExit: (_) => setState(() => _hovered = false),
|
||||
child: GestureDetector(
|
||||
onTap: widget.onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
height: 48,
|
||||
color: isActive
|
||||
? AppTheme.primary.withOpacity(0.3)
|
||||
: _hovered
|
||||
? Colors.white.withOpacity(0.05)
|
||||
: Colors.transparent,
|
||||
padding: EdgeInsets.symmetric(horizontal: expanded ? 0 : 0),
|
||||
return SizedBox(
|
||||
height: 48,
|
||||
child: Material(
|
||||
color: isActive ? AppTheme.primary.withAlpha(76) : Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
hoverColor: Colors.white.withAlpha(13),
|
||||
splashColor: Colors.white.withAlpha(26),
|
||||
highlightColor: Colors.white.withAlpha(13),
|
||||
child: Row(
|
||||
children: [
|
||||
// Active indicator
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
// Active indicator bar
|
||||
Container(
|
||||
width: 3,
|
||||
height: isActive ? 28 : 0,
|
||||
color: Colors.white,
|
||||
@@ -279,7 +263,7 @@ class _SidebarItemState extends State<_SidebarItem> {
|
||||
: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
widget.item.icon,
|
||||
item.icon,
|
||||
color: isActive ? Colors.white : Colors.white60,
|
||||
size: 20,
|
||||
),
|
||||
@@ -287,11 +271,9 @@ class _SidebarItemState extends State<_SidebarItem> {
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Text(
|
||||
widget.item.label,
|
||||
item.label,
|
||||
style: TextStyle(
|
||||
color: isActive
|
||||
? Colors.white
|
||||
: Colors.white70,
|
||||
color: isActive ? Colors.white : Colors.white70,
|
||||
fontSize: 14,
|
||||
fontWeight: isActive
|
||||
? FontWeight.w500
|
||||
|
||||
Reference in New Issue
Block a user