mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: def searchword
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:PiliPalaX/models/common/tab_type.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import '../../http/index.dart';
|
||||
@@ -16,32 +15,36 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
late TabController tabController;
|
||||
late List tabsCtrList;
|
||||
late List<Widget> tabsPageList;
|
||||
Box userInfoCache = GStorage.userInfo;
|
||||
Box settingStorage = GStorage.setting;
|
||||
RxBool userLogin = false.obs;
|
||||
RxString userFace = ''.obs;
|
||||
dynamic userInfo;
|
||||
Box setting = GStorage.setting;
|
||||
late final StreamController<bool> searchBarStream =
|
||||
StreamController<bool>.broadcast();
|
||||
late bool hideSearchBar;
|
||||
late List defaultTabs;
|
||||
late List<String> tabbarSort;
|
||||
RxString defaultSearch = ''.obs;
|
||||
late bool useSideBar;
|
||||
|
||||
late bool enableSearchWord;
|
||||
late RxString defaultSearch = ''.obs;
|
||||
late int lateCheckAt = 0;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userInfo = GStorage.userInfo.get('userInfoCache');
|
||||
userLogin.value = userInfo != null;
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
hideSearchBar =
|
||||
setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
|
||||
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
||||
searchDefault();
|
||||
GStorage.setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
|
||||
enableSearchWord = GStorage.setting
|
||||
.get(SettingBoxKey.enableSearchWord, defaultValue: true);
|
||||
if (enableSearchWord) {
|
||||
lateCheckAt = DateTime.now().millisecondsSinceEpoch;
|
||||
querySearchDefault();
|
||||
}
|
||||
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
||||
useSideBar =
|
||||
GStorage.setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
||||
// 进行tabs配置
|
||||
setTabConfig();
|
||||
}
|
||||
@@ -60,7 +63,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
// 更新登录状态
|
||||
Future updateLoginStatus(val) async {
|
||||
userInfo = await userInfoCache.get('userInfoCache');
|
||||
userInfo = await GStorage.userInfo.get('userInfoCache');
|
||||
userLogin.value = val ?? false;
|
||||
if (val) return;
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
@@ -68,7 +71,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
void setTabConfig() async {
|
||||
defaultTabs = [...tabsConfig];
|
||||
tabbarSort = settingStorage
|
||||
tabbarSort = GStorage.setting
|
||||
.get(SettingBoxKey.tabbarSort,
|
||||
defaultValue: ['live', 'rcmd', 'hot', 'rank', 'bangumi'])
|
||||
.map<String>((i) => i.toString())
|
||||
@@ -93,12 +96,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
tabController.animation!.removeListener(() {});
|
||||
tabController.animation?.removeListener(() {});
|
||||
tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void searchDefault() async {
|
||||
void querySearchDefault() async {
|
||||
var res = await Request().get(Api.searchDefault);
|
||||
if (res.data['code'] == 0) {
|
||||
defaultSearch.value = res.data['data']['name'];
|
||||
@@ -108,10 +111,11 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
showUserInfoDialog(context) {
|
||||
feedBack();
|
||||
showDialog(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
builder: (context) => const Dialog(
|
||||
child: MinePage(),
|
||||
));
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
builder: (context) => const Dialog(
|
||||
child: MinePage(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user