迁移运维工具确认事件
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import './bootstrap';
|
|||||||
import { bindAdminAutoactControls } from './admin/autoact.js';
|
import { bindAdminAutoactControls } from './admin/autoact.js';
|
||||||
import { bindAdminFishingEventsControls } from './admin/fishing-events.js';
|
import { bindAdminFishingEventsControls } from './admin/fishing-events.js';
|
||||||
import { bindAdminGameConfigControls } from './admin/game-configs.js';
|
import { bindAdminGameConfigControls } from './admin/game-configs.js';
|
||||||
|
import { bindAdminOpsControls } from './admin/ops.js';
|
||||||
import { bindAdminRoomControls } from './admin/rooms.js';
|
import { bindAdminRoomControls } from './admin/rooms.js';
|
||||||
import { bindAdminSignInRulesControls } from './admin/sign-in-rules.js';
|
import { bindAdminSignInRulesControls } from './admin/sign-in-rules.js';
|
||||||
|
|
||||||
@@ -9,5 +10,6 @@ import { bindAdminSignInRulesControls } from './admin/sign-in-rules.js';
|
|||||||
bindAdminAutoactControls();
|
bindAdminAutoactControls();
|
||||||
bindAdminFishingEventsControls();
|
bindAdminFishingEventsControls();
|
||||||
bindAdminGameConfigControls();
|
bindAdminGameConfigControls();
|
||||||
|
bindAdminOpsControls();
|
||||||
bindAdminRoomControls();
|
bindAdminRoomControls();
|
||||||
bindAdminSignInRulesControls();
|
bindAdminSignInRulesControls();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
修改 <code class="bg-gray-100 px-1 rounded">.env</code> 后、部署新版本后建议执行。
|
修改 <code class="bg-gray-100 px-1 rounded">.env</code> 后、部署新版本后建议执行。
|
||||||
</p>
|
</p>
|
||||||
<form action="{{ route('admin.ops.clear-cache') }}" method="POST"
|
<form action="{{ route('admin.ops.clear-cache') }}" method="POST"
|
||||||
onsubmit="return confirm('确定清理应用缓存?')">
|
data-ops-confirm="确定清理应用缓存?">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
部署后出现 404 路由错误时执行。
|
部署后出现 404 路由错误时执行。
|
||||||
</p>
|
</p>
|
||||||
<form action="{{ route('admin.ops.clear-routes') }}" method="POST"
|
<form action="{{ route('admin.ops.clear-routes') }}" method="POST"
|
||||||
onsubmit="return confirm('确定清理路由缓存?')">
|
data-ops-confirm="确定清理路由缓存?">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
页面样式或内容更新后未生效时执行。
|
页面样式或内容更新后未生效时执行。
|
||||||
</p>
|
</p>
|
||||||
<form action="{{ route('admin.ops.clear-views') }}" method="POST"
|
<form action="{{ route('admin.ops.clear-views') }}" method="POST"
|
||||||
onsubmit="return confirm('确定清理视图缓存?')">
|
data-ops-confirm="确定清理视图缓存?">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
class="px-4 py-2 bg-amber-500 text-white rounded-lg text-sm font-bold hover:bg-amber-600 transition shadow-sm">
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
<strong>执行后在线用户需重新进房才能出现在名单中。</strong>
|
<strong>执行后在线用户需重新进房才能出现在名单中。</strong>
|
||||||
</p>
|
</p>
|
||||||
<form action="{{ route('admin.ops.clear-room-online') }}" method="POST"
|
<form action="{{ route('admin.ops.clear-room-online') }}" method="POST"
|
||||||
onsubmit="return confirm('确定清理所有房间在线名单?\n在线用户需重进房间才能重新出现在名单!')">
|
data-ops-confirm="确定清理所有房间在线名单? 在线用户需重进房间才能重新出现在名单!">
|
||||||
@csrf
|
@csrf
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="px-4 py-2 bg-red-500 text-white rounded-lg text-sm font-bold hover:bg-red-600 transition shadow-sm">
|
class="px-4 py-2 bg-red-500 text-white rounded-lg text-sm font-bold hover:bg-red-600 transition shadow-sm">
|
||||||
|
|||||||
Reference in New Issue
Block a user