迁移运维工具确认事件
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// 运维工具后台事件代理,替代 Blade 内联确认提交逻辑。
|
||||
|
||||
let adminOpsControlsBound = false;
|
||||
|
||||
/**
|
||||
* 绑定运维工具确认提交事件。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindAdminOpsControls() {
|
||||
if (adminOpsControlsBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
adminOpsControlsBound = true;
|
||||
document.addEventListener("submit", (event) => {
|
||||
if (!(event.target instanceof HTMLFormElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 运维动作不可撤销,提交前统一读取 Blade 声明的确认文案。
|
||||
const confirmMessage = event.target.getAttribute("data-ops-confirm");
|
||||
if (confirmMessage && !window.confirm(confirmMessage)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user