mod: remove in-app update

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-19 13:18:56 +08:00
parent bfb0712ca7
commit 34961e5475
5 changed files with 100 additions and 102 deletions

View File

@@ -238,7 +238,7 @@ class SettingBoxKey {
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
/// 其他
autoUpdate = 'autoUpdate',
// autoUpdate = 'autoUpdate',
autoClearCache = 'autoClearCache',
defaultShowComment = 'defaultShowComment',
replySortType = 'replySortType',

View File

@@ -659,92 +659,92 @@ class Utils {
}
// 检查更新
static Future<bool> checkUpdate() async {
SmartDialog.dismiss();
var currentInfo = await PackageInfo.fromPlatform();
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
if (result.data.isEmpty) {
SmartDialog.showToast('检查更新失败github接口未返回数据请检查网络');
return false;
}
LatestDataModel data = LatestDataModel.fromJson(result.data[0]);
String buildNumber = currentInfo.buildNumber;
String remoteVersion = data.tagName!;
if (Platform.isAndroid) {
buildNumber = buildNumber.substring(0, buildNumber.length - 1);
} else if (Platform.isIOS) {
remoteVersion = remoteVersion.replaceAll('-beta', '');
}
bool isUpdate =
Utils.needUpdate("${currentInfo.version}+$buildNumber", remoteVersion);
if (isUpdate) {
SmartDialog.show(
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (context) {
return AlertDialog(
title: const Text('🎉 发现新版本 '),
content: SizedBox(
height: 280,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
data.tagName!,
style: const TextStyle(fontSize: 20),
),
const SizedBox(height: 8),
Text(data.body!),
TextButton(
onPressed: () {
launchUrl(
Uri.parse(
"https://github.com/bggRGjQaUbCoE/PiliPalaX/commits/main/"),
mode: LaunchMode.externalApplication,
);
},
child: Text(
"点此查看完整更新即commit内容",
style: TextStyle(
color: Theme.of(context).colorScheme.primary),
)),
],
),
),
),
actions: [
TextButton(
onPressed: () {
GStorage.setting.put(SettingBoxKey.autoUpdate, false);
SmartDialog.dismiss();
},
child: Text(
'不再提醒',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style:
TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () => matchVersion(data),
child: const Text('Github'),
),
],
);
},
);
}
return true;
}
// static Future<bool> checkUpdate() async {
// SmartDialog.dismiss();
// var currentInfo = await PackageInfo.fromPlatform();
// var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
// if (result.data.isEmpty) {
// SmartDialog.showToast('检查更新失败github接口未返回数据请检查网络');
// return false;
// }
// LatestDataModel data = LatestDataModel.fromJson(result.data[0]);
// String buildNumber = currentInfo.buildNumber;
// String remoteVersion = data.tagName!;
// if (Platform.isAndroid) {
// buildNumber = buildNumber.substring(0, buildNumber.length - 1);
// } else if (Platform.isIOS) {
// remoteVersion = remoteVersion.replaceAll('-beta', '');
// }
// bool isUpdate =
// Utils.needUpdate("${currentInfo.version}+$buildNumber", remoteVersion);
// if (isUpdate) {
// SmartDialog.show(
// animationType: SmartAnimationType.centerFade_otherSlide,
// builder: (context) {
// return AlertDialog(
// title: const Text('🎉 发现新版本 '),
// content: SizedBox(
// height: 280,
// child: SingleChildScrollView(
// child: Column(
// mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// data.tagName!,
// style: const TextStyle(fontSize: 20),
// ),
// const SizedBox(height: 8),
// Text(data.body!),
// TextButton(
// onPressed: () {
// launchUrl(
// Uri.parse(
// "https://github.com/bggRGjQaUbCoE/PiliPalaX/commits/main/"),
// mode: LaunchMode.externalApplication,
// );
// },
// child: Text(
// "点此查看完整更新即commit内容",
// style: TextStyle(
// color: Theme.of(context).colorScheme.primary),
// )),
// ],
// ),
// ),
// ),
// actions: [
// TextButton(
// onPressed: () {
// GStorage.setting.put(SettingBoxKey.autoUpdate, false);
// SmartDialog.dismiss();
// },
// child: Text(
// '不再提醒',
// style:
// TextStyle(color: Theme.of(context).colorScheme.outline),
// ),
// ),
// TextButton(
// onPressed: () => SmartDialog.dismiss(),
// child: Text(
// '取消',
// style:
// TextStyle(color: Theme.of(context).colorScheme.outline),
// ),
// ),
// TextButton(
// onPressed: () => matchVersion(data),
// child: const Text('Github'),
// ),
// ],
// );
// },
// );
// }
// return true;
// }
// 下载适用于当前系统的安装包
static Future matchVersion(data) async {