mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 20:32:05 +08:00
fix: Can not get app version
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
DataCollectorAndUploader::DataCollectorAndUploader(QObject *parent) : QObject(parent)
|
DataCollectorAndUploader::DataCollectorAndUploader(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -27,11 +28,17 @@ void DataCollectorAndUploader::collectData()
|
|||||||
QString architecture;
|
QString architecture;
|
||||||
|
|
||||||
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||||
QString version = config.value("build/version").toString();
|
QString version = QString(APP_VERSION); // 使用编译时定义的版本号
|
||||||
QString uuid = config.value("info/uuid").toString();
|
QString uuid = config.value("info/uuid").toString();
|
||||||
|
|
||||||
// Read /etc/os-release file
|
// 根据环境变量选择 os-release 文件路径
|
||||||
QFile osReleaseFile("/etc/os-release");
|
QString osReleasePath = "/etc/os-release";
|
||||||
|
if (qEnvironmentVariableIsSet("IS_ACE_ENV") && qgetenv("IS_ACE_ENV") == "1") {
|
||||||
|
osReleasePath = "/host/etc/os-release";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read os-release file
|
||||||
|
QFile osReleaseFile(osReleasePath);
|
||||||
if (osReleaseFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (osReleaseFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QTextStream in(&osReleaseFile);
|
QTextStream in(&osReleaseFile);
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
@@ -44,7 +51,7 @@ void DataCollectorAndUploader::collectData()
|
|||||||
}
|
}
|
||||||
osReleaseFile.close();
|
osReleaseFile.close();
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Could not open /etc/os-release file";
|
qWarning() << "Could not open os-release file:" << osReleasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute uname -m to get the architecture
|
// Execute uname -m to get the architecture
|
||||||
@@ -83,4 +90,4 @@ void DataCollectorAndUploader::collectData()
|
|||||||
}
|
}
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user