add status bar for plugin/capability status instead of message box

This commit is contained in:
SoftFever
2026-07-03 14:57:35 +08:00
parent e3c6ec309d
commit 6fd1176661
5 changed files with 208 additions and 49 deletions

View File

@@ -1,7 +1,7 @@
const pluginsById = new Map();
const pluginInstallActions = {
"explore": {
label: "Browse plugins",
label: "Install plugin",
command: "open_plugin_hub"
},
"install-local": {
@@ -40,7 +40,6 @@ function OnInit() {
exploreMenu?.addEventListener("click", OnExploreMenuClick);
document.getElementById("open_terminal")?.addEventListener("click", () => SendMessage("open_terminal"));
document.getElementById("detailUpdateBtn")?.addEventListener("click", UpdateSelectedPlugin);
document.getElementById("close_btn")?.addEventListener("click", () => SendMessage("close_page"));
document.querySelectorAll("[role='tab']").forEach((tab) => {
tab.addEventListener("click", () => ActivateDetailTab(String(tab.dataset.tab || "")));
@@ -216,9 +215,26 @@ function HandleStudio(value) {
if (payload.command === "list_plugins") {
SetSelectedInstallAction(payload.install_action, false);
ApplyPlugins(payload.data || []);
} else if (payload.command === "status_message") {
ShowStatusMessage(String(payload.message || ""), String(payload.level || "info"));
}
}
// Renders the latest plugin/capability operation result in the footer status bar. The result
// persists until the next operation replaces it; the native side already localizes the text.
function ShowStatusMessage(message, level) {
const bar = document.getElementById("statusBar");
const text = document.getElementById("statusText");
if (!bar || !text)
return;
const normalizedLevel = ["success", "warn", "error", "info"].includes(level) ? level : "info";
text.textContent = message;
text.title = message;
bar.classList.remove("is-empty", "level-success", "level-warn", "level-error", "level-info");
bar.classList.add(`level-${normalizedLevel}`);
}
function SafeJsonParse(value) {
try {
return JSON.parse(value);