chore:使用pkexec调用更新器
This commit is contained in:
parent
1f6e68ca3f
commit
30acad7516
|
@ -553,12 +553,11 @@ void MainWindow::on_pushButton_14_clicked()
|
||||||
{
|
{
|
||||||
QString appPath;
|
QString appPath;
|
||||||
|
|
||||||
// 开发环境路径(构建目录)
|
// 判断路径:开发环境 vs 安装后
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
appPath = QCoreApplication::applicationDirPath() +
|
appPath = QCoreApplication::applicationDirPath() +
|
||||||
"/spark-update-tool/spark-update-tool";
|
"/spark-update-tool/spark-update-tool";
|
||||||
#else
|
#else
|
||||||
// 安装后路径(系统PATH)
|
|
||||||
appPath = QStandardPaths::findExecutable("spark-update-tool");
|
appPath = QStandardPaths::findExecutable("spark-update-tool");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -568,14 +567,24 @@ void MainWindow::on_pushButton_14_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
QProcess *process = new QProcess(this);
|
QProcess *process = new QProcess(this);
|
||||||
process->start(appPath, {"--silent"});
|
|
||||||
|
|
||||||
connect(process, QOverload<int>::of(&QProcess::finished),
|
#ifdef QT_DEBUG
|
||||||
[=](int exitCode) {
|
// 开发模式:直接运行本地构建的更新器
|
||||||
|
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) {
|
if (exitCode == 0) {
|
||||||
qDebug() << "Update check successful";
|
qDebug() << "Update check successful";
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Update check failed";
|
qWarning() << "Update check failed with exit code:" << exitCode;
|
||||||
}
|
}
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue