Commit 25eeb5db authored by KesaubeEire's avatar KesaubeEire

fix: 搜索重复整理.

parent c3b438fb
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
}; };
}; };
let lastSearchURL;
/**创建请求 fetch 函数 /**创建请求 fetch 函数
* @param {object} param0 参数对象 * @param {object} param0 参数对象
* @param {function} callback 回调函数 * @param {function} callback 回调函数
...@@ -74,10 +75,20 @@ ...@@ -74,10 +75,20 @@
if (params.method == 'POST') msg.body = payload; if (params.method == 'POST') msg.body = payload;
if (params.headers) msg.headers = params.headers; if (params.headers) msg.headers = params.headers;
if (lastSearchURL == url) {
toast.push('搜索参数重复捏~');
return;
}
lastSearchURL = url;
fetch(url, msg) fetch(url, msg)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
// console.log(data); // console.log(data);
if (!data.length) {
toast.push('没有搜索到东西捏~');
return;
}
// 处理数据 // 处理数据
callback(data); callback(data);
...@@ -137,16 +148,12 @@ ...@@ -137,16 +148,12 @@
*/ */
export function searchTitle(title) { export function searchTitle(title) {
if (title === lastSearch) { if (title === lastSearch) {
toast.push('重复搜索捏~'); toast.push('搜索名称重复捏~');
return; return;
} }
lastSearch = title; lastSearch = title;
if (process.env.APP_ENV === 'dev') console.log('执行搜索:\t', title); if (process.env.APP_ENV === 'dev') console.log('执行搜索:\t', title);
createFetch(searchTextRequest(title), data => { createFetch(searchTextRequest(title), data => {
if (!data.length) {
toast.push('没有搜索到东西捏~');
return;
}
if (process.env.APP_ENV === 'dev') console.log(data); if (process.env.APP_ENV === 'dev') console.log(data);
showList(data); showList(data);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment