fe5aa5bbf0
update-client-hardening 四工作流合入(构建/静态检查已过): - 配置:不可变产品策略经 UpdateClientResources.cmake 归一化校验后 内嵌 qrc(URL/相对路径/主程序必须落 install_root/版本/UUID 格式, CMake override 写入前复验);可变机器状态迁系统级原生存储; 运行目录不再落可编辑 app_config.json。 - i18n:生产源全英文(no-Han 检查 41/41),中文进 translations/ zh_CN 目录;翻译加载收敛 Common/TranslationHelper 唯一入口; Bootstrap 补资源文件。 - 依赖:Qt/OpenSSL/架构/Perl 机器路径改 imported targets + UpdateClientDependencies.cmake,3rdparty 由父工程契约供给。 - 清理:旧 README/SDK README/3 个重复 PowerShell 打包脚本/PDF 提取 文本删除,canonical README + 5 份结构化英文文档替代;Launcher requireAdministrator manifest;统一 MSVC /utf-8 删运行时编码设置。
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
#include "MainWindow.h"
|
|
#include <QApplication>
|
|
#include <QFont>
|
|
#include <QFile>
|
|
#include <QLabel>
|
|
#include <QVBoxLayout>
|
|
#include <QCryptographicHash>
|
|
#include "../Common/PolicyHelper.h"
|
|
#include "../Common/ConfigHelper.h"
|
|
|
|
static QString readDllVersion(const QString& dllPath)
|
|
{
|
|
QFile file(dllPath);
|
|
if (!file.exists())
|
|
return QCoreApplication::translate("MainWindow", "missing");
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
return QCoreApplication::translate("MainWindow", "unreadable");
|
|
|
|
QByteArray data = file.read(1024);
|
|
file.close();
|
|
return QString::fromUtf8(QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex().left(8));
|
|
}
|
|
|
|
MainWindow::MainWindow(QWidget* parent)
|
|
: QWidget(parent)
|
|
{
|
|
this->setWindowTitle(tr("Marsco Demo MainApp"));
|
|
this->resize(600, 400);
|
|
|
|
QString appVersion = ConfigHelper::instance().getValue("App", "current_version");
|
|
if (appVersion.isEmpty())
|
|
appVersion = tr("unknown");
|
|
|
|
QString dllVersion = readDllVersion(QApplication::applicationDirPath() + "/plugins/demo_plugin.dll");
|
|
|
|
PolicyHelper policy(QApplication::applicationDirPath());
|
|
QString policyResult;
|
|
if (!policy.loadPolicy("config/version_policy.dat"))
|
|
{
|
|
policyResult = tr("policy missing");
|
|
}
|
|
else if (!policy.isValid())
|
|
{
|
|
policyResult = tr("policy invalid");
|
|
}
|
|
else if (!policy.isVersionAllowed(appVersion))
|
|
{
|
|
policyResult = tr("version disabled");
|
|
}
|
|
else if (policy.isExpired())
|
|
{
|
|
policyResult = tr("policy expired");
|
|
}
|
|
else
|
|
{
|
|
policyResult = tr("policy ok");
|
|
}
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
QLabel* label = new QLabel(tr("Software Running Successfully\nVersion: %1\nDLL Version: %2\nPolicy: %3")
|
|
.arg(appVersion)
|
|
.arg(dllVersion)
|
|
.arg(policyResult));
|
|
QFont font = label->font();
|
|
font.setPointSize(14);
|
|
label->setFont(font);
|
|
label->setAlignment(Qt::AlignCenter);
|
|
|
|
layout->addWidget(label);
|
|
this->setLayout(layout);
|
|
}
|