@co0ontty/wand 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +3 -4
- package/dist/web-ui/content/scripts.js +6 -2
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -483,14 +483,13 @@ export async function startServer(config, configPath) {
|
|
|
483
483
|
});
|
|
484
484
|
app.post("/api/update", async (_req, res) => {
|
|
485
485
|
try {
|
|
486
|
-
const { updateAvailable } = await checkNpmLatestVersion();
|
|
486
|
+
const { updateAvailable, latest } = await checkNpmLatestVersion();
|
|
487
487
|
if (!updateAvailable) {
|
|
488
488
|
res.json({ ok: true, message: "已经是最新版本。" });
|
|
489
489
|
return;
|
|
490
490
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
execAsync(`npm install -g ${PKG_NAME}@latest`, { timeout: 120000 }).catch(() => { });
|
|
491
|
+
await execAsync(`npm install -g ${PKG_NAME}@latest`, { timeout: 120000 });
|
|
492
|
+
res.json({ ok: true, message: `已更新到 ${latest},请重启 wand 服务以生效。` });
|
|
494
493
|
}
|
|
495
494
|
catch (error) {
|
|
496
495
|
res.status(500).json({ error: getErrorMessage(error, "更新失败。") });
|
|
@@ -3864,11 +3864,15 @@
|
|
|
3864
3864
|
.then(function(res) { return res.json(); })
|
|
3865
3865
|
.then(function(data) {
|
|
3866
3866
|
if (msgEl) {
|
|
3867
|
-
msgEl.textContent = data.message || data.error || "
|
|
3867
|
+
msgEl.textContent = data.message || data.error || "更新完成。";
|
|
3868
3868
|
msgEl.style.color = data.error ? "var(--error)" : "var(--success)";
|
|
3869
3869
|
msgEl.classList.remove("hidden");
|
|
3870
3870
|
}
|
|
3871
|
-
if (
|
|
3871
|
+
if (data.error) {
|
|
3872
|
+
if (updateBtn) updateBtn.disabled = false;
|
|
3873
|
+
} else {
|
|
3874
|
+
if (updateBtn) updateBtn.classList.add("hidden");
|
|
3875
|
+
}
|
|
3872
3876
|
})
|
|
3873
3877
|
.catch(function() {
|
|
3874
3878
|
if (msgEl) {
|