diff --git a/lib/pages/about/index.dart b/lib/pages/about/index.dart index 04a5efec..34bfda13 100644 --- a/lib/pages/about/index.dart +++ b/lib/pages/about/index.dart @@ -47,6 +47,11 @@ class _AboutPageState extends State { 'PiliPala', style: Theme.of(context).textTheme.titleMedium, ), + const SizedBox(height: 6), + Text( + '使用Flutter开发的哔哩哔哩第三方客户端', + style: TextStyle(color: Theme.of(context).colorScheme.outline), + ), const SizedBox(height: 20), Obx( () => ListTile( @@ -82,16 +87,6 @@ class _AboutPageState extends State { height: 30, color: Theme.of(context).colorScheme.onInverseSurface, ), - ListTile( - onTap: () {}, - title: const Text('作者'), - trailing: Text('guozhigq', style: subTitleStyle), - ), - ListTile( - onTap: () {}, - title: const Text('酷安'), - trailing: Text('影若风', style: subTitleStyle), - ), ListTile( onTap: () => _aboutController.githubUrl(), title: const Text('Github'), @@ -123,6 +118,11 @@ class _AboutPageState extends State { title: const Text('TG频道'), trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline), ), + ListTile( + onTap: () => _aboutController.aPay(), + title: const Text('赞助'), + trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline), + ), Divider( thickness: 8, height: 30, @@ -141,11 +141,12 @@ class AboutController extends GetxController { late LatestDataModel remoteAppInfo; RxBool isUpdate = true.obs; RxBool isLoading = true.obs; + late LatestDataModel data; @override void onInit() { super.onInit(); - init(); + // init(); // 获取当前版本 getCurrentApp(); // 获取最新的版本 @@ -153,16 +154,16 @@ class AboutController extends GetxController { } // 获取设备信息 - Future init() async { - DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - if (Platform.isAndroid) { - AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; - print(androidInfo.supportedAbis); - } else if (Platform.isIOS) { - IosDeviceInfo iosInfo = await deviceInfo.iosInfo; - print(iosInfo); - } - } + // Future init() async { + // DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); + // if (Platform.isAndroid) { + // AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; + // print(androidInfo.supportedAbis); + // } else if (Platform.isIOS) { + // IosDeviceInfo iosInfo = await deviceInfo.iosInfo; + // print(iosInfo); + // } + // } // 获取当前版本 Future getCurrentApp() async { @@ -173,7 +174,7 @@ class AboutController extends GetxController { // 获取远程版本 Future getRemoteApp() async { var result = await Request().get(Api.latestApp); - LatestDataModel data = LatestDataModel.fromJson(result.data); + data = LatestDataModel.fromJson(result.data); remoteAppInfo = data; remoteVersion.value = data.tagName!; isUpdate.value = @@ -183,15 +184,7 @@ class AboutController extends GetxController { // 跳转下载/本地更新 Future onUpdate() async { - // final dir = await getApplicationSupportDirectory(); - // final path = '${dir.path}/pilipala.apk'; - // var result = await Request() - // .downloadFile(remoteAppInfo.assets!.first.downloadUrl, path); - // print(result); - launchUrl( - Uri.parse('https://github.com/guozhigq/pilipala/releases'), - mode: LaunchMode.externalApplication, - ); + Utils.matchVersion(data); } // 跳转github @@ -242,4 +235,16 @@ class AboutController extends GetxController { ), ); } + + aPay() { + try { + launchUrl( + Uri.parse( + 'alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx14623ddwl1ping3ddd73'), + mode: LaunchMode.externalApplication, + ); + } catch (e) { + print(e); + } + } } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index cb32b38e..27310d31 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:io'; import 'dart:math'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get_utils/get_utils.dart'; @@ -210,6 +211,7 @@ class Utils { bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!); if (isUpdate) { SmartDialog.show( + animationType: SmartAnimationType.centerFade_otherSlide, builder: (context) { return AlertDialog( title: const Text('🎉 发现新版本 '), @@ -228,22 +230,27 @@ class Utils { ), actions: [ TextButton( - onPressed: () => SmartDialog.dismiss(), - child: Text( - '稍后', - style: - TextStyle(color: Theme.of(context).colorScheme.outline), - )), + onPressed: () => SmartDialog.dismiss(), + child: Text( + '稍后', + style: + TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), TextButton( - onPressed: () async { - await SmartDialog.dismiss(); - launchUrl( - Uri.parse( - 'https://github.com/guozhigq/pilipala/releases'), - mode: LaunchMode.externalApplication, - ); - }, - child: const Text('去下载')), + onPressed: () async { + await SmartDialog.dismiss(); + launchUrl( + Uri.parse('https://www.123pan.com/s/9sVqVv-flu0A.html'), + mode: LaunchMode.externalApplication, + ); + }, + child: const Text('网盘下载'), + ), + TextButton( + onPressed: () => matchVersion(data), + child: const Text('Github下载'), + ), ], ); }, @@ -251,4 +258,27 @@ class Utils { } return true; } + + // 下载适用于当前系统的安装包 + static Future matchVersion(data) async { + await SmartDialog.dismiss(); + // 获取设备信息 + DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); + if (Platform.isAndroid) { + AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; + // [arm64-v8a] + String abi = androidInfo.supportedAbis.first; + late String downloadUrl; + for (var i in data.assets) { + if (i.downloadUrl.contains(abi)) { + downloadUrl = i.downloadUrl; + } + } + // 应用外下载 + launchUrl( + Uri.parse(downloadUrl), + mode: LaunchMode.externalApplication, + ); + } + } }