fix(POSTV1-runtime): 改善后台启动与状态窗口可见性
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run
Dada P0-A isolated Windows CI / validate-and-package (push) Waiting to run
This commit is contained in:
@@ -107,5 +107,7 @@ if (!workerPort && process.argv.includes("--dada-ai-probe")) {
|
|||||||
} catch {
|
} catch {
|
||||||
storageStatus = "unavailable";
|
storageStatus = "unavailable";
|
||||||
control.reportStatus("storage_unavailable");
|
control.reportStatus("storage_unavailable");
|
||||||
|
clearInterval(keepAlive);
|
||||||
|
setTimeout(() => process.exit(1), 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ internal static class Program
|
|||||||
};
|
};
|
||||||
var state = await runtime.StartAsync();
|
var state = await runtime.StartAsync();
|
||||||
if (!form.IsDisposed) form.SetState(state);
|
if (!form.IsDisposed) form.SetState(state);
|
||||||
if (state == SupervisorState.Ready) SupervisorForm.OpenProductInSupportedBrowser();
|
if (state == SupervisorState.Ready && !SupervisorForm.OpenProductInSupportedBrowser())
|
||||||
|
{
|
||||||
|
form.SetBrowserLaunchFailure();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
form.Shown += async (_, _) => await StartRuntimeAsync();
|
form.Shown += async (_, _) => await StartRuntimeAsync();
|
||||||
form.RestartRequested += async () => await StartRuntimeAsync();
|
form.RestartRequested += async () => await StartRuntimeAsync();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ internal sealed class SupervisorForm : Form
|
|||||||
Font = new Font("Segoe UI", 9F);
|
Font = new Font("Segoe UI", 9F);
|
||||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
|
ShowInTaskbar = true;
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Dada";
|
Text = "Dada";
|
||||||
|
|
||||||
@@ -90,10 +91,6 @@ internal sealed class SupervisorForm : Form
|
|||||||
trayIcon.DoubleClick += (_, _) => RestoreWindow();
|
trayIcon.DoubleClick += (_, _) => RestoreWindow();
|
||||||
|
|
||||||
FormClosing += (_, _) => trayIcon.Visible = false;
|
FormClosing += (_, _) => trayIcon.Visible = false;
|
||||||
Resize += (_, _) =>
|
|
||||||
{
|
|
||||||
if (WindowState == FormWindowState.Minimized) Hide();
|
|
||||||
};
|
|
||||||
SetState(initialState);
|
SetState(initialState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,6 +136,14 @@ internal sealed class SupervisorForm : Form
|
|||||||
Activate();
|
Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SetBrowserLaunchFailure()
|
||||||
|
{
|
||||||
|
if (state == SupervisorState.Ready)
|
||||||
|
{
|
||||||
|
statusDetail.Text = "本机服务运行正常,但未能自动打开浏览器;请点击“打开 Dada”或选择浏览器。";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing) trayIcon.Dispose();
|
if (disposing) trayIcon.Dispose();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
@@ -13,10 +14,20 @@ internal static class SupportedBrowserLauncher
|
|||||||
{
|
{
|
||||||
var executable = FindExecutable(executableName);
|
var executable = FindExecutable(executableName);
|
||||||
if (executable is null) return false;
|
if (executable is null) return false;
|
||||||
var startInfo = new ProcessStartInfo(executable) { UseShellExecute = false };
|
try
|
||||||
startInfo.ArgumentList.Add(uri.AbsoluteUri);
|
{
|
||||||
Process.Start(startInfo);
|
var startInfo = new ProcessStartInfo(executable) { UseShellExecute = false };
|
||||||
return true;
|
startInfo.ArgumentList.Add(uri.AbsoluteUri);
|
||||||
|
return Process.Start(startInfo) is not null;
|
||||||
|
}
|
||||||
|
catch (Win32Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? FindExecutable(string executableName)
|
private static string? FindExecutable(string executableName)
|
||||||
|
|||||||
Reference in New Issue
Block a user