chore:更新按钮逻辑

This commit is contained in:
2025-08-03 19:53:30 +08:00
parent 77dde49653
commit 2b62cc7677

View File

@@ -522,118 +522,5 @@ void MainWindow::notify(QObject *receiver, QEvent *event)
void MainWindow::on_pushButton_14_clicked()
{
/**
* NOTE: No need to judget developmode status
*/
// Check UOS
// QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
// if (config.contains("UOS/EnableDeveloperMode") && !config.value("UOS/EnableDeveloperMode").toBool())
if (false)
{
qDebug() << "UOS Developer Mode has not been enabled!";
(void)QtConcurrent::run([=]
{
auto upgradeP = new QProcess();
upgradeP->startDetached("zenity", QStringList() << "--info"
<< "--text"
<< "UOS开发者模式未开启相关功能被禁用"
<< "--title"
<< "功能禁用提示"
<< "--width"
<< "360"
);
upgradeP->waitForStarted();
upgradeP->waitForFinished(30);
upgradeP->deleteLater();
});
}else
{
QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt");
if (!upgradeStatus.exists())
{
QString appPath;
// 判断路径:开发环境 vs 安装后
#ifdef QT_DEBUG
appPath = QCoreApplication::applicationDirPath() +
"/spark-update-tool/spark-update-tool";
#else
appPath = QStandardPaths::findExecutable("spark-update-tool");
#endif
if (appPath.isEmpty()) {
qWarning() << "spark-update-tool not found!";
return;
}
QProcess *process = new QProcess(this);
#ifdef QT_DEBUG
// 开发模式:直接运行本地构建的更新器
process->start(appPath, {"--silent"});
#else
// 安装模式:使用 pkexec 提权运行系统路径下的 spark-update-tool
QString program = "pkexec";
QStringList arguments;
arguments << appPath << "--silent";
process->start(program, arguments);
#endif
QObject::connect(process, &QProcess::finished,
[process](int exitCode, QProcess::ExitStatus) {
if (exitCode == 0) {
qDebug() << "Update check successful";
} else {
qWarning() << "Update check failed with exit code:" << exitCode;
}
process->deleteLater();
});
}
}
// ...existing code...
else
{
QFile upgradeStatus("/tmp/spark-store/upgradeStatus.txt");
if (!upgradeStatus.exists())
{
QString appPath;
// 判断路径:开发环境 vs 安装后
#ifdef QT_DEBUG
appPath = QCoreApplication::applicationDirPath() +
"/spark-update-tool/spark-update-tool";
#else
appPath = QStandardPaths::findExecutable("spark-update-tool");
#endif
if (appPath.isEmpty()) {
qWarning() << "spark-update-tool not found!";
return;
}
QProcess *process = new QProcess(this);
#ifdef QT_DEBUG
// 开发模式:直接运行本地构建的更新器
process->start(appPath, {"--silent"});
#else
// 安装模式:使用 pkexec 提权运行系统路径下的 spark-update-tool
QString program = "pkexec";
QStringList arguments;
arguments << appPath << "--silent";
process->start(program, arguments);
#endif
QObject::connect(process, QOverload<int>::of(&QProcess::finished),
[process](int exitCode) {
if (exitCode == 0) {
qDebug() << "Update check successful";
} else {
qWarning() << "Update check failed with exit code:" << exitCode;
}
process->deleteLater();
});
}
}
}
}
}