mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
@@ -24,7 +24,7 @@ class HomeController extends GetxController
|
|||||||
final bool hideSearchBar = Pref.hideSearchBar;
|
final bool hideSearchBar = Pref.hideSearchBar;
|
||||||
final bool useSideBar = Pref.useSideBar;
|
final bool useSideBar = Pref.useSideBar;
|
||||||
|
|
||||||
final bool enableSearchWord = Pref.enableSearchWord;
|
bool enableSearchWord = Pref.enableSearchWord;
|
||||||
late RxString defaultSearch = ''.obs;
|
late RxString defaultSearch = ''.obs;
|
||||||
late int lateCheckSearchAt = 0;
|
late int lateCheckSearchAt = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ class _HomePageState extends State<HomePage>
|
|||||||
semanticLabel: '搜索',
|
semanticLabel: '搜索',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
if (_homeController.enableSearchWord) ...[
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
@@ -215,8 +214,7 @@ class _HomePageState extends State<HomePage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: 5),
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class _MainAppState extends State<MainApp>
|
|||||||
late final _homeController = Get.put(HomeController());
|
late final _homeController = Get.put(HomeController());
|
||||||
late final _dynamicController = Get.put(DynamicsController());
|
late final _dynamicController = Get.put(DynamicsController());
|
||||||
|
|
||||||
|
static const _period = 5 * 60 * 1000;
|
||||||
late int _lastSelectTime = 0;
|
late int _lastSelectTime = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -85,7 +86,7 @@ class _MainAppState extends State<MainApp>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int now = DateTime.now().millisecondsSinceEpoch;
|
int now = DateTime.now().millisecondsSinceEpoch;
|
||||||
if (now - _homeController.lateCheckSearchAt >= 5 * 60 * 1000) {
|
if (now - _homeController.lateCheckSearchAt >= _period) {
|
||||||
_homeController
|
_homeController
|
||||||
..lateCheckSearchAt = now
|
..lateCheckSearchAt = now
|
||||||
..querySearchDefault();
|
..querySearchDefault();
|
||||||
@@ -103,7 +104,7 @@ class _MainAppState extends State<MainApp>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int now = DateTime.now().millisecondsSinceEpoch;
|
int now = DateTime.now().millisecondsSinceEpoch;
|
||||||
if (now - _mainController.lastCheckUnreadAt >= 5 * 60 * 1000) {
|
if (now - _mainController.lastCheckUnreadAt >= _period) {
|
||||||
_mainController
|
_mainController
|
||||||
..lastCheckUnreadAt = now
|
..lastCheckUnreadAt = now
|
||||||
..queryUnreadMsg();
|
..queryUnreadMsg();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/http/search.dart';
|
|||||||
import 'package:PiliPlus/models/search/suggest.dart';
|
import 'package:PiliPlus/models/search/suggest.dart';
|
||||||
import 'package:PiliPlus/models_new/search/search_rcmd/data.dart';
|
import 'package:PiliPlus/models_new/search/search_rcmd/data.dart';
|
||||||
import 'package:PiliPlus/models_new/search/search_trending/data.dart';
|
import 'package:PiliPlus/models_new/search/search_trending/data.dart';
|
||||||
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/id_utils.dart';
|
import 'package:PiliPlus/utils/id_utils.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
@@ -20,7 +21,7 @@ class SSearchController extends GetxController {
|
|||||||
final searchFocusNode = FocusNode();
|
final searchFocusNode = FocusNode();
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
|
|
||||||
String hintText = '搜索';
|
String? hintText;
|
||||||
|
|
||||||
int initIndex = 0;
|
int initIndex = 0;
|
||||||
|
|
||||||
@@ -48,15 +49,11 @@ class SSearchController extends GetxController {
|
|||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
// 其他页面跳转过来
|
final params = Get.parameters;
|
||||||
if (Get.parameters['keyword'] != null) {
|
hintText = params['hintText'];
|
||||||
onClickKeyword(Get.parameters['keyword']!);
|
final text = params['text'];
|
||||||
}
|
if (text != null) {
|
||||||
if (Get.parameters['hintText'] != null) {
|
controller.text = text;
|
||||||
hintText = Get.parameters['hintText']!;
|
|
||||||
}
|
|
||||||
if (Get.parameters['text'] != null) {
|
|
||||||
controller.text = Get.parameters['text']!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
historyList = List<String>.from(
|
historyList = List<String>.from(
|
||||||
@@ -111,10 +108,10 @@ class SSearchController extends GetxController {
|
|||||||
// 搜索
|
// 搜索
|
||||||
Future<void> submit() async {
|
Future<void> submit() async {
|
||||||
if (controller.text.isEmpty) {
|
if (controller.text.isEmpty) {
|
||||||
if (hintText.isEmpty) {
|
if (hintText.isNullOrEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
controller.text = hintText;
|
controller.text = hintText!;
|
||||||
validateUid();
|
validateUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +123,6 @@ class SSearchController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchFocusNode.unfocus();
|
searchFocusNode.unfocus();
|
||||||
|
|
||||||
await Get.toNamed(
|
await Get.toNamed(
|
||||||
'/searchResult',
|
'/searchResult',
|
||||||
parameters: {
|
parameters: {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
textInputAction: TextInputAction.search,
|
textInputAction: TextInputAction.search,
|
||||||
onChanged: _searchController.onChange,
|
onChanged: _searchController.onChange,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: _searchController.hintText,
|
hintText: _searchController.hintText ?? '搜索',
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
),
|
),
|
||||||
onSubmitted: (value) => _searchController.submit(),
|
onSubmitted: (value) => _searchController.submit(),
|
||||||
|
|||||||
@@ -773,7 +773,14 @@ List<SettingsModel> get extraSettings => [
|
|||||||
setKey: SettingBoxKey.enableSearchWord,
|
setKey: SettingBoxKey.enableSearchWord,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
onChanged: (val) {
|
onChanged: (val) {
|
||||||
Get.find<HomeController>().defaultSearch.value = '';
|
try {
|
||||||
|
final controller = Get.find<HomeController>()..enableSearchWord = val;
|
||||||
|
if (val) {
|
||||||
|
controller.querySearchDefault();
|
||||||
|
} else {
|
||||||
|
controller.defaultSearch.value = '';
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
|
|||||||
Reference in New Issue
Block a user