diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index a28f05f8..ed2378ba 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -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; diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 50f84151..c707b13e 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -370,13 +370,13 @@ class _ExtraSettingState extends State { 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, + // ), ], ), ); diff --git a/lib/pages/setting/widgets/switch_item.dart b/lib/pages/setting/widgets/switch_item.dart index 25991c43..2fb7c7fb 100644 --- a/lib/pages/setting/widgets/switch_item.dart +++ b/lib/pages/setting/widgets/switch_item.dart @@ -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 { 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); } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 3b5fb9d3..0700aea5 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -238,7 +238,7 @@ class SettingBoxKey { applyFilterToRelatedVideos = 'applyFilterToRelatedVideos', /// 其他 - autoUpdate = 'autoUpdate', + // autoUpdate = 'autoUpdate', autoClearCache = 'autoClearCache', defaultShowComment = 'defaultShowComment', replySortType = 'replySortType', diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 07452d1f..9951867e 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -659,92 +659,92 @@ class Utils { } // 检查更新 - static Future 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 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 {