!153 搜索从网页加载

Merge pull request !153 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

View File

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