迁移后台输入选中事件

This commit is contained in:
2026-04-25 13:32:16 +08:00
parent 4352919889
commit c3229f870a
4 changed files with 32 additions and 3 deletions
+27
View File
@@ -0,0 +1,27 @@
// 后台只读输入框选择事件代理,用于复制类配置项的一键选中文本。
let adminInputSelectionBound = false;
/**
* 绑定后台只读输入框点击选中逻辑。
*
* @returns {void}
*/
export function bindAdminInputSelection() {
if (adminInputSelectionBound || typeof document === "undefined") {
return;
}
adminInputSelectionBound = true;
document.addEventListener("click", (event) => {
if (!(event.target instanceof HTMLInputElement)) {
return;
}
// 回调地址等只读字段点击后直接选中,便于管理员复制。
if (event.target.hasAttribute("data-admin-select-on-click")) {
event.target.select();
}
});
}