feat: add admin dashboard, pipeline service, lightbox, and update dependencies
This commit is contained in:
+47
-2
@@ -1,11 +1,10 @@
|
||||
/* app.js — 基础前端交互 */
|
||||
/* app.js — 基础前端交互 + 管理后台共享工具 */
|
||||
|
||||
// Ctrl+K 或 / 聚焦搜索框
|
||||
document.addEventListener("keydown", function (e) {
|
||||
var input = document.querySelector(".nav-search-input");
|
||||
if (!input) return;
|
||||
|
||||
// 忽略在输入框内的按键
|
||||
if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") return;
|
||||
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "k") {
|
||||
@@ -16,3 +15,49 @@ document.addEventListener("keydown", function (e) {
|
||||
input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// ── Toast 通知(管理后台共享)──────────────────────────────────────────
|
||||
|
||||
function showToast(msg, opts) {
|
||||
opts = opts || {};
|
||||
var duration = opts.duration || 2500;
|
||||
var callback = opts.callback || null;
|
||||
|
||||
var t = document.createElement("div");
|
||||
t.className = "admin-toast";
|
||||
t.textContent = String(msg).substring(0, 200);
|
||||
document.body.appendChild(t);
|
||||
requestAnimationFrame(function () { t.classList.add("show"); });
|
||||
setTimeout(function () {
|
||||
t.classList.remove("show");
|
||||
setTimeout(function () {
|
||||
t.remove();
|
||||
if (typeof callback === "function") callback();
|
||||
}, 300);
|
||||
}, duration);
|
||||
}
|
||||
|
||||
// ── Admin 通用操作(管理后台共享)───────────────────────────────────────
|
||||
|
||||
function adminAction(action, callback) {
|
||||
fetch("/admin/" + action, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
})
|
||||
.then(function (r) {
|
||||
if (r.status === 303 || r.status === 401) {
|
||||
window.location.href = "/admin/login";
|
||||
return;
|
||||
}
|
||||
return r.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (data) {
|
||||
showToast(data.error ? "❌ " + data.error.substring(0, 200) : "✅ 操作成功");
|
||||
if (typeof callback === "function") callback(data);
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
showToast("❌ 请求失败");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user