fix: 退出搜索页面控制器未销毁

This commit is contained in:
guozhigq
2024-01-27 00:24:54 +08:00
parent 0595648f4c
commit d1bacf8950
3 changed files with 32 additions and 25 deletions

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/models/common/tab_type.dart';
import 'package:pilipala/utils/storage.dart';
import '../../http/index.dart';
class HomeController extends GetxController with GetTickerProviderStateMixin {
bool flag = false;
@ -24,6 +25,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
late bool hideSearchBar;
late List defaultTabs;
late List<String> tabbarSort;
RxString defaultSearch = ''.obs;
@override
void onInit() {
@ -35,6 +37,9 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
setTabConfig();
hideSearchBar =
setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
searchDefault();
}
}
void onRefresh() {
@ -94,4 +99,11 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
}
});
}
void searchDefault() async {
var res = await Request().get(Api.searchDefault);
if (res.data['code'] == 0) {
defaultSearch.value = res.data['data']['name'];
}
}
}