mirror of
https://github.com/TommyFang2077/dsh-desktop.git
synced 2026-08-17 09:06:36 +08:00
feat: add mainland-reachable desktop distribution
This commit is contained in:
43
ui/app.js
43
ui/app.js
@@ -2,6 +2,10 @@ const statusEl = document.getElementById("status");
|
||||
const spinner = document.getElementById("spinner");
|
||||
const retry = document.getElementById("retry");
|
||||
const detail = document.getElementById("detail");
|
||||
const updatePanel = document.getElementById("update-panel");
|
||||
const updateNotes = document.getElementById("update-notes");
|
||||
const installUpdate = document.getElementById("install-update");
|
||||
const skipUpdate = document.getElementById("skip-update");
|
||||
|
||||
function tauri() {
|
||||
return window.__TAURI__;
|
||||
@@ -18,6 +22,13 @@ function setStatus(message, kind) {
|
||||
}
|
||||
}
|
||||
|
||||
function continueBoot(api) {
|
||||
updatePanel.hidden = true;
|
||||
spinner.hidden = false;
|
||||
setStatus("正在启动…", "ok");
|
||||
return api.core.invoke("skip_shell_update");
|
||||
}
|
||||
|
||||
async function boot() {
|
||||
const api = tauri();
|
||||
if (!api) {
|
||||
@@ -39,10 +50,42 @@ async function boot() {
|
||||
window.location.replace(event.payload.url);
|
||||
}
|
||||
});
|
||||
await api.event.listen("shell-update-progress", function (event) {
|
||||
const progress = event.payload || {};
|
||||
const suffix = typeof progress.percent === "number" ? ` ${progress.percent}%` : "";
|
||||
setStatus(`正在下载更新…${suffix}`, "ok");
|
||||
});
|
||||
|
||||
retry.addEventListener("click", function () {
|
||||
setStatus("正在重新启动…", "ok");
|
||||
api.core.invoke("restart");
|
||||
});
|
||||
skipUpdate.addEventListener("click", function () {
|
||||
continueBoot(api);
|
||||
});
|
||||
installUpdate.addEventListener("click", async function () {
|
||||
installUpdate.disabled = true;
|
||||
skipUpdate.disabled = true;
|
||||
spinner.hidden = false;
|
||||
setStatus("正在准备签名更新…", "ok");
|
||||
try {
|
||||
await api.core.invoke("install_shell_update");
|
||||
} catch (error) {
|
||||
installUpdate.disabled = false;
|
||||
skipUpdate.disabled = false;
|
||||
spinner.hidden = true;
|
||||
statusEl.textContent = `更新失败:${String(error)}`;
|
||||
}
|
||||
});
|
||||
|
||||
const update = await api.core.invoke("check_shell_update");
|
||||
if (update) {
|
||||
spinner.hidden = true;
|
||||
retry.hidden = true;
|
||||
statusEl.textContent = `发现壳更新 ${update.version}`;
|
||||
updateNotes.textContent = update.notes || "更新包已经签名,安装前会在本机完成校验。";
|
||||
updatePanel.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
|
||||
Reference in New Issue
Block a user