| | |
| | | |
| | | Future<void> _download() async { |
| | | if (game == null) return; |
| | | // 检查下载路径 |
| | | var dlPath = await AppPrefs.getDownloadPath(); |
| | | if (dlPath.isEmpty) { |
| | | // 每次下载前都弹出选择下载安装路径 |
| | | final ok = await _askDownloadPath(); |
| | | if (!ok) return; |
| | | dlPath = await AppPrefs.getDownloadPath(); |
| | | } |
| | | // 会员校验+开始下载 |
| | | try { |
| | | await DownloadManager.instance.startDownload(game!); |
| | |
| | | } |
| | | } |
| | | |
| | | /// 首次下载询问下载路径 |
| | | /// 下载前选择下载安装路径 |
| | | Future<bool> _askDownloadPath() async { |
| | | final res = await ApiService.downloadInfo(widget.gameId); |
| | | if (res['code'] != 0) { |
| | | if (mounted) _toast(res['msg'] ?? '无法下载', error: true); |
| | | return false; |
| | | } |
| | | final result = await showDialog<bool>( |
| | | context: context, |
| | | builder: (context) => _DownloadPathDialog(gameTitle: game!.title), |