Commit 048e28da authored by JoyJ's avatar JoyJ

fix search loop

parent 6031cd45
Pipeline #23797 failed with stages
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
.catch(error => { .catch(error => {
// 处理错误 // 处理错误
console.error('网络请求错误:', error); console.error('网络请求错误:', error);
我处理一下就行; //我处理一下就行;
toast.push('网络请求错误'); toast.push('网络请求错误');
}); });
} }
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
List = [...List, ...data]; List = [...List, ...data];
} }
function search(args) { function searchTag(args) {
let searchInfo = { let searchInfo = {
url: `${$_env}/query.php?action=get&${args}`, url: `${$_env}/query.php?action=get&${args}`,
params: { params: {
...@@ -85,12 +85,18 @@ ...@@ -85,12 +85,18 @@
} }
} }
}; };
List = [];
createFetch(searchInfo, data => { createFetch(searchInfo, data => {
console.log(data); console.log(data);
showList(data); showList(data);
}); });
} }
function onSearch(e) {
console.log('triggered search');
console.log(e.detail.text);
}
</script> </script>
<!-- ----------------------------------------------- DOM ----------------------------------------------- --> <!-- ----------------------------------------------- DOM ----------------------------------------------- -->
...@@ -103,7 +109,7 @@ ...@@ -103,7 +109,7 @@
cover={$_env + '/' + item.folder.substring(2) + '/rpg_info/1.jpg' ?? ''} cover={$_env + '/' + item.folder.substring(2) + '/rpg_info/1.jpg' ?? ''}
language={categoryList[item.category] || "未知"} language={categoryList[item.category] || "未知"}
raw_tags={item.tags} raw_tags={item.tags}
on:search={search(`tags=${(ev)=>{search(ev.detail.tag)}}`)} on:search={onSearch}
/> />
{/each} {/each}
<Card raw_tags="|示例1|示例2|" /> <Card raw_tags="|示例1|示例2|" />
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
let error = false; let error = false;
const raiseEvent = createEventDispatcher(); const raiseEvent = createEventDispatcher();
function searchByTag(tag) { function searchByTag(e) {
console.log(e);
raiseEvent('search', { raiseEvent('search', {
tag: tag text: e.target
}); });
} }
</script> </script>
...@@ -56,8 +57,7 @@ ...@@ -56,8 +57,7 @@
{#each tags as tag} {#each tags as tag}
<div <div
class="badge badge-outline" class="badge badge-outline"
on:click={searchByTag(tag)} on:mousedown={searchByTag}>{tag}</div>
on:keypress={searchByTag(tag)}>{tag}</div>
{/each} {/each}
{/if} {/if}
</div> </div>
......
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