905086
2026-11-07 0b4478cf6c0eb509c95a9bec2cc7bda37b259e10
fluttergamebox/lib/pages/login_page.dart
@@ -1,13 +1,10 @@
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/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});
@@ -43,13 +40,7 @@
      if (res['code'] == 0) {
        await ApiClient.saveToken(res['data']['token']);
        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 +81,7 @@
                        errorBuilder: (_, __, ___) => Container(
                          color: const Color(0xFF1B1E2E),
                          child: const Center(
                            child: Text('99游戏盒子',
                            child: Text('游趣电玩',
                                style: TextStyle(
                                    color: AppColors.pink,
                                    fontSize: 40,
@@ -364,68 +355,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('知道了'),
              ),
            ),
          ],
        ),
      ),
    ),
  );
}