feat: tg/ws/security/

This commit is contained in:
hashbro
2026-10-03 05:40:19 +08:00
parent 6e4f7e6020
commit afac799588
32 changed files with 2038 additions and 18 deletions
+32 -1
View File
@@ -22,6 +22,9 @@
<table id="LAY-admin-list" lay-filter="LAY-admin-list"></table>
<script type="text/html" id="LAY-admin-ops">
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>
@{{# if(d.is_locked){ }}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="unlock">解锁</a>
@{{# } }}
@{{# if(!d.is_self){ }}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
@{{# } }}
@@ -53,8 +56,18 @@ layui.use(['table', 'form', 'layer'], function () {
return Number(d.google_auth_open) === 1 ? '开' : '关';
}},
{ field: 'last_ip', title: '最近登录IP', width: 140 },
{ field: 'is_locked', title: '锁定状态', width: 110, templet: function (d) {
if (d.is_locked) {
return '<span style="color:#ff5722;">已封锁</span><br><span style="font-size:12px;color:#999;">' + (d.locked_at || '') + '</span>';
}
var attempts = Number(d.login_attempts) || 0;
if (attempts > 0) {
return '<span style="color:#ffb800;">失败 ' + attempts + ' 次</span>';
}
return '<span style="color:#16b777;">正常</span>';
}},
{ field: 'created_at', title: '创建时间', width: 170, sort: true },
{ title: '操作', width: 160, toolbar: '#LAY-admin-ops' }
{ title: '操作', width: 200, toolbar: '#LAY-admin-ops' }
]],
page: true, limit: 20, limits: [10, 20, 30, 50],
request: { pageName: 'page', limitName: 'limit' },
@@ -128,6 +141,24 @@ layui.use(['table', 'form', 'layer'], function () {
table.on('tool(LAY-admin-list)', function (obj) {
if (obj.event === 'edit') openForm('编辑管理员', obj.data, false);
if (obj.event === 'unlock') {
layer.confirm('确定解除管理员「' + obj.data.username + '」的封禁状态?', function (index) {
$.ajax({
url: @json(url('/admin/system/admins')) + '/' + obj.data.id + '/unlock',
method: 'POST',
data: { _token: token },
success: function (res) {
if (res.code !== 0) return layer.msg(res.msg || '失败');
layer.msg(res.msg || '已解除封禁');
layer.close(index);
table.reload('LAY-admin-list');
},
error: function (xhr) {
layer.msg((xhr.responseJSON && (xhr.responseJSON.message || xhr.responseJSON.msg)) || '解锁失败');
}
});
});
}
if (obj.event === 'del') {
layer.confirm('确定删除管理员「' + obj.data.username + '」?', function (index) {
$.ajax({