mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-06 03:12:21 +08:00
feat: cdn
This commit is contained in:
parent
55c6c13e50
commit
1733d9853d
@ -292,18 +292,20 @@ void Widget::initConfig()
|
|||||||
|
|
||||||
// 读取服务器URL并初始化菜单项的链接
|
// 读取服务器URL并初始化菜单项的链接
|
||||||
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
QSettings readConfig(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
if(!readConfig.value("server/choose").toString().isEmpty())
|
if(!readConfig.value("server/choose").toString().isEmpty() && readConfig.value("server/updated").toString() == "TRUE")
|
||||||
{
|
{
|
||||||
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
||||||
appinfoLoadThread.setServer(serverUrl = readConfig.value("server/choose").toString());
|
appinfoLoadThread.setServer(serverUrl = readConfig.value("server/choose").toString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appinfoLoadThread.setServer(serverUrl = "https://d.store.deepinos.org.cn/"); // 默认URL
|
this->cdnSeverUrl = "https://cdn.d.store.deepinos.org.cn/";
|
||||||
|
appinfoLoadThread.setServer(serverUrl = this->cdnSeverUrl); // 默认URL
|
||||||
}
|
}
|
||||||
configCanSave = true; // 防止触发保存配置信号
|
configCanSave = true; // 防止触发保存配置信号
|
||||||
|
|
||||||
// menuUrl[0] = "http://127.0.0.1:8000/#/darkprogramming";
|
// menuUrl[0] = "http://127.0.0.1:8000/#/darkprogramming";
|
||||||
|
qDebug() << "serverUrl: " << serverUrl;
|
||||||
menuUrl[0] = serverUrl + "store/#/";
|
menuUrl[0] = serverUrl + "store/#/";
|
||||||
menuUrl[1] = serverUrl + "store/#/network";
|
menuUrl[1] = serverUrl + "store/#/network";
|
||||||
menuUrl[2] = serverUrl + "store/#/relations";
|
menuUrl[2] = serverUrl + "store/#/relations";
|
||||||
@ -1026,11 +1028,13 @@ void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
|||||||
{
|
{
|
||||||
appinfoLoadThread.setServer(arg1); // 服务器信息更新
|
appinfoLoadThread.setServer(arg1); // 服务器信息更新
|
||||||
|
|
||||||
|
const QString updatedInfo = "TRUE";
|
||||||
if(configCanSave)
|
if(configCanSave)
|
||||||
{
|
{
|
||||||
// ui->label_setting1->show();
|
// ui->label_setting1->show();
|
||||||
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
QSettings *setConfig = new QSettings(QDir::homePath() + "/.config/spark-store/config.ini", QSettings::IniFormat);
|
||||||
setConfig->setValue("server/choose", arg1);
|
setConfig->setValue("server/choose", arg1);
|
||||||
|
setConfig->setValue("server/updated", updatedInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ class DownloadController;
|
|||||||
namespace AeaQt {
|
namespace AeaQt {
|
||||||
class HttpClient;
|
class HttpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Widget : public DBlurEffectWidget
|
class Widget : public DBlurEffectWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -105,6 +104,7 @@ private slots:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QUrl url;
|
QUrl url;
|
||||||
|
QString cdnSeverUrl;
|
||||||
|
|
||||||
downloadlist download_list[LIST_MAX];
|
downloadlist download_list[LIST_MAX];
|
||||||
Ui::Widget *ui;
|
Ui::Widget *ui;
|
||||||
|
@ -13,10 +13,12 @@ void SpkAppInfoLoaderThread::run()
|
|||||||
emit requestResetUi();
|
emit requestResetUi();
|
||||||
|
|
||||||
httpClient = new AeaQt::HttpClient;
|
httpClient = new AeaQt::HttpClient;
|
||||||
|
QString oriSeverUrl = "https://d.store.deepinos.org.cn";
|
||||||
|
QString cdnSeverUrl = "https://cdn.d.store.deepinos.org.cn";
|
||||||
|
|
||||||
QString downloadTimesUrl = targetUrl.toString();
|
QString downloadTimesUrl = targetUrl.toString();
|
||||||
downloadTimesUrl = downloadTimesUrl.replace("app.json","download-times.txt");
|
downloadTimesUrl = downloadTimesUrl.replace(oriSeverUrl, cdnSeverUrl);
|
||||||
|
downloadTimesUrl = downloadTimesUrl.replace("app.json", "download-times.txt");
|
||||||
httpClient->get(downloadTimesUrl)
|
httpClient->get(downloadTimesUrl)
|
||||||
.onResponse([this](QString downloadTimesFeedback)
|
.onResponse([this](QString downloadTimesFeedback)
|
||||||
{
|
{
|
||||||
@ -33,7 +35,7 @@ void SpkAppInfoLoaderThread::run()
|
|||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
|
|
||||||
httpClient->get(targetUrl.toString())
|
httpClient->get(targetUrl.toString().replace(oriSeverUrl, cdnSeverUrl))
|
||||||
.header("content-type", "application/json")
|
.header("content-type", "application/json")
|
||||||
.onResponse([this](QByteArray json_array)
|
.onResponse([this](QByteArray json_array)
|
||||||
{
|
{
|
||||||
@ -51,8 +53,8 @@ void SpkAppInfoLoaderThread::run()
|
|||||||
|
|
||||||
QStringList url_ = targetUrl.toString().replace("//", "/").split("/");
|
QStringList url_ = targetUrl.toString().replace("//", "/").split("/");
|
||||||
urladdress = "https://" + url_[1];
|
urladdress = "https://" + url_[1];
|
||||||
// 不使用图片专用服务器
|
// 使用 cdn 服务器
|
||||||
// urladdress = "https://d.store.deepinos.org.cn"; // 使用图片专用服务器请保留这行,删除后将使用源服务器
|
urladdress = "https://cdn.d.store.deepinos.org.cn"; // 使用图片专用服务器请保留这行,删除后将使用源服务器
|
||||||
|
|
||||||
|
|
||||||
for(int i = 3; i < downloadurl.size(); i++)
|
for(int i = 3; i < downloadurl.size(); i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user