mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
添加异常测试功能
增加隐藏设置页 修复无法跳转到隐藏设置页面
This commit is contained in:
@@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:pilipala/http/index.dart';
|
||||
import 'package:pilipala/models/github/latest.dart';
|
||||
import 'package:pilipala/pages/setting/controller.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../utils/cache_manage.dart';
|
||||
@@ -64,6 +67,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
),
|
||||
Obx(
|
||||
() => ListTile(
|
||||
onTap: () => _aboutController.tapOnVersion(),
|
||||
title: const Text('当前版本'),
|
||||
trailing: Text(_aboutController.currentVersion.value,
|
||||
style: subTitleStyle),
|
||||
@@ -174,12 +178,15 @@ class _AboutPageState extends State<AboutPage> {
|
||||
}
|
||||
|
||||
class AboutController extends GetxController {
|
||||
Box setting = GStrorage.setting;
|
||||
final SettingController settingController = Get.put(SettingController());
|
||||
RxString currentVersion = ''.obs;
|
||||
RxString remoteVersion = ''.obs;
|
||||
late LatestDataModel remoteAppInfo;
|
||||
RxBool isUpdate = true.obs;
|
||||
RxBool isLoading = true.obs;
|
||||
late LatestDataModel data;
|
||||
RxInt count = 0.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -298,4 +305,16 @@ class AboutController extends GetxController {
|
||||
logs() {
|
||||
Get.toNamed('/logs');
|
||||
}
|
||||
|
||||
tapOnVersion() {
|
||||
if (settingController.hiddenSettingUnlocked.value) {
|
||||
SmartDialog.showToast('您已解锁隐藏设置, 无需再次操作');
|
||||
return;
|
||||
}
|
||||
count.value++;
|
||||
if (count.value == 5) {
|
||||
setting.put(SettingBoxKey.hiddenSettingUnlocked, true);
|
||||
SmartDialog.showToast('恭喜您发现了隐藏设置!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class SettingController extends GetxController {
|
||||
Box localCache = GStrorage.localCache;
|
||||
|
||||
RxBool userLogin = false.obs;
|
||||
RxBool hiddenSettingUnlocked = false.obs;
|
||||
RxBool feedBackEnable = false.obs;
|
||||
RxDouble toastOpacity = (1.0).obs;
|
||||
RxInt picQuality = 10.obs;
|
||||
@@ -29,6 +30,7 @@ class SettingController extends GetxController {
|
||||
super.onInit();
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin.value = userInfo != null;
|
||||
hiddenSettingUnlocked.value = setting.get(SettingBoxKey.hiddenSettingUnlocked, defaultValue: false);
|
||||
feedBackEnable.value =
|
||||
setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
|
||||
toastOpacity.value =
|
||||
|
||||
85
lib/pages/setting/hidden_settings.dart
Normal file
85
lib/pages/setting/hidden_settings.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
class HiddenSetting extends StatefulWidget {
|
||||
const HiddenSetting({super.key});
|
||||
|
||||
@override
|
||||
State<HiddenSetting> createState() => _HiddenSettingState();
|
||||
}
|
||||
|
||||
class _HiddenSettingState extends State<HiddenSetting> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void test(Object? val) {
|
||||
print(val);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TextStyle titleStyle = Theme.of(context).textTheme.titleMedium!;
|
||||
TextStyle subTitleStyle = Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(color: Theme.of(context).colorScheme.outline);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
title: Text(
|
||||
'隐藏设置',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {
|
||||
RxInt zero = 0.obs;
|
||||
1 / zero.value;
|
||||
},
|
||||
dense: false,
|
||||
title: Text('产生除以0异常', style: titleStyle),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
List list = [];
|
||||
test(list[0]);
|
||||
},
|
||||
dense: false,
|
||||
title: Text('产生数组越界异常', style: titleStyle),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
RxInt? integer;
|
||||
test(integer!.value);
|
||||
},
|
||||
dense: false,
|
||||
title: Text('产生空异常', style: titleStyle),
|
||||
subtitle: Text('空安全: 喵喵喵?', style: subTitleStyle),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
int.parse("壹");
|
||||
},
|
||||
dense: false,
|
||||
title: Text('产生整数解析异常', style: titleStyle),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
throw Exception("测试异常");
|
||||
},
|
||||
dense: false,
|
||||
title: Text('产生测试异常', style: titleStyle),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,16 @@ class SettingPage extends StatelessWidget {
|
||||
dense: false,
|
||||
title: const Text('其他设置'),
|
||||
),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: settingController.hiddenSettingUnlocked.value,
|
||||
child: ListTile(
|
||||
onTap: () => Get.toNamed('/hiddenSetting'),
|
||||
dense: false,
|
||||
title: const Text('隐藏设置'),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: settingController.userLogin.value,
|
||||
|
||||
@@ -47,6 +47,7 @@ import '../pages/setting/recommend_setting.dart';
|
||||
import '../pages/setting/play_setting.dart';
|
||||
import '../pages/setting/privacy_setting.dart';
|
||||
import '../pages/setting/style_setting.dart';
|
||||
import '../pages/setting/hidden_settings.dart';
|
||||
import '../pages/video/detail/index.dart';
|
||||
import '../pages/video/detail/reply_reply/index.dart';
|
||||
import '../pages/webview/index.dart';
|
||||
@@ -121,6 +122,8 @@ class Routes {
|
||||
//
|
||||
CustomGetPage(name: '/blackListPage', page: () => const BlackListPage()),
|
||||
CustomGetPage(name: '/colorSetting', page: () => const ColorSelectPage()),
|
||||
// 隐藏设置
|
||||
CustomGetPage(name: '/hiddenSetting', page: () => const HiddenSetting()),
|
||||
// 首页tabbar
|
||||
CustomGetPage(name: '/tabbarSetting', page: () => const TabbarSetPage()),
|
||||
CustomGetPage(
|
||||
|
||||
@@ -138,7 +138,8 @@ class SettingBoxKey {
|
||||
hideSearchBar = 'hideSearchBar', // 收起顶栏
|
||||
hideTabBar = 'hideTabBar', // 收起底栏
|
||||
tabbarSort = 'tabbarSort', // 首页tabbar
|
||||
dynamicBadgeMode = 'dynamicBadgeMode';
|
||||
dynamicBadgeMode = 'dynamicBadgeMode',
|
||||
hiddenSettingUnlocked = 'hiddenSettingUnlocked';
|
||||
}
|
||||
|
||||
class LocalCacheKey {
|
||||
|
||||
Reference in New Issue
Block a user