|
@@ -1,8 +1,8 @@
|
|
|
import { ajaxGetSearchHistory, ajaxClearSearchHistory } from '../api/search-history'
|
|
|
|
|
|
-class SearchHistoryApi {
|
|
|
+class SearchHistoryBaseApi {
|
|
|
constructor(config = {}) {
|
|
|
- this.historyList = []
|
|
|
+ this.searchHistoryList = []
|
|
|
this._getParams = config.getParams || (() => {})
|
|
|
// 函数 Hooks
|
|
|
this.getHistoryQuery = this.runQuery.bind(this)
|
|
@@ -16,13 +16,13 @@ class SearchHistoryApi {
|
|
|
*/
|
|
|
|
|
|
async runQuery(params) {
|
|
|
- this.historyList = []
|
|
|
+ this.searchHistoryList = []
|
|
|
const query = Object.assign({}, params, this._getParams(params))
|
|
|
const result = await this.ajaxQuery(query)
|
|
|
if (result.success) {
|
|
|
- this.historyList = result.list
|
|
|
+ this.searchHistoryList = result.list
|
|
|
} else {
|
|
|
- this.historyList = []
|
|
|
+ this.searchHistoryList = []
|
|
|
}
|
|
|
return result
|
|
|
}
|
|
@@ -45,11 +45,15 @@ class SearchHistoryApi {
|
|
|
return ajaxClearSearchHistory(query).then((res) => {
|
|
|
let success = res?.error_code === 0
|
|
|
|
|
|
+ if (success && res.data) {
|
|
|
+ this.searchHistoryList = []
|
|
|
+ }
|
|
|
return {
|
|
|
- success: success
|
|
|
+ success: success,
|
|
|
+ list: []
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default SearchHistoryApi
|
|
|
+export default SearchHistoryBaseApi
|