Update application UI and functionality

This commit is contained in:
2026-07-26 16:20:36 +08:00
parent b9aff58f32
commit 97ea6fb7aa
48 changed files with 2790 additions and 628 deletions
+91 -25
View File
@@ -482,6 +482,11 @@ begin
QueueInstallOutput(Text, True, True);
end;
procedure LogBootstrapEvent(const EventName, Value: string);
begin
Log('YMHUT_EVENT:' + EventName + '|' + Value);
end;
procedure LogCurrentExtractFile();
var
FileName: string;
@@ -718,28 +723,67 @@ begin
Result := FmtMessage(CustomMessage(Key), [Value1, Value2]);
end;
function DownloadAndInstallPrerequisite(const Url, FileName, Arguments, FriendlyName: string; var NeedsRestart: Boolean): Boolean;
function AcquireAndInstallPrerequisite(
const Url, DownloadFileName, BundledFileName, Arguments, FriendlyName: string;
const Bundled: Boolean; var NeedsRestart: Boolean): Boolean;
var
Attempt: Integer;
Downloaded: Boolean;
LastDownloadError: string;
ResultCode: Integer;
ExecutablePath: string;
begin
Result := False;
ExecutablePath := ExpandConstant('{tmp}\' + FileName);
DownloadPage.Clear;
DownloadPage.Add(Url, FileName, '');
if not WizardSilent then
DownloadPage.Show;
try
DownloadPage.Download;
except
if DownloadPage.AbortedByUser then
RaiseException(FormatCustomMessage('DependencyDownloadCancelled', FriendlyName))
else
RaiseException(FormatCustomMessage2('DependencyDownloadFailed', FriendlyName, GetExceptionMessage));
end;
if not WizardSilent then
DownloadPage.Hide;
if Bundled then
begin
LogBootstrapEvent('DEPENDENCY', 'bundled|' + FriendlyName);
ExtractTemporaryFile(BundledFileName);
ExecutablePath := ExpandConstant('{tmp}\' + BundledFileName);
end
else
begin
ExecutablePath := ExpandConstant('{tmp}\' + DownloadFileName);
Downloaded := False;
LastDownloadError := '';
for Attempt := 1 to 3 do
begin
LogBootstrapEvent('DEPENDENCY', 'download|' + FriendlyName);
DownloadPage.Clear;
DownloadPage.Add(Url, DownloadFileName, '');
if not WizardSilent then
DownloadPage.Show;
try
try
DownloadPage.Download;
Downloaded := True;
except
if DownloadPage.AbortedByUser then
RaiseException(FormatCustomMessage('DependencyDownloadCancelled', FriendlyName))
else
LastDownloadError := GetExceptionMessage;
end;
finally
if not WizardSilent then
DownloadPage.Hide;
end;
if Downloaded then
Break;
if Attempt < 3 then
begin
LogBootstrapEvent('DEPENDENCY', 'retry|' + FriendlyName);
Sleep(Attempt * 1500);
end;
end;
if not Downloaded then
RaiseException(FormatCustomMessage2('DependencyDownloadFailed', FriendlyName, LastDownloadError));
end;
if not FileExists(ExecutablePath) then
RaiseException(FormatCustomMessage2('DependencyDownloadFailed', FriendlyName, 'downloaded file is missing'));
LogBootstrapEvent('DEPENDENCY', 'install|' + FriendlyName);
if not Exec(ExecutablePath, Arguments, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
RaiseException(FormatCustomMessage('DependencyStartFailed', FriendlyName));
@@ -749,9 +793,16 @@ begin
if (ResultCode = 3010) or (ResultCode = 1641) then
NeedsRestart := True;
LogBootstrapEvent('DEPENDENCY', 'complete|' + FriendlyName);
Result := True;
end;
procedure SetSetupFailure(var ResultText: string; const MessageText: string);
begin
ResultText := MessageText;
LogBootstrapEvent('FAILURE', MessageText);
end;
procedure CopyIfExists(const Source, TargetDir: string);
begin
if FileExists(Source) then
@@ -900,46 +951,57 @@ end;
function PrepareToInstall(var NeedsRestart: Boolean): string;
begin
AppendInstallOutput('Prepare system prerequisites.');
LogBootstrapEvent('STAGE', 'prerequisites');
Result := '';
#if Int(QAIsolated) == 1
Exit;
#endif
if (ExistingInstallDir <> '') and IsProtectedInstallPath(ExistingInstallDir) and (not IsAdminInstallMode) then
begin
Result := CustomMessage('ProtectedInstallNeedsAdmin');
SetSetupFailure(Result, CustomMessage('ProtectedInstallNeedsAdmin'));
Exit;
end;
if IsProtectedInstallPath(WizardDirValue) and (not IsAdminInstallMode) then
begin
Result := CustomMessage('ProtectedInstallNeedsAdmin');
SetSetupFailure(Result, CustomMessage('ProtectedInstallNeedsAdmin'));
Exit;
end;
try
if not IsWebView2Installed() then
if IsWebView2Installed() then
LogBootstrapEvent('DEPENDENCY', 'ready|' + GetCustomMessageValue('WebView2RuntimeName'))
else
begin
DownloadAndInstallPrerequisite('{#WebView2BootstrapperUrl}', 'MicrosoftEdgeWebView2Setup.exe', '/silent /install', GetCustomMessageValue('WebView2RuntimeName'), NeedsRestart);
AcquireAndInstallPrerequisite(
'{#WebView2BootstrapperUrl}', 'MicrosoftEdgeWebView2Setup.exe',
'MicrosoftEdgeWebView2RuntimeInstallerX64.exe', '/silent /install',
GetCustomMessageValue('WebView2RuntimeName'), BundledWebView2Included = 1, NeedsRestart);
if not WaitForWebView2Installed(60) then
begin
Result := GetCustomMessageValue('WebView2StillMissing');
SetSetupFailure(Result, GetCustomMessageValue('WebView2StillMissing'));
Exit;
end;
end;
if (not IsVCRedistInstalled()) then
if IsVCRedistInstalled() then
LogBootstrapEvent('DEPENDENCY', 'ready|' + GetCustomMessageValue('VCRuntimeName'))
else
begin
DownloadAndInstallPrerequisite('{#VCRedistUrl}', 'vc_redist.x64.exe', '/install /quiet /norestart', GetCustomMessageValue('VCRuntimeName'), NeedsRestart);
AcquireAndInstallPrerequisite(
'{#VCRedistUrl}', 'vc_redist.x64.exe', 'vc_redist.x64.exe',
'/install /quiet /norestart', GetCustomMessageValue('VCRuntimeName'),
BundledVCRedistIncluded = 1, NeedsRestart);
if not WaitForVCRedistInstalled(10) then
begin
Result := GetCustomMessageValue('VCRuntimeStillMissing');
SetSetupFailure(Result, GetCustomMessageValue('VCRuntimeStillMissing'));
Exit;
end;
end;
except
Result := GetExceptionMessage;
SetSetupFailure(Result, GetExceptionMessage);
end;
end;
@@ -954,6 +1016,7 @@ begin
if CurStep = ssInstall then
begin
LastInstallProgressPercent := -1;
LogBootstrapEvent('STAGE', 'files');
AppendInstallOutput(CustomMessage('InstallOutputClean'));
CleanLegacyInstallLayout();
AppendInstallOutput(CustomMessage('InstallOutputExtract'));
@@ -961,6 +1024,7 @@ begin
else if CurStep = ssPostInstall then
begin
FlushInstallOutput();
LogBootstrapEvent('STAGE', 'finalize');
AppendInstallOutput(CustomMessage('InstallOutputPostInstall'));
#if Int(QAIsolated) == 0
MigrateLegacyData();
@@ -980,6 +1044,7 @@ begin
if LastInstallProgressPercent <> 100 then
begin
LastInstallProgressPercent := 100;
LogBootstrapEvent('PROGRESS', '100|' + ExpandConstant(CurrentFileName));
FlushInstallOutput();
end;
Exit;
@@ -991,6 +1056,7 @@ begin
if ProgressPercent <> LastInstallProgressPercent then
begin
LastInstallProgressPercent := ProgressPercent;
LogBootstrapEvent('PROGRESS', IntToStr(ProgressPercent) + '|' + ExpandConstant(CurrentFileName));
FlushInstallOutput();
end;
end;