mirror of
https://github.com/PaiGramTeam/luoxu-api-pub.git
synced 2024-11-22 07:08:05 +00:00
avoid old requests to mess up results
This commit is contained in:
parent
5dd8d16e2e
commit
bfbfe81c08
@ -17,6 +17,7 @@
|
|||||||
let sender: string;
|
let sender: string;
|
||||||
let selected_init: string;
|
let selected_init: string;
|
||||||
let our_hash_change = false;
|
let our_hash_change = false;
|
||||||
|
let abort = new AbortController();
|
||||||
|
|
||||||
setContext("LUOXU_URL", LUOXU_URL);
|
setContext("LUOXU_URL", LUOXU_URL);
|
||||||
|
|
||||||
@ -91,6 +92,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function do_search(more?: any) {
|
async function do_search(more?: any) {
|
||||||
|
abort.abort();
|
||||||
|
abort = new AbortController();
|
||||||
if (!group && !islocal) {
|
if (!group && !islocal) {
|
||||||
error = "请选择要搜索的群组";
|
error = "请选择要搜索的群组";
|
||||||
return;
|
return;
|
||||||
@ -130,9 +133,12 @@
|
|||||||
now = new Date();
|
now = new Date();
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url);
|
const res = await fetch(url, {signal: abort.signal});
|
||||||
const r = await res.json();
|
const r = await res.json();
|
||||||
loading = false;
|
loading = false;
|
||||||
|
if (abort.signal.aborted) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
if (more) {
|
if (more) {
|
||||||
return r;
|
return r;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user