| | |
| | | import 'dart:convert'; |
| | | import 'package:fluttergamebox/api/api_client.dart'; |
| | | import 'package:fluttergamebox/utils/util.dart' show parseGb; |
| | | |
| | | class Game { |
| | | final int id; |
| | |
| | | } |
| | | |
| | | 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 { |
| | |
| | | final String cover; |
| | | final String description; |
| | | final String fileUrl; |
| | | final String launchExe; |
| | | Tool({ |
| | | required this.id, |
| | | required this.name, |
| | |
| | | required this.cover, |
| | | required this.description, |
| | | required this.fileUrl, |
| | | this.launchExe = '', |
| | | }); |
| | | factory Tool.fromJson(Map<String, dynamic> j) => Tool( |
| | | id: j['id'], |
| | |
| | | cover: j['cover'] ?? '', |
| | | description: j['description'] ?? '', |
| | | fileUrl: j['file_url'] ?? '', |
| | | launchExe: j['launch_exe'] ?? '', |
| | | ); |
| | | } |
| | | |
| | |
| | | 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 ''; |