905086
2026-11-07 7fd2270570811c0d29f0d5d87d11bfc4612e0743
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;
@@ -15,6 +16,7 @@
  final String gpuReq;
  final String ramReq;
  final String versionNote;
  final String launchExe; // 启动程序相对路径(相对游戏安装目录)
  final String cover;
  final String video;
  final List<String> screenshots;
@@ -37,6 +39,7 @@
    required this.gpuReq,
    required this.ramReq,
    required this.versionNote,
    required this.launchExe,
    required this.cover,
    required this.video,
    required this.screenshots,
@@ -75,6 +78,7 @@
      gpuReq: j['gpu_req'] ?? '',
      ramReq: j['ram_req'] ?? '',
      versionNote: j['version_note'] ?? '',
      launchExe: j['launch_exe'] ?? '',
      cover: j['cover'] ?? '',
      video: j['video'] ?? '',
      screenshots: shots,
@@ -86,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 {
@@ -115,6 +126,7 @@
  final String cover;
  final String description;
  final String fileUrl;
  final String launchExe;
  Tool({
    required this.id,
    required this.name,
@@ -122,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'],
@@ -130,6 +143,7 @@
        cover: j['cover'] ?? '',
        description: j['description'] ?? '',
        fileUrl: j['file_url'] ?? '',
        launchExe: j['launch_exe'] ?? '',
      );
}
@@ -187,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 '';