@ -185,7 +185,7 @@ class Api {
|
|||||||
static const String searchDefault = '/x/web-interface/wbi/search/default';
|
static const String searchDefault = '/x/web-interface/wbi/search/default';
|
||||||
|
|
||||||
// 搜索关键词
|
// 搜索关键词
|
||||||
static const String serachSuggest =
|
static const String searchSuggest =
|
||||||
'https://s.search.bilibili.com/main/suggest';
|
'https://s.search.bilibili.com/main/suggest';
|
||||||
|
|
||||||
// 分类搜索
|
// 分类搜索
|
||||||
|
|||||||
@ -70,14 +70,14 @@ class ApiInterceptor extends Interceptor {
|
|||||||
case DioExceptionType.sendTimeout:
|
case DioExceptionType.sendTimeout:
|
||||||
return '发送请求超时,请检查网络设置';
|
return '发送请求超时,请检查网络设置';
|
||||||
case DioExceptionType.unknown:
|
case DioExceptionType.unknown:
|
||||||
final String res = await checkConect();
|
final String res = await checkConnect();
|
||||||
return '$res \n 网络异常,请稍后重试!';
|
return '$res \n 网络异常,请稍后重试!';
|
||||||
// default:
|
// default:
|
||||||
// return 'Dio异常';
|
// return 'Dio异常';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> checkConect() async {
|
static Future<String> checkConnect() async {
|
||||||
final ConnectivityResult connectivityResult =
|
final ConnectivityResult connectivityResult =
|
||||||
await Connectivity().checkConnectivity();
|
await Connectivity().checkConnectivity();
|
||||||
if (connectivityResult == ConnectivityResult.mobile) {
|
if (connectivityResult == ConnectivityResult.mobile) {
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class SearchHttp {
|
|||||||
|
|
||||||
// 获取搜索建议
|
// 获取搜索建议
|
||||||
static Future searchSuggest({required term}) async {
|
static Future searchSuggest({required term}) async {
|
||||||
var res = await Request().get(Api.serachSuggest,
|
var res = await Request().get(Api.searchSuggest,
|
||||||
data: {'term': term, 'main_ver': 'v1', 'highlight': term});
|
data: {'term': term, 'main_ver': 'v1', 'highlight': term});
|
||||||
if (res.data is String) {
|
if (res.data is String) {
|
||||||
Map<String, dynamic> resultMap = json.decode(res.data);
|
Map<String, dynamic> resultMap = json.decode(res.data);
|
||||||
|
|||||||
Reference in New Issue
Block a user