From 076d5b99d238ebcdc9b9b7b136887a69fc2fa333 Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Sat, 07 Nov 2026 16:55:04 +0800
Subject: [PATCH] feat: 新增永久卡、密钥冻结、工具管理及公告功能,优化游戏安装逻辑

---
 fluttergamebox/lib/pages/main_shell.dart |  121 ++++++++++++++++++++++++++++++++--------
 1 files changed, 97 insertions(+), 24 deletions(-)

diff --git a/fluttergamebox/lib/pages/main_shell.dart b/fluttergamebox/lib/pages/main_shell.dart
index bdfdac5..b02184b 100644
--- a/fluttergamebox/lib/pages/main_shell.dart
+++ b/fluttergamebox/lib/pages/main_shell.dart
@@ -12,6 +12,7 @@
 import 'package:fluttergamebox/widgets/activate_dialog.dart';
 import 'package:fluttergamebox/widgets/download_manager.dart';
 import 'package:shared_preferences/shared_preferences.dart';
+import 'package:window_manager/window_manager.dart';
 import 'package:fluttergamebox/widgets/info_dialogs.dart';
 import 'package:fluttergamebox/widgets/window_controls.dart';
 
@@ -42,6 +43,22 @@
     ShellNav.instance.openDetail =
         (id) => setState(() => _detailGameId = id);
     ShellNav.instance.goBack = _closeDetail;
+    // 打开首页时自动弹出系统公告(内容在管理后台设置)
+    WidgetsBinding.instance.addPostFrameCallback((_) {
+      if (mounted) _showHomeAnnouncement();
+    });
+  }
+
+  /// 打开首页自动弹出公告(无公告内容则不弹出)
+  void _showHomeAnnouncement() async {
+    final res = await ApiClient.get('/api/announcements');
+    if (!mounted || res['code'] != 0) return;
+    final data = res['data'] as List;
+    if (data.isEmpty) return;
+    final content = (data[0]['content'] ?? '').toString().trim();
+    if (content.isEmpty) return;
+    if (!mounted) return;
+    _showAnnouncementDialog(context, content);
   }
 
   @override
@@ -91,7 +108,8 @@
                 height: 3,
                 color: AppColors.bgLight,
                 child: LinearProgressIndicator(
-                  value: task.progress,
+                  // 下载阶段显示下载进度,安装(解压)阶段显示解压进度
+                  value: task.extracting ? task.extractProgress : task.progress,
                   backgroundColor: Colors.transparent,
                   color: AppColors.accent,
                 ),
@@ -133,7 +151,15 @@
 
   Widget _buildTopBar() {
     return GestureDetector(
-      onDoubleTap: () {},
+      // 拖动顶栏移动窗口;双击最大化/还原
+      onPanStart: (_) => windowManager.startDragging(),
+      onDoubleTap: () async {
+        if (await windowManager.isMaximized()) {
+          windowManager.unmaximize();
+        } else {
+          windowManager.maximize();
+        }
+      },
       child: Container(
         height: 52,
         color: const Color(0xFF191C2B),
@@ -151,12 +177,12 @@
                       height: 28,
                       color: AppColors.pink,
                       child: const Center(
-                          child: Text('99',
+                          child: Text('游',
                               style: TextStyle(
                                   color: Colors.white, fontSize: 11))))),
             ),
             const SizedBox(width: 8),
-            const Text('99游戏盒子',
+            const Text('游趣电玩',
                 style: TextStyle(
                     color: Colors.white,
                     fontSize: 14,
@@ -676,6 +702,72 @@
   }
 }
 
+/// 公告弹窗(标题+内容+关闭),首页打开与左侧栏共用
+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('知道了'),
+              ),
+            ),
+          ],
+        ),
+      ),
+    ),
+  );
+}
+
 /// 左侧浮动栏:系统公告/联系客服/常见问题
 class _LeftSidebar extends StatelessWidget {
   const _LeftSidebar();
@@ -714,26 +806,7 @@
             (res['data'] as List).isNotEmpty
         ? res['data'][0]['content']
         : '暂无公告';
-    showDialog(
-      context: context,
-      builder: (context) => AlertDialog(
-        backgroundColor: Colors.white,
-        title: const Text('系统公告',
-            style: TextStyle(color: Colors.black, fontSize: 16)),
-        content: SizedBox(
-          width: 380,
-          child: Text('$content',
-              style:
-                  const TextStyle(color: Color(0xFFE74C3C), fontSize: 13, height: 1.9)),
-        ),
-        actions: [
-          TextButton(
-            onPressed: () => Navigator.pop(context),
-            child: const Text('知道了', style: TextStyle(color: Color(0xFF2B7FFF))),
-          ),
-        ],
-      ),
-    );
+    _showAnnouncementDialog(context, '$content');
   }
 
   void _showToast2(BuildContext context, String msg) {

--
Gitblit v1.10.0