From cbb26873e88a7a13e868448c1cc578ce70b8c6ae Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Mon, 09 Nov 2026 10:54:51 +0800
Subject: [PATCH] feat: 新增客户端版本管理与下载页,重构配置加载方式
---
fluttergamebox/lib/pages/login_page.dart | 99 +++++++++++--------------------------------------
1 files changed, 22 insertions(+), 77 deletions(-)
diff --git a/fluttergamebox/lib/pages/login_page.dart b/fluttergamebox/lib/pages/login_page.dart
index 516063a..0f04814 100644
--- a/fluttergamebox/lib/pages/login_page.dart
+++ b/fluttergamebox/lib/pages/login_page.dart
@@ -1,13 +1,11 @@
-import 'dart:convert';
-
-import 'package:flutter/material.dart';
+import 'package:flutter/material.dart';
import 'package:fluttergamebox/api/api_client.dart';
import 'package:fluttergamebox/api/api_service.dart';
import 'package:fluttergamebox/common/theme.dart';
import 'package:fluttergamebox/store/app_state.dart';
+import 'package:fluttergamebox/utils/util.dart';
import 'package:fluttergamebox/widgets/auth_dialogs.dart';
import 'package:fluttergamebox/widgets/window_controls.dart';
-import 'package:shared_preferences/shared_preferences.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@@ -21,6 +19,22 @@
bool _loading = false;
String? _error;
+ @override
+ void initState() {
+ super.initState();
+ _fillSavedCredentials();
+ }
+
+ /// 自动填充上次登录成功的账号密码
+ Future<void> _fillSavedCredentials() async {
+ final (phone, pwd) = await AppPrefs.getLoginCredentials();
+ if (!mounted || phone.isEmpty) return;
+ setState(() {
+ _phoneCtrl.text = phone;
+ _pwdCtrl.text = pwd;
+ });
+ }
+
// 检查更新提示
void _checkUpdate() {
showToast(context, '当前已是最新版本!');
@@ -42,14 +56,10 @@
if (!mounted) return;
if (res['code'] == 0) {
await ApiClient.saveToken(res['data']['token']);
+ // 登录成功后记住账号密码,下次打开自动填充
+ await AppPrefs.saveLoginCredentials(phone, pwd);
await AppState.instance.refreshUserInfo();
- if (mounted) {
- // 登录成功后弹出公告
- final ann = await ApiService.announcements();
- if (mounted && ann.isNotEmpty) {
- showAnnouncementDialog(context, ann);
- }
- }
+ // 公告改为进入首页时统一弹出(见 main_shell)
} else {
setState(() => _error = res['msg'] ?? '登录失败');
}
@@ -90,7 +100,7 @@
errorBuilder: (_, __, ___) => Container(
color: const Color(0xFF1B1E2E),
child: const Center(
- child: Text('99游戏盒子',
+ child: Text('游趣电玩',
style: TextStyle(
color: AppColors.pink,
fontSize: 40,
@@ -364,68 +374,3 @@
Future.delayed(const Duration(seconds: 2), () => entry.remove());
}
-/// 登录成功后的公告弹窗
-void showAnnouncementDialog(BuildContext context, String content) {
- showDialog(
- context: context,
- builder: (context) => Dialog(
- backgroundColor: Colors.white,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
- child: Container(
- width: 420,
- padding: const EdgeInsets.all(24),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- const Icon(Icons.campaign,
- color: Color(0xFF2B7FFF), size: 22),
- const SizedBox(width: 8),
- const Text('系统公告',
- style: TextStyle(
- color: Colors.black,
- fontSize: 16,
- fontWeight: FontWeight.bold)),
- const Spacer(),
- GestureDetector(
- onTap: () => Navigator.pop(context),
- child: const Icon(Icons.close,
- color: Colors.grey, size: 20),
- ),
- ],
- ),
- const SizedBox(height: 16),
- ConstrainedBox(
- constraints: const BoxConstraints(maxHeight: 320),
- child: SingleChildScrollView(
- child: Text(
- content,
- style: const TextStyle(
- color: Color(0xFFE74C3C),
- fontSize: 13,
- height: 1.9),
- ),
- ),
- ),
- const SizedBox(height: 16),
- Align(
- alignment: Alignment.centerRight,
- child: ElevatedButton(
- onPressed: () => Navigator.pop(context),
- style: ElevatedButton.styleFrom(
- backgroundColor: const Color(0xFF2B7FFF),
- foregroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(4)),
- ),
- child: const Text('知道了'),
- ),
- ),
- ],
- ),
- ),
- ),
- );
-}
--
Gitblit v1.10.0