feat: 搜索建议
This commit is contained in:
@ -144,4 +144,7 @@ class Api {
|
||||
// 热搜
|
||||
static const String hotSearchList =
|
||||
'https://s.search.bilibili.com/main/hotword';
|
||||
// 搜索关键词
|
||||
static const String serachSuggest =
|
||||
'https://s.search.bilibili.com/main/suggest';
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:pilipala/http/index.dart';
|
||||
import 'package:pilipala/models/search/hot.dart';
|
||||
import 'package:pilipala/models/search/suggest.dart';
|
||||
|
||||
class SearchHttp {
|
||||
static Future hotSearchList() async {
|
||||
@ -17,4 +18,23 @@ class SearchHttp {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 获取搜索建议
|
||||
static Future searchSuggest({required term}) async {
|
||||
var res = await Request().get(Api.serachSuggest,
|
||||
data: {'term': term, 'main_ver': 'v1', 'highlight': term});
|
||||
if (res.data['code'] == 0) {
|
||||
res.data['result']['term'] = term;
|
||||
return {
|
||||
'status': true,
|
||||
'data': SearchSuggestModel.fromJson(res.data['result']),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'date': [],
|
||||
'msg': '请求错误 🙅',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user