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
+34 -1
View File
@@ -33,6 +33,9 @@
<script type="text/html" id="LAY-agent-ops">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="channels">渠道链接</a>
<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.telegram_ready) { }}
<a class="layui-btn layui-btn-xs" lay-event="tgtest">测试TG</a>
@{{# } }}
@@ -75,6 +78,16 @@ layui.use(['table', 'form', 'layer'], function () {
? '<span style="color:#16a34a;">已绑定</span>'
: '<span style="color:#888;">未绑定</span>';
}},
{ 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: 'chat_id', title: 'Chat ID', width: 140 },
{ field: 'comment', title: '备注', minWidth: 100 },
{ field: 'album_storage_default', title: '相册存储', width: 100, templet: function (d) {
@@ -93,7 +106,7 @@ layui.use(['table', 'form', 'layer'], function () {
cols.push(
{ field: 'channels_count', title: '渠道数', width: 90 },
{ field: 'created_at', title: '创建时间', width: 160, sort: true },
{ title: '操作', width: 240, align: 'center', fixed: 'right', toolbar: '#LAY-agent-ops' }
{ title: '操作', width: 300, align: 'center', fixed: 'right', toolbar: '#LAY-agent-ops' }
);
table.render({
@@ -241,6 +254,26 @@ layui.use(['table', 'form', 'layer'], function () {
if (res.code !== 0) return layer.msg(res.msg || '失败');
layer.close(index);
table.reload('LAY-agent-list');
},
error: function (xhr) {
layer.msg((xhr.responseJSON && xhr.responseJSON.message) || '更新失败');
}
});
});
} else if (obj.event === 'unlock') {
layer.confirm('确定解除代理「' + d.username + '」的封禁状态?', function (index) {
$.ajax({
url: @json(url('/admin/agents')) + '/' + d.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-agent-list');
},
error: function (xhr) {
layer.msg((xhr.responseJSON && (xhr.responseJSON.message || xhr.responseJSON.msg)) || '解锁失败');
}
});
});