mod: 历史记录搜索

This commit is contained in:
guozhigq
2023-11-03 23:39:21 +08:00
parent 6f34bacb64
commit fd43a8cb31
10 changed files with 332 additions and 13 deletions

View File

@ -303,4 +303,7 @@ class Api {
static const String onlineTotal = '/x/player/online/total';
static const String webDanmaku = '/x/v2/dm/web/seg.so';
// 搜索历史记录
static const String searchHistory = '/x/web-goblin/history/search';
}

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:pilipala/http/index.dart';
import 'package:pilipala/models/bangumi/info.dart';
@ -11,18 +13,26 @@ class SearchHttp {
static Box setting = GStrorage.setting;
static Future hotSearchList() async {
var res = await Request().get(Api.hotSearchList);
if (res.data['code'] == 0) {
if (res.data is String) {
Map<String, dynamic> resultMap = json.decode(res.data);
if (resultMap['code'] == 0) {
return {
'status': true,
'data': HotSearchModel.fromJson(resultMap),
};
}
} else if (res.data is Map<String, dynamic> && res.data['code'] == 0) {
return {
'status': true,
'data': HotSearchModel.fromJson(res.data),
};
} else {
return {
'status': false,
'data': [],
'msg': '请求错误 🙅',
};
}
return {
'status': false,
'data': [],
'msg': '请求错误 🙅',
};
}
// 获取搜索建议

View File

@ -248,4 +248,22 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']};
}
}
// 搜索历史记录
static Future searchHistory(
{required int pn, required String keyword}) async {
var res = await Request().get(
Api.searchHistory,
data: {
'pn': pn,
'keyword': keyword,
'business': 'all',
},
);
if (res.data['code'] == 0) {
return {'status': true, 'data': HistoryData.fromJson(res.data['data'])};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
}