perf(plugin): improve searXNG empty result handling and documentation (#3507)
* perf(plugin): improve searXNG empty result handling and documentation * 修改了文档和代码部分无搜索的结果的反馈
This commit is contained in:
@@ -160,6 +160,18 @@ default_doi_resolver: 'oadoi.org'
|
||||
}
|
||||
```
|
||||
|
||||
* 搜索结果为空时会返回友好提示:
|
||||
|
||||
```Bash
|
||||
{
|
||||
"result": "[]",
|
||||
"error": {
|
||||
"message": "No search results",
|
||||
"code": 500
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* 失败时通过 Promise.reject 可能返回错误信息:
|
||||
|
||||
```Bash
|
||||
|
||||
@@ -48,6 +48,16 @@ const main = async (props: Props, retry = 3): Response => {
|
||||
});
|
||||
});
|
||||
|
||||
if (results.length === 0) {
|
||||
return {
|
||||
result: JSON.stringify([]),
|
||||
error: {
|
||||
message: 'No search results',
|
||||
code: 500
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
result: JSON.stringify(results.slice(0, 10))
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user