45 lines
943 B
TypeScript
Raw Normal View History

2022-05-12 02:45:43 +08:00
import request from '@/web/utils/request'
2022-04-16 21:14:03 +08:00
import {
SearchParams,
SearchResponse,
SearchTypes,
MultiMatchSearchParams,
MultiMatchSearchResponse,
2022-08-22 16:51:23 +08:00
FetchSearchSuggestionsParams,
FetchSearchSuggestionsResponse,
2022-04-16 21:14:03 +08:00
} from '@/shared/api/Search'
2022-03-13 14:40:38 +08:00
// 搜索
export function search(params: SearchParams): Promise<SearchResponse> {
return request({
url: '/search',
method: 'get',
2022-03-29 00:11:05 +08:00
params: {
...params,
type: SearchTypes[params.type ?? SearchTypes.All],
2022-03-29 00:11:05 +08:00
},
2022-03-13 14:40:38 +08:00
})
}
// 搜索多重匹配
export function multiMatchSearch(
params: MultiMatchSearchParams
): Promise<MultiMatchSearchResponse> {
return request({
url: '/search/multimatch',
method: 'get',
params: params,
})
}
2022-08-22 16:51:23 +08:00
// 搜索建议
export function fetchSearchSuggestions(
params: FetchSearchSuggestionsParams
): Promise<FetchSearchSuggestionsResponse> {
return request({
url: '/search/suggest',
method: 'get',
params,
})
}