退出登录+机器状态+切换设备+历史作业记录+设备信息

This commit is contained in:
2026-02-25 13:41:23 +08:00
parent 3c48a96d26
commit d81d0c04ea
32 changed files with 1940 additions and 142 deletions

View File

@@ -1,17 +1,31 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/router/route_paths.dart';
import '../../../../core/storage/user_storage.dart';
import '../../../auth/presentation/bloc/auth_cubit.dart';
import '../../../auth/presentation/bloc/auth_state.dart';
import '../../../auth/presentation/pages/login_page.dart';
import '../../../web_view/web_view_page.dart';
import '../web_view/user_info_pages.dart';
class MyPage extends StatelessWidget {
const MyPage({super.key});
@override
Widget build(BuildContext context) {
// 假设从 AuthCubit 获取用户信息
final authState = context.watch<AuthCubit>().state;
String userName = '未知用户';
String userId = '未知ID';
if (authState is AuthAuthenticated) {
final user = authState.user;
userName = user.username ?? '未知用户';
userId = user.userId ?? '未知ID';
}
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
@@ -20,7 +34,7 @@ class MyPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 顶部用户信息
_buildUserInfo(),
UserInfoCard(userName: userName, userId: userId),
SizedBox(height: 16),
@@ -43,42 +57,6 @@ class MyPage extends StatelessWidget {
);
}
Widget _buildUserInfo() {
return Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
image: DecorationImage(
image: NetworkImage('https://pic4.zhimg.com/v2-c34c61a90095abb8713de9d1dca7ec7b_r.jpg'),
fit: BoxFit.cover,
),
),
),
SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('宋', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
Text('用户id:songchunyi', style: TextStyle(fontSize: 12, color: Colors.grey)),
],
),
),
IconButton(
icon: Icon(Icons.edit),
onPressed: () {},
),
Spacer(),
IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
],
);
}
Widget _buildBanner(BuildContext context) { // 添加 context 参数
return GestureDetector(
@@ -132,8 +110,7 @@ class MyPage extends StatelessWidget {
}
Widget _buildFunctionList(BuildContext context) { // 添加 context 参数
//https://www.satabot.com/
Widget _buildFunctionList(BuildContext context) {
final items = [
{'icon': Icons.play_arrow, 'title': '操作视频', 'url': 'https://www.satabot.com/Support/index.html'},
{'icon': Icons.car_rental, 'title': '租赁服务', 'url': 'https://www.satabot.com/Leasing.html'},
@@ -141,7 +118,6 @@ class MyPage extends StatelessWidget {
{'icon': Icons.policy, 'title': '售后政策', 'url': 'https://www.satabot.com/Aftersales-Service.html'},
];
return Container(
decoration: BoxDecoration(
color: Colors.white,
@@ -150,36 +126,56 @@ class MyPage extends StatelessWidget {
BoxShadow(color: Colors.grey.withOpacity(0.1), blurRadius: 4),
],
),
child: ListView.builder(
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return ListTile(
leading: Icon(item['icon'] as IconData),
title: Text(item['title'] as String),
trailing: Icon(Icons.arrow_forward),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewPage(url: item['url'] as String),
),
child: Column(
children: [
// 功能列表
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), // 禁止滚动,使其适应父容器高度
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return ListTile(
leading: Icon(item['icon'] as IconData),
title: Text(item['title'] as String),
trailing: Icon(Icons.arrow_forward),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewPage(url: item['url'] as String),
),
);
},
);
},
);
},
),
// 分割线
Divider(height: 1, color: Colors.grey.withOpacity(0.3)),
// 退出登录按钮
ListTile(
title: Text('退出登录', style: TextStyle(color: Colors.black)),
trailing: Icon(Icons.exit_to_app, color: Colors.black),
onTap: () async {
await GetIt.I<UserStorage>().deleteUser();
GetIt.I<AuthCubit>().logout();
context.go(RoutePaths.login);
},
),
],
),
);
}
Widget _buildLogoutButton(BuildContext context) {
return ElevatedButton(
onPressed: () async {
await GetIt.I<UserStorage>().deleteUser();
context.go('/auth/login');
},
GetIt.I<AuthCubit>().logout();
context.go(RoutePaths.login);
}
,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.red,
@@ -189,9 +185,6 @@ class MyPage extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.exit_to_app, size: 16, color: Colors.red),
SizedBox(width: 8),
Text('退出登录'),
],
),
);

View File

@@ -2,11 +2,14 @@ import 'package:go_router/go_router.dart';
import 'package:maibu_satabot_v2/features/my/presentation/pages/my_page.dart';
import '../../../../core/router/route_paths.dart';
import '../../../auth/presentation/pages/login_page.dart';
class MyRoutes {
/// 1. 全屏功能页面(不带导航栏)
/// 在 createRouter 的根 routes 中使用 ...HomeRoutes.routes 引入
static List<RouteBase> get routes => [
// GoRoute(
// path: RoutePaths.remoteControl,
// builder: (context, state) => const RemoteControlPage(), // 需导入对应 Page

View File

@@ -0,0 +1,47 @@
// user_info_card.dart
import 'package:flutter/material.dart';
class UserInfoCard extends StatelessWidget {
final String userName;
final String userId;
const UserInfoCard({super.key, required this.userName, required this.userId});
@override
Widget build(BuildContext context) {
return Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
image: DecorationImage(
image: NetworkImage('https://pic4.zhimg.com/v2-c34c61a90095abb8713de9d1dca7ec7b_r.jpg'),
fit: BoxFit.cover,
),
),
),
SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(userName, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
Text('用户id:$userId', style: TextStyle(fontSize: 12, color: Colors.grey)),
],
),
),
IconButton(
icon: Icon(Icons.edit),
onPressed: () {},
),
Spacer(),
IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
],
);
}
}