${pluginAvatarHtml(item)}
@@ -432,7 +435,7 @@ function loadedPluginHtml(item, index) {
- 运行中
+ ${statusBadge}
${escapeHtml(item.title)}
${escapeHtml(item.module)}
${escapeHtml(item.description)}
@@ -584,7 +587,9 @@ function openLoadedDetail(item) {
setDetailAvatar(item);
$("#detail-title").textContent = item.title || item.name;
$("#detail-module").textContent = item.module || "";
- $("#detail-badges").innerHTML = '运行中';
+ $("#detail-badges").innerHTML = item.disabled
+ ? '已禁用'
+ : '运行中';
const homepage = safeUrl(item.homepage);
$("#detail-body").innerHTML = `
-
@@ -604,12 +609,41 @@ function openLoadedDetail(item) {
${item.path ? `` : ""}
${homepage ? `` : ""}
`;
- $("#detail-actions").innerHTML = homepage
- ? `打开主页`
- : ``;
+ const isSelf = item.module === "nonebot_plugin_mimo_console";
+ const toggleButton = isSelf
+ ? ""
+ : ``;
+ $("#detail-actions").innerHTML = [
+ homepage ? `打开主页` : "",
+ toggleButton,
+ ].join("");
+ const toggle = $("#detail-toggle-disabled");
+ if (toggle) toggle.addEventListener("click", () => togglePluginDisabled(item));
showDetail(true);
}
+async function togglePluginDisabled(item) {
+ const next = !item.disabled;
+ if (
+ next
+ && !window.confirm(
+ `确定禁用插件「${item.title || item.name}」?\n禁用后它的响应器不再处理消息(插件后台任务不受影响),可随时重新启用。`,
+ )
+ ) return;
+ try {
+ await api("/plugins/disabled", {
+ method: "PUT",
+ body: JSON.stringify({ plugin: item.name, disabled: next }),
+ });
+ item.disabled = next;
+ renderPlugins();
+ openLoadedDetail(item);
+ toast(next ? `已禁用 ${item.title || item.name}` : `已启用 ${item.title || item.name}`);
+ } catch (error) {
+ toast(error.message, "error");
+ }
+}
+
async function openStoreDetail(item) {
if (!item) return;
state.detailSource = "store";
diff --git a/src/nonebot_plugin_mimo_console/static/assets/styles.css b/src/nonebot_plugin_mimo_console/static/assets/styles.css
index fbcb826..d537448 100644
--- a/src/nonebot_plugin_mimo_console/static/assets/styles.css
+++ b/src/nonebot_plugin_mimo_console/static/assets/styles.css
@@ -1077,6 +1077,11 @@ a { color: inherit; text-decoration: none; }
background: rgba(110, 217, 168, 0.1);
color: var(--green);
}
+.badge.disabled {
+ border: 1px solid var(--line);
+ background: var(--surface-soft);
+ color: var(--muted);
+}
.badge.official {
border: 1px solid rgba(117, 139, 153, 0.2);
background: rgba(117, 139, 153, 0.1);
diff --git a/src/nonebot_plugin_mimo_console/static/index.html b/src/nonebot_plugin_mimo_console/static/index.html
index a52b7ea..10e5cf7 100644
--- a/src/nonebot_plugin_mimo_console/static/index.html
+++ b/src/nonebot_plugin_mimo_console/static/index.html
@@ -23,7 +23,7 @@
-
+
@@ -115,7 +115,7 @@
路径
${escapeHtml(item.path)}
链接
欢迎回来
Mimo Console · v0.1.3
+ Mimo Console · v0.1.5
@@ -517,6 +517,6 @@