auto-save 2026-05-11 14:39 (~6)

This commit is contained in:
2026-05-11 14:39:31 +08:00
parent 93118d4ce1
commit 5247dfd0dc
6 changed files with 168 additions and 19 deletions

View File

@@ -390,6 +390,7 @@ async function refreshFeishuApps() {
}
box.innerHTML = apps.map(app => {
const appId = escapeHTML(app.app_id || "");
const encodedAppId = encodeURIComponent(app.app_id || "");
const callbackUrl = escapeHTML(app.callback_url || "");
const isDefault = app.app_id === data.default_app_id;
const tokenCount = Number(app.verification_tokens_count || 0);
@@ -400,7 +401,12 @@ async function refreshFeishuApps() {
<div class="feishu-app-title">${appId}</div>
<div class="feishu-app-meta">${isDefault ? "默认应用" : "独立应用"} · ${tokenCount} 个校验 Token</div>
</div>
<span class="feishu-status">已接入</span>
<div class="feishu-app-actions">
<span class="feishu-status">已接入</span>
<button class="icon-btn-mini danger" onclick="deleteFeishuApp('${encodedAppId}')" title="删除机器人">
<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M19 6l-1 14H6L5 6"/><path d="M10 11v5"/><path d="M14 11v5"/></svg>
</button>
</div>
</div>
<div class="feishu-callback">
<span>${callbackUrl}</span>
@@ -421,6 +427,25 @@ async function refreshFeishuApps() {
}
}
async function deleteFeishuApp(encodedAppId) {
const appId = decodeURIComponent(encodedAppId || "");
if (!appId) return;
const ok = confirm(`删除飞书机器人 ${appId}\n\n删除后这个 App ID 的回调地址会立刻失效Secret / Token 也会从服务器环境文件移除。`);
if (!ok) return;
try {
const res = await fetch("/feishu/apps/" + encodeURIComponent(appId), {
method: "DELETE",
credentials: "same-origin",
});
const data = await res.json().catch(() => ({}));
if (!res.ok || data.code !== 0) throw new Error(data.msg || ("HTTP " + res.status));
toast("飞书机器人已删除");
await refreshFeishuApps();
} catch (e) {
toast("删除失败: " + (e.message || e));
}
}
async function saveFeishuApp(event) {
event.preventDefault();
const appIdEl = document.getElementById("feishuAppId");