mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 12:52:04 +08:00
chore:更新按钮14逻辑
This commit is contained in:
@@ -531,7 +531,7 @@ void MainWindow::on_pushButton_14_clicked()
|
||||
if (false)
|
||||
{
|
||||
qDebug() << "UOS Developer Mode has not been enabled!";
|
||||
QtConcurrent::run([=]
|
||||
(void)QtConcurrent::run([=]
|
||||
{
|
||||
auto upgradeP = new QProcess();
|
||||
upgradeP->startDetached("zenity", QStringList() << "--info"
|
||||
@@ -544,20 +544,96 @@ void MainWindow::on_pushButton_14_clicked()
|
||||
);
|
||||
upgradeP->waitForStarted();
|
||||
upgradeP->waitForFinished(30);
|
||||
upgradeP->deleteLater(); });
|
||||
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())
|
||||
{
|
||||
QtConcurrent::run([=]
|
||||
{
|
||||
auto upgradeP = new QProcess();
|
||||
upgradeP->startDetached("/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh", QStringList());
|
||||
upgradeP->waitForStarted();
|
||||
upgradeP->waitForFinished(-1);
|
||||
upgradeP->deleteLater(); });
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user