Skip to content

Commit

Permalink
💾 Feat(HomePage): You can download files now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Mar 12, 2023
1 parent 74929ac commit c584f30
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions KitX Website Flutter/kitx_website/lib/pages/home_page.dart
Expand Up @@ -58,14 +58,51 @@ class _HomePageState extends State<HomePage> {
);
}

void downloadFile(String url) {
AnchorElement(href: url)
..download = url
..click();
}

void beginDownload(BuildContext context, String id) {
Get.back();
showItemsDialog(
context,
[
const Text('当前尚未发布, 官网下载项暂不可用, 您可前往 GitHub 仓库 Release 页面下载测试版'),
],
);

var latestVersion = 'v3.22.04.6287';

var baseUrl = 'https://source.catrol.cn/download/apps/kitx';

if (id.contains('.pubxml')) id = id.replaceAll('.pubxml', '');

var url = '$baseUrl/desktop/$latestVersion/kitx-$id.7z';

var canDownload = false;

if (id.startsWith('win')) {
url = url.replaceAll('desktop', 'win');
canDownload = true;
}

if (id.startsWith('osx')) {
url = url.replaceAll('desktop', 'osx');
canDownload = true;
}

if (id.startsWith('linux')) {
url = url.replaceAll('desktop', 'linux');
canDownload = true;
}

if (id.endsWith('apk')) {
showItemsDialog(
context,
[
const Text('当前尚未发布, 官网下载项暂不可用, 您可前往 GitHub 仓库 Release 页面下载测试版'),
],
);
canDownload = false;
}

if (canDownload) downloadFile(url);
}

@override
Expand Down

0 comments on commit c584f30

Please sign in to comment.