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 |  106 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 85 insertions(+), 21 deletions(-)

diff --git a/fluttergamebox/lib/pages/main_shell.dart b/fluttergamebox/lib/pages/main_shell.dart
index 3b0088f..b02184b 100644
--- a/fluttergamebox/lib/pages/main_shell.dart
+++ b/fluttergamebox/lib/pages/main_shell.dart
@@ -43,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
@@ -92,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,
                 ),
@@ -685,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();
@@ -723,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