905086
2026-11-08 b1e9aef9d2698cf27eccde2f131eae3c4e6a65d0
fluttergamebox/lib/api/api_service.dart
@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:fluttergamebox/api/api_client.dart';
import 'package:fluttergamebox/utils/util.dart' show parseGb;
class Game {
  final int id;
@@ -89,6 +90,13 @@
  }
  String get platformLabel => platform == 'switch' ? 'Switch资源' : 'PC资源';
  /// 下载所需磁盘空间(GB):优先"磁盘占用",未设置时回退"游戏大小"
  double get requiredDiskGb {
    final install = parseGb(installSize);
    if (install > 0) return install;
    return parseGb(size);
  }
}
class GameFile {
@@ -118,6 +126,7 @@
  final String cover;
  final String description;
  final String fileUrl;
  final String launchExe;
  Tool({
    required this.id,
    required this.name,
@@ -125,6 +134,7 @@
    required this.cover,
    required this.description,
    required this.fileUrl,
    this.launchExe = '',
  });
  factory Tool.fromJson(Map<String, dynamic> j) => Tool(
        id: j['id'],
@@ -133,6 +143,7 @@
        cover: j['cover'] ?? '',
        description: j['description'] ?? '',
        fileUrl: j['file_url'] ?? '',
        launchExe: j['launch_exe'] ?? '',
      );
}
@@ -190,6 +201,9 @@
    return (res['data'] as List).map((e) => Tool.fromJson(e)).toList();
  }
  static Future<Map<String, dynamic>> toolDownloadInfo(int toolId) async =>
      await ApiClient.get('/api/tools/$toolId/download');
  static Future<String> announcements() async {
    final res = await ApiClient.get('/api/announcements');
    if (res['code'] != 0) return '';