perf(plugin): improve searXNG empty result handling and documentation (#3507)

* perf(plugin): improve searXNG empty result handling and documentation

* 修改了文档和代码部分无搜索的结果的反馈
This commit is contained in:
Jiangween
2025-01-02 16:50:10 +08:00
committed by archer
parent 9abbc16036
commit d24d29ac48
2 changed files with 22 additions and 0 deletions

View File

@@ -160,6 +160,18 @@ default_doi_resolver: 'oadoi.org'
}
```
* 搜索结果为空时会返回友好提示:
```Bash
{
"result": "[]",
"error": {
"message": "No search results",
"code": 500
}
}
```
* 失败时通过 Promise.reject 可能返回错误信息:
```Bash

View File

@@ -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))
};