Skip to content

Commit

Permalink
💾 Feat(Download): Available to select download source
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Aug 8, 2024
1 parent 81ca60f commit 0283c61
Showing 1 changed file with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,30 @@ void downloadFile(String url) {
void beginDownload(BuildContext context, String id) {
Get.back();

var latestVersion = 'v3.23.04.6488';

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;
var fileName = 'kitx-$id.7z';

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

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

if (id.startsWith('linux')) {
url = url.replaceAll('desktop', 'linux');
canDownload = true;
switch (downloadSource.value) {
case 'GitHub':
url = 'https://github.com/Crequency/KitX/releases/latest/download/$fileName';
break;
case 'Gitee':
// ToDo: Add Gitee download source
break;
case 'Crequency':
var source = 'https://dl.catrol.cn/kitx';
url = '$source/latest/$fileName';
break;
}

if (id.endsWith('apk')) {
url = '$baseUrl/android/$latestVersion/$id';
canDownload = true;
}

if (canDownload) downloadFile(url);
downloadFile(url);
}

void showItemsDialog(BuildContext context, List<Widget> items) {
Expand Down Expand Up @@ -280,10 +273,12 @@ Widget getDownloadList(BuildContext context) {
child: const Text('GitHub'),
value: 'GitHub',
),
const DropdownMenuItem(
child: const Text('Gitee'),
value: 'Gitee',
),
// ToDo: Add Gitee download source

// const DropdownMenuItem(
// child: const Text('Gitee'),
// value: 'Gitee',
// ),
const DropdownMenuItem(
child: const Text('Crequency'),
value: 'Crequency',
Expand Down

0 comments on commit 0283c61

Please sign in to comment.