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

@@ -10,7 +10,6 @@ import 'package:PiliPalaX/pages/dynamics/index.dart';
import 'package:PiliPalaX/pages/home/view.dart';
import 'package:PiliPalaX/pages/media/index.dart';
import 'package:PiliPalaX/utils/storage.dart';
import 'package:PiliPalaX/utils/utils.dart';
import '../../models/common/dynamic_badge_mode.dart';
import '../../models/common/nav_bar_config.dart';
@@ -40,9 +39,9 @@ class MainController extends GetxController {
super.onInit();
checkDynamic = GStorage.checkDynamic;
dynamicPeriod = GStorage.dynamicPeriod;
if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
Utils.checkUpdate();
}
// if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
// Utils.checkUpdate();
// }
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
int defaultHomePage =
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0) as int;

View File

@@ -370,13 +370,13 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.autoClearCache,
defaultVal: false,
),
const SetSwitchItem(
title: '检查更新',
subTitle: '每次启动时检查是否需要更新',
leading: Icon(Icons.system_update_alt_outlined),
setKey: SettingBoxKey.autoUpdate,
defaultVal: false,
),
// const SetSwitchItem(
// title: '检查更新',
// subTitle: '每次启动时检查是否需要更新',
// leading: Icon(Icons.system_update_alt_outlined),
// setKey: SettingBoxKey.autoUpdate,
// defaultVal: false,
// ),
],
),
);

View File

@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:hive/hive.dart';
import 'package:PiliPalaX/utils/storage.dart';
import 'package:PiliPalaX/utils/utils.dart';
class SetSwitchItem extends StatefulWidget {
final String? title;
@@ -44,9 +43,9 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
void switchChange(value) async {
val = value ?? !val;
await Setting.put(widget.setKey, val);
if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
Utils.checkUpdate();
}
// if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
// Utils.checkUpdate();
// }
if (widget.callFn != null) {
widget.callFn!.call(val);
}

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 {