| | |
| | | ], |
| | | ), |
| | | ) |
| | | : GridView.builder( |
| | | : LayoutBuilder(builder: (context, constraints) { |
| | | // 卡片高度 = 封面高度 + 信息区实际内容高度,避免出现大段空白 |
| | | const crossAxisSpacing = 16.0; |
| | | final cardWidth = |
| | | (constraints.maxWidth - crossAxisSpacing * 4) / 5; |
| | | final coverHeight = cardWidth / 1.42; |
| | | const infoHeight = 92.0; |
| | | return GridView.builder( |
| | | padding: const EdgeInsets.only(bottom: 40), |
| | | gridDelegate: |
| | | const SliverGridDelegateWithFixedCrossAxisCount( |
| | | SliverGridDelegateWithFixedCrossAxisCount( |
| | | crossAxisCount: 5, |
| | | mainAxisSpacing: 18, |
| | | crossAxisSpacing: 16, |
| | | childAspectRatio: 0.60, |
| | | crossAxisSpacing: crossAxisSpacing, |
| | | mainAxisExtent: coverHeight + infoHeight, |
| | | ), |
| | | itemCount: filtered.length, |
| | | itemBuilder: (context, i) => |
| | | _LibraryCard(game: filtered[i], onRemove: _load), |
| | | ), |
| | | ); |
| | | }), |
| | | ), |
| | | ], |
| | | ), |
| | |
| | | |
| | | Future<void> _launch(BuildContext context) async { |
| | | final dir = await _installDir(); |
| | | // 尝试查找目录中的exe并启动(启动已下载的游戏不需要会员) |
| | | final d = Directory(dir); |
| | | if (await d.exists()) { |
| | | // 优先启动管理端设置的启动程序 |
| | | if (game.launchExe.isNotEmpty) { |
| | | final exe = File(p.join(dir, game.launchExe)); |
| | | if (await exe.exists()) { |
| | | Process.run(exe.path, [], |
| | | workingDirectory: p.dirname(exe.path)); |
| | | return; |
| | | } |
| | | } |
| | | // 未设置或找不到时,尝试查找目录中的exe并启动(启动已下载的游戏不需要会员) |
| | | final exes = d |
| | | .listSync(recursive: false) |
| | | .whereType<File>() |