搜索从网页加载

Merge pull request  from Pluto/dev
This commit is contained in:
shenmo 2022-12-09 03:25:07 +00:00 committed by Gitee
commit 58b31f182a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -751,38 +751,49 @@ void Widget::searchApp(QString text)
}
//加载动画
spinner->show();
spinner->start();
// spinner->show();
// spinner->start();
// // 关键字搜索处理
// httpClient->get("https://search.deepinos.org.cn/appinfo/search")
// .header("content-type", "application/json")
// .queryParam("keyword", text)
// .onResponse([this](QByteArray result)
// {
// auto json = QJsonDocument::fromJson(result).array();
// if (json.empty())
// {
// qDebug() << "相关应用未找到!";
// sendNotification(tr("Relative apps Not Found!"));
// mutex.unlock();
// clearSearchApp();
// spinner->stop();
// spinner->hide();
// ui->stackedWidget->setCurrentIndex(0);
// ui->webEngineView->setUrl(QUrl("https://wayou.github.io/t-rex-runner"));
// return;
// }
// clearSearchApp();
// displaySearchApp(json); })
// .onError([this](QString errorStr)
// {
// qDebug() << "请求出错:" << errorStr;
// sendNotification(QString(tr("Request Error: %1")).arg(errorStr));
// mutex.unlock();
// return; })
// .timeout(10 * 1000)
// .exec();
if (!themeIsDark){
ui->webEngineView->setUrl(serverUrl + "store/#/search?keywords=" + text);
}else{
ui->webEngineView->setUrl(serverUrl + "store/#/darksearch?keywords=" + text);
}
// spinner->stop();
// spinner->hide();
mutex.unlock();
// 关键字搜索处理
httpClient->get("https://search.deepinos.org.cn/appinfo/search")
.header("content-type", "application/json")
.queryParam("keyword", text)
.onResponse([this](QByteArray result)
{
auto json = QJsonDocument::fromJson(result).array();
if (json.empty())
{
qDebug() << "相关应用未找到!";
sendNotification(tr("Relative apps Not Found!"));
mutex.unlock();
clearSearchApp();
spinner->stop();
spinner->hide();
ui->stackedWidget->setCurrentIndex(0);
ui->webEngineView->setUrl(QUrl("https://wayou.github.io/t-rex-runner"));
return;
}
clearSearchApp();
displaySearchApp(json); })
.onError([this](QString errorStr)
{
qDebug() << "请求出错:" << errorStr;
sendNotification(QString(tr("Request Error: %1")).arg(errorStr));
mutex.unlock();
return; })
.timeout(10 * 1000)
.exec();
}
}