From ba14e56cebf5c9ad4141a3033216797c6a7f347b Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 21 Aug 2025 14:07:18 +0800 Subject: [PATCH] fix #1061 opt `FollowingsFollowedUpper` url Closes #1061 Closes #1062 Signed-off-by: bggRGjQaUbCoE --- lib/pages/about/view.dart | 8 +++++--- lib/pages/emote/view.dart | 17 ++++++++++------- lib/pages/member/widget/user_info_card.dart | 7 ++++++- lib/pages/search/controller.dart | 4 +++- lib/pages/search/view.dart | 13 +++++++++---- lib/pages/webdav/view.dart | 1 - lib/utils/storage.dart | 7 ++++--- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/lib/pages/about/view.dart b/lib/pages/about/view.dart index ca6627df..4570172c 100644 --- a/lib/pages/about/view.dart +++ b/lib/pages/about/view.dart @@ -244,6 +244,7 @@ Commit Hash: ${BuildConfig.commitHash}''', if (Accounts.main.isLogin) { await LoginUtils.onLoginMain(); } + return true; }, ), ), @@ -313,7 +314,7 @@ Future showInportExportDialog( required String title, String? label, required String Function() toJson, - required FutureOr Function(T json) fromJson, + required FutureOr Function(T json) fromJson, }) => showDialog( context: context, builder: (context) { @@ -426,8 +427,9 @@ Future showInportExportDialog( onPressed: () async { Get.back(); try { - await fromJson(json); - SmartDialog.showToast('导入成功'); + if (await fromJson(json)) { + SmartDialog.showToast('导入成功'); + } } catch (e) { SmartDialog.showToast('导入失败:$e'); } diff --git a/lib/pages/emote/view.dart b/lib/pages/emote/view.dart index 3c9d8134..39e19f1b 100644 --- a/lib/pages/emote/view.dart +++ b/lib/pages/emote/view.dart @@ -171,13 +171,16 @@ class _EmotePanelState extends State .withValues(alpha: 0.8), bgColor: Colors.transparent, context: context, - onPressed: () => Get.toNamed( - '/webview', - parameters: { - 'url': - 'https://www.bilibili.com/h5/mall/emoji-package/home?navhide=1&native.theme=1&night=${Get.isDarkMode ? 1 : 0}', - }, - ), + onPressed: () { + final isDark = Get.isDarkMode; + Get.toNamed( + '/webview', + parameters: { + 'url': + 'https://www.bilibili.com/h5/mall/emoji-package/home?navhide=1&native.theme=${isDark ? 2 : 1}&night=${isDark ? 1 : 0}', + }, + ); + }, icon: Icons.settings, ), ), diff --git a/lib/pages/member/widget/user_info_card.dart b/lib/pages/member/widget/user_info_card.dart index 3b7a561e..306848a9 100644 --- a/lib/pages/member/widget/user_info_card.dart +++ b/lib/pages/member/widget/user_info_card.dart @@ -645,7 +645,12 @@ class UserInfoCard extends StatelessWidget { ); if (item.jumpUrl?.isNotEmpty == true) { return GestureDetector( - onTap: () => PageUtils.handleWebview(item.jumpUrl!), + onTap: () { + final isDark = Get.isDarkMode; + PageUtils.handleWebview( + '${item.jumpUrl}&native.theme=${isDark ? 2 : 1}&night=${isDark ? 1 : 0}', + ); + }, child: child, ); } diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 1d09610b..c69807ac 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -150,6 +150,7 @@ class SSearchController extends GetxController historyList ..remove(controller.text) ..insert(0, controller.text); + GStorage.historyWord.put('cacheList', historyList); } searchFocusNode.unfocus(); @@ -197,6 +198,7 @@ class SSearchController extends GetxController void onLongSelect(String word) { historyList.remove(word); + GStorage.historyWord.put('cacheList', historyList); } void onClearHistory() { @@ -205,13 +207,13 @@ class SSearchController extends GetxController title: '确定清空搜索历史?', onConfirm: () { historyList.clear(); + GStorage.historyWord.delete('cacheList'); }, ); } @override void onClose() { - GStorage.historyWord.put('cacheList', historyList); subDispose(); searchFocusNode.dispose(); controller.dispose(); diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index 57e5b692..21491eeb 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -14,6 +14,7 @@ import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart' hide ContextExtensionss; class SearchPage extends StatefulWidget { @@ -394,15 +395,19 @@ class _SearchPageState extends State { Icons.import_export_outlined, color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.8), ), - style: IconButton.styleFrom( - padding: EdgeInsets.zero, - ), + style: IconButton.styleFrom(padding: EdgeInsets.zero), onPressed: () => showInportExportDialog( context, title: '历史记录', toJson: () => jsonEncode(_searchController.historyList), fromJson: (json) { - _searchController.historyList.value = json.cast(); + try { + _searchController.historyList.value = List.from(json); + return true; + } catch (e) { + SmartDialog.showToast(e.toString()); + return false; + } }, ), ), diff --git a/lib/pages/webdav/view.dart b/lib/pages/webdav/view.dart index 5780c8ee..c8ebb1c5 100644 --- a/lib/pages/webdav/view.dart +++ b/lib/pages/webdav/view.dart @@ -38,7 +38,6 @@ class _WebDavSettingPageState extends State { Widget build(BuildContext context) { EdgeInsets padding = MediaQuery.viewPaddingOf(context); return Scaffold( - resizeToAvoidBottomInset: widget.showAppBar, appBar: !widget.showAppBar ? null : AppBar(title: const Text('WebDAV 设置')), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index e3d88fb5..3744c844 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -14,7 +14,7 @@ import 'package:path_provider/path_provider.dart'; class GStorage { static late final Box userInfo; - static late final Box> historyWord; + static late final Box historyWord; static late final Box localCache; static late final Box setting; static late final Box video; @@ -41,7 +41,7 @@ class GStorage { // 设置 setting = await Hive.openBox('setting'); // 搜索历史 - historyWord = await Hive.openBox>( + historyWord = await Hive.openBox( 'historyWord', compactionStrategy: (int entries, int deletedEntries) { return deletedEntries > 10; @@ -63,11 +63,12 @@ class GStorage { static Future importAllSettings(String data) => importAllJsonSettings(jsonDecode(data)); - static Future importAllJsonSettings(Map map) async { + static Future importAllJsonSettings(Map map) async { await setting.clear(); await video.clear(); await setting.putAll(map[setting.name]); await video.putAll(map[video.name]); + return true; } static void regAdapter() {