Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge guozhigq/main #2

Merged
merged 5 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/http/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:dio/io.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
// import 'package:dio_http2_adapter/dio_http2_adapter.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/utils/id_utils.dart';
import '../utils/storage.dart';
import '../utils/utils.dart';
import 'constants.dart';
Expand Down Expand Up @@ -77,10 +78,11 @@ class Request {
static setOptionsHeaders(userInfo, bool status) {
if (status) {
dio.options.headers['x-bili-mid'] = userInfo.mid.toString();
dio.options.headers['x-bili-aurora-eid'] =
IdUtils.genAuroraEid(userInfo.mid);
}
dio.options.headers['env'] = 'prod';
dio.options.headers['app-key'] = 'android64';
dio.options.headers['x-bili-aurora-eid'] = 'UlMFQVcABlAH';
dio.options.headers['x-bili-aurora-zone'] = 'sh001';
dio.options.headers['referer'] = 'https://www.bilibili.com/';
}
Expand Down
34 changes: 0 additions & 34 deletions lib/models/home/rcmd/result.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import 'package:hive/hive.dart';

part 'result.g.dart';

@HiveType(typeId: 0)
class RecVideoItemAppModel {
RecVideoItemAppModel({
this.id,
Expand All @@ -27,47 +22,27 @@ class RecVideoItemAppModel {
this.adInfo,
});

@HiveField(0)
int? id;
@HiveField(1)
int? aid;
@HiveField(2)
String? bvid;
@HiveField(3)
int? cid;
@HiveField(4)
String? pic;
@HiveField(5)
RcmdStat? stat;
@HiveField(6)
String? duration;
@HiveField(7)
String? title;
@HiveField(8)
int? isFollowed;
@HiveField(9)
RcmdOwner? owner;
@HiveField(10)
RcmdReason? rcmdReason;
@HiveField(11)
String? goto;
@HiveField(12)
int? param;
@HiveField(13)
String? uri;
@HiveField(14)
String? talkBack;
// 番剧
@HiveField(15)
String? bangumiView;
@HiveField(16)
String? bangumiFollow;
@HiveField(17)
String? bangumiBadge;

@HiveField(18)
String? cardType;
@HiveField(19)
Map? adInfo;

RecVideoItemAppModel.fromJson(Map<String, dynamic> json) {
Expand Down Expand Up @@ -102,18 +77,14 @@ class RecVideoItemAppModel {
}
}

@HiveType(typeId: 1)
class RcmdStat {
RcmdStat({
this.view,
this.like,
this.danmu,
});
@HiveField(0)
String? view;
@HiveField(1)
String? like;
@HiveField(2)
String? danmu;

RcmdStat.fromJson(Map<String, dynamic> json) {
Expand All @@ -122,13 +93,10 @@ class RcmdStat {
}
}

@HiveType(typeId: 2)
class RcmdOwner {
RcmdOwner({this.name, this.mid});

@HiveField(0)
String? name;
@HiveField(1)
int? mid;

RcmdOwner.fromJson(Map<String, dynamic> json) {
Expand All @@ -141,13 +109,11 @@ class RcmdOwner {
}
}

@HiveType(typeId: 8)
class RcmdReason {
RcmdReason({
this.content,
});

@HiveField(0)
String? content;

RcmdReason.fromJson(Map<String, dynamic> json) {
Expand Down
209 changes: 0 additions & 209 deletions lib/models/home/rcmd/result.g.dart

This file was deleted.

12 changes: 12 additions & 0 deletions lib/pages/home/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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'];
}
}
}
Loading