mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: remove in-app update
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -10,7 +10,6 @@ import 'package:PiliPalaX/pages/dynamics/index.dart';
|
|||||||
import 'package:PiliPalaX/pages/home/view.dart';
|
import 'package:PiliPalaX/pages/home/view.dart';
|
||||||
import 'package:PiliPalaX/pages/media/index.dart';
|
import 'package:PiliPalaX/pages/media/index.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
|
||||||
import '../../models/common/dynamic_badge_mode.dart';
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
import '../../models/common/nav_bar_config.dart';
|
import '../../models/common/nav_bar_config.dart';
|
||||||
|
|
||||||
@@ -40,9 +39,9 @@ class MainController extends GetxController {
|
|||||||
super.onInit();
|
super.onInit();
|
||||||
checkDynamic = GStorage.checkDynamic;
|
checkDynamic = GStorage.checkDynamic;
|
||||||
dynamicPeriod = GStorage.dynamicPeriod;
|
dynamicPeriod = GStorage.dynamicPeriod;
|
||||||
if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
|
// if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
|
||||||
Utils.checkUpdate();
|
// Utils.checkUpdate();
|
||||||
}
|
// }
|
||||||
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
||||||
int defaultHomePage =
|
int defaultHomePage =
|
||||||
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0) as int;
|
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0) as int;
|
||||||
|
|||||||
@@ -370,13 +370,13 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.autoClearCache,
|
setKey: SettingBoxKey.autoClearCache,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
// const SetSwitchItem(
|
||||||
title: '检查更新',
|
// title: '检查更新',
|
||||||
subTitle: '每次启动时检查是否需要更新',
|
// subTitle: '每次启动时检查是否需要更新',
|
||||||
leading: Icon(Icons.system_update_alt_outlined),
|
// leading: Icon(Icons.system_update_alt_outlined),
|
||||||
setKey: SettingBoxKey.autoUpdate,
|
// setKey: SettingBoxKey.autoUpdate,
|
||||||
defaultVal: false,
|
// defaultVal: false,
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
|
||||||
|
|
||||||
class SetSwitchItem extends StatefulWidget {
|
class SetSwitchItem extends StatefulWidget {
|
||||||
final String? title;
|
final String? title;
|
||||||
@@ -44,9 +43,9 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
|||||||
void switchChange(value) async {
|
void switchChange(value) async {
|
||||||
val = value ?? !val;
|
val = value ?? !val;
|
||||||
await Setting.put(widget.setKey, val);
|
await Setting.put(widget.setKey, val);
|
||||||
if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
|
// if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
|
||||||
Utils.checkUpdate();
|
// Utils.checkUpdate();
|
||||||
}
|
// }
|
||||||
if (widget.callFn != null) {
|
if (widget.callFn != null) {
|
||||||
widget.callFn!.call(val);
|
widget.callFn!.call(val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class SettingBoxKey {
|
|||||||
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
|
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
|
||||||
|
|
||||||
/// 其他
|
/// 其他
|
||||||
autoUpdate = 'autoUpdate',
|
// autoUpdate = 'autoUpdate',
|
||||||
autoClearCache = 'autoClearCache',
|
autoClearCache = 'autoClearCache',
|
||||||
defaultShowComment = 'defaultShowComment',
|
defaultShowComment = 'defaultShowComment',
|
||||||
replySortType = 'replySortType',
|
replySortType = 'replySortType',
|
||||||
|
|||||||
@@ -659,92 +659,92 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查更新
|
// 检查更新
|
||||||
static Future<bool> checkUpdate() async {
|
// static Future<bool> checkUpdate() async {
|
||||||
SmartDialog.dismiss();
|
// SmartDialog.dismiss();
|
||||||
var currentInfo = await PackageInfo.fromPlatform();
|
// var currentInfo = await PackageInfo.fromPlatform();
|
||||||
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
// var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
||||||
if (result.data.isEmpty) {
|
// if (result.data.isEmpty) {
|
||||||
SmartDialog.showToast('检查更新失败,github接口未返回数据,请检查网络');
|
// SmartDialog.showToast('检查更新失败,github接口未返回数据,请检查网络');
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
LatestDataModel data = LatestDataModel.fromJson(result.data[0]);
|
// LatestDataModel data = LatestDataModel.fromJson(result.data[0]);
|
||||||
String buildNumber = currentInfo.buildNumber;
|
// String buildNumber = currentInfo.buildNumber;
|
||||||
String remoteVersion = data.tagName!;
|
// String remoteVersion = data.tagName!;
|
||||||
if (Platform.isAndroid) {
|
// if (Platform.isAndroid) {
|
||||||
buildNumber = buildNumber.substring(0, buildNumber.length - 1);
|
// buildNumber = buildNumber.substring(0, buildNumber.length - 1);
|
||||||
} else if (Platform.isIOS) {
|
// } else if (Platform.isIOS) {
|
||||||
remoteVersion = remoteVersion.replaceAll('-beta', '');
|
// remoteVersion = remoteVersion.replaceAll('-beta', '');
|
||||||
}
|
// }
|
||||||
bool isUpdate =
|
// bool isUpdate =
|
||||||
Utils.needUpdate("${currentInfo.version}+$buildNumber", remoteVersion);
|
// Utils.needUpdate("${currentInfo.version}+$buildNumber", remoteVersion);
|
||||||
if (isUpdate) {
|
// if (isUpdate) {
|
||||||
SmartDialog.show(
|
// SmartDialog.show(
|
||||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
// animationType: SmartAnimationType.centerFade_otherSlide,
|
||||||
builder: (context) {
|
// builder: (context) {
|
||||||
return AlertDialog(
|
// return AlertDialog(
|
||||||
title: const Text('🎉 发现新版本 '),
|
// title: const Text('🎉 发现新版本 '),
|
||||||
content: SizedBox(
|
// content: SizedBox(
|
||||||
height: 280,
|
// height: 280,
|
||||||
child: SingleChildScrollView(
|
// child: SingleChildScrollView(
|
||||||
child: Column(
|
// child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
// mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
Text(
|
// Text(
|
||||||
data.tagName!,
|
// data.tagName!,
|
||||||
style: const TextStyle(fontSize: 20),
|
// style: const TextStyle(fontSize: 20),
|
||||||
),
|
// ),
|
||||||
const SizedBox(height: 8),
|
// const SizedBox(height: 8),
|
||||||
Text(data.body!),
|
// Text(data.body!),
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
launchUrl(
|
// launchUrl(
|
||||||
Uri.parse(
|
// Uri.parse(
|
||||||
"https://github.com/bggRGjQaUbCoE/PiliPalaX/commits/main/"),
|
// "https://github.com/bggRGjQaUbCoE/PiliPalaX/commits/main/"),
|
||||||
mode: LaunchMode.externalApplication,
|
// mode: LaunchMode.externalApplication,
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
child: Text(
|
// child: Text(
|
||||||
"点此查看完整更新(即commit)内容",
|
// "点此查看完整更新(即commit)内容",
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary),
|
// color: Theme.of(context).colorScheme.primary),
|
||||||
)),
|
// )),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
actions: [
|
// actions: [
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () {
|
// onPressed: () {
|
||||||
GStorage.setting.put(SettingBoxKey.autoUpdate, false);
|
// GStorage.setting.put(SettingBoxKey.autoUpdate, false);
|
||||||
SmartDialog.dismiss();
|
// SmartDialog.dismiss();
|
||||||
},
|
// },
|
||||||
child: Text(
|
// child: Text(
|
||||||
'不再提醒',
|
// '不再提醒',
|
||||||
style:
|
// style:
|
||||||
TextStyle(color: Theme.of(context).colorScheme.outline),
|
// TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () => SmartDialog.dismiss(),
|
// onPressed: () => SmartDialog.dismiss(),
|
||||||
child: Text(
|
// child: Text(
|
||||||
'取消',
|
// '取消',
|
||||||
style:
|
// style:
|
||||||
TextStyle(color: Theme.of(context).colorScheme.outline),
|
// TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
TextButton(
|
// TextButton(
|
||||||
onPressed: () => matchVersion(data),
|
// onPressed: () => matchVersion(data),
|
||||||
child: const Text('Github'),
|
// child: const Text('Github'),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 下载适用于当前系统的安装包
|
// 下载适用于当前系统的安装包
|
||||||
static Future matchVersion(data) async {
|
static Future matchVersion(data) async {
|
||||||
|
|||||||
Reference in New Issue
Block a user