diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/App.js | 102 | ||||
| -rw-r--r-- | public/index.html | 2 |
2 files changed, 56 insertions, 48 deletions
diff --git a/public/App.js b/public/App.js index 1f28482..4716bb3 100644 --- a/public/App.js +++ b/public/App.js @@ -885,53 +885,7 @@ export function selectionForLiveStart(selection) { } } -export function startRun(selection) { - const requestBody = { - projectId: selection.ProjectId, - runId: selection.RunId, - baseId: selection.BaseId, - targetId: selection.TargetId, - render: selection.Render, - }; - const requestOptions = { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(requestBody), - }; - setText("run-message", "正在启动设计运行"); - updateStreamState("实时链路 · 等待服务端确认"); - startImmediate(singleton.Delay(() => singleton.TryWith(singleton.Delay(() => singleton.Bind(awaitPromise(fetch("/api/runs/start", requestOptions)), (_arg) => { - let arg; - const response = _arg; - if (response.ok) { - return singleton.Bind(awaitPromise(response.json()), (_arg_1) => { - updateState(_arg_1); - connectToServer(selection); - updateStreamState("实时链路 · SSE 已连接"); - return singleton.Zero(); - }); - } - else { - setText("run-message", (arg = (response.status | 0), toText(printf("启动失败 · HTTP %d"))(arg))); - updateStreamState("实时链路 · 启动失败"); - return singleton.Zero(); - } - })), (_arg_2) => { - setText("run-message", "启动失败 · 无法连接服务端"); - updateStreamState("实时链路 · 连接失败"); - return singleton.Zero(); - }))); -} - -/** - * Boot-time historical load: surface the pre-published probe build replay so - * first-time visitors see the real vehicle instead of an empty placeholder. - * Any failure leaves the honest placeholder idle state untouched. - */ -export function loadBootHistory() { - const selection = selectedRun(); +export function loadHistoryFor(selection) { const projectId = encodeURIComponent(selection.ProjectId); const runId = encodeURIComponent(selection.RunId); const url = toText(printf("/api/artifacts/manifest?projectId=%s&runId=%s"))(projectId)(runId); @@ -985,6 +939,60 @@ export function loadBootHistory() { }))); } +export function startRun(selection) { + const requestBody = { + projectId: selection.ProjectId, + runId: selection.RunId, + baseId: selection.BaseId, + targetId: selection.TargetId, + render: selection.Render, + }; + const requestOptions = { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(requestBody), + }; + setText("run-message", "正在启动设计运行"); + updateStreamState("实时链路 · 等待服务端确认"); + startImmediate(singleton.Delay(() => singleton.TryWith(singleton.Delay(() => singleton.Bind(awaitPromise(fetch("/api/runs/start", requestOptions)), (_arg) => { + let arg; + const response = _arg; + if (response.ok) { + return singleton.Bind(awaitPromise(response.json()), (_arg_1) => { + updateState(_arg_1); + connectToServer(selection); + updateStreamState("实时链路 · SSE 已连接"); + return singleton.Zero(); + }); + } + else if (response.status === 409) { + setText("run-message", "该运行已完成 · 载入历史回放"); + loadHistoryFor(selection); + return singleton.Zero(); + } + else { + setText("run-message", (arg = (response.status | 0), toText(printf("启动失败 · HTTP %d"))(arg))); + updateStreamState("实时链路 · 启动失败"); + return singleton.Zero(); + } + })), (_arg_2) => { + setText("run-message", "启动失败 · 无法连接服务端"); + updateStreamState("实时链路 · 连接失败"); + return singleton.Zero(); + }))); +} + +/** + * Boot-time historical load: surface the pre-published probe build replay so + * first-time visitors see the real vehicle instead of an empty placeholder. + * Any failure leaves the honest placeholder idle state untouched. + */ +export function loadBootHistory() { + loadHistoryFor(selectedRun()); +} + export function boot() { showFrameMetadata(item(0, frames)); try { diff --git a/public/index.html b/public/index.html index 494d26c..b2f8703 100644 --- a/public/index.html +++ b/public/index.html @@ -196,6 +196,6 @@ <span>heritage 参考线保留占位演示 · F# / OPEN CODE</span> </footer> </main> - <script type="module" src="/App.js?v=orbit1"></script> + <script type="module" src="/App.js?v=ship1"></script> </body> </html> |
