登录用户: - 模型删除 cookie_value / domain 两列(连同 to_dict) - 列表表头、新增/编辑表单移除对应控件;保存/更新不再校验 Cookie 值 (改为只校验 用户名 + 网站URL) 登录网站: - CookieSite 新增 cookie_user_id(关联 admin_cookie_user.id,可空) - 列表新增「关联用户」列,未关联显示灰色「未关联」标签;查询栏支持按用户筛选 - 新增/编辑页用 layui 下拉框选择登录用户(lay-search 可搜索,显示 “昵称(用户名)· 网站名”),编辑时自动回显已关联项 - Schema 增加 cookie_username 输出字段,视图一次性查用户表做映射,避免逐行查库 迁移 e5f6a7b8c9d0: - admin_cookie_user 删 cookie_value、domain(SQLite 用 batch 重建表) - admin_cookie_site 加 cookie_user_id - 每步先判断列是否存在,可重复执行;downgrade 可还原 注意:升级会丢弃 admin_cookie_user.cookie_value / domain 的历史数据。 已 Playwright 真机验证(本机 :5000): 列表无 Cookie值/域名列、新增页无对应控件、保存成功; 网站新增选中用户后落库 cookie_user_id=1、列表显示“验证用户”、编辑页正确回显。
202 lines
7.3 KiB
HTML
202 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>登录用户</title>
|
|
{% include 'system/common/header.html' %}
|
|
</head>
|
|
<body class="pear-container">
|
|
{# 查询表单 #}
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<form class="layui-form" action="" lay-filter="cookie-user-query-form">
|
|
<div class="layui-form-item" style="margin-bottom: unset;">
|
|
<label class="layui-form-label">用户名</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="username" placeholder="" class="layui-input">
|
|
</div>
|
|
<label class="layui-form-label">网站名称</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" name="website_name" placeholder="" class="layui-input">
|
|
</div>
|
|
<label class="layui-form-label">状态</label>
|
|
<div class="layui-input-inline">
|
|
<select name="enable">
|
|
<option value="">全部</option>
|
|
<option value="1">启用</option>
|
|
<option value="0">禁用</option>
|
|
</select>
|
|
</div>
|
|
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-user-query">
|
|
<i class="layui-icon layui-icon-search"></i>
|
|
查询
|
|
</button>
|
|
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
|
<i class="layui-icon layui-icon-refresh"></i>
|
|
重置
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{# 用户表格 #}
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<table id="cookie-user-table" lay-filter="cookie-user-table"></table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
{% include 'system/common/footer.html' %}
|
|
{# 表格工具栏 #}
|
|
<script type="text/html" id="cookie-user-toolbar">
|
|
{% if authorize("system:cookie-user:add") %}
|
|
<button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add">
|
|
<i class="pear-icon pear-icon-add"></i>
|
|
新增
|
|
</button>
|
|
{% endif %}
|
|
</script>
|
|
|
|
{# 行操作 #}
|
|
<script type="text/html" id="cookie-user-op">
|
|
{% if authorize("system:cookie-user:edit") %}
|
|
<button class="layui-btn layui-btn-xs" lay-event="edit"><i class="pear-icon pear-icon-edit"></i> 编辑</button>
|
|
{% endif %}
|
|
{% if authorize("system:cookie-user:remove") %}
|
|
<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove"><i
|
|
class="pear-icon pear-icon-ashbin"></i> 删除
|
|
</button>
|
|
{% endif %}
|
|
</script>
|
|
|
|
{% raw %}
|
|
<script type="text/html" id="cookie-user-enable">
|
|
<input type="checkbox" name="enable" value="{{ d.id }}" lay-skin="switch" lay-text="启用|禁用"
|
|
lay-filter="cookie-user-enable" {{# if(d.enable==1){ }} checked {{# } }} />
|
|
</script>
|
|
{% endraw %}
|
|
|
|
<script>
|
|
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
|
|
let table = layui.table
|
|
let form = layui.form
|
|
let $ = layui.jquery
|
|
let popup = layui.popup
|
|
let common = layui.common
|
|
let MODULE_PATH = "{{ url_for('cookie_user.main') }}"
|
|
|
|
let cols = [
|
|
[
|
|
{title: '编号', field: 'id', align: 'center', width: 80},
|
|
{title: '用户名', field: 'username', align: 'center'},
|
|
{title: '昵称', field: 'nickname', align: 'center'},
|
|
{title: '网站名称', field: 'website_name', align: 'center'},
|
|
{title: '网站链接', field: 'website_url', align: 'center', minWidth: 200},
|
|
{title: '过期时间', field: 'expiry', align: 'center'},
|
|
{title: '状态', field: 'enable', align: 'center', templet: '#cookie-user-enable', width: 100},
|
|
{title: '创建时间', field: 'create_at', align: 'center'},
|
|
{title: '操作', toolbar: '#cookie-user-op', align: 'center', width: 140}
|
|
]
|
|
]
|
|
|
|
table.render({
|
|
elem: '#cookie-user-table',
|
|
url: MODULE_PATH + 'data',
|
|
page: true,
|
|
cols: cols,
|
|
skin: 'line',
|
|
toolbar: '#cookie-user-toolbar', /*工具栏*/
|
|
text: {none: '暂无登录用户'},
|
|
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
|
|
})
|
|
|
|
table.on('tool(cookie-user-table)', function (obj) {
|
|
if (obj.event === 'remove') {
|
|
window.remove(obj)
|
|
} else if (obj.event === 'edit') {
|
|
window.edit(obj)
|
|
}
|
|
})
|
|
|
|
table.on('toolbar(cookie-user-table)', function (obj) {
|
|
if (obj.event === 'add') {
|
|
window.add()
|
|
} else if (obj.event === 'refresh') {
|
|
window.refresh()
|
|
}
|
|
})
|
|
|
|
form.on('submit(cookie-user-query)', function (data) {
|
|
window.refresh(data.field)
|
|
return false
|
|
})
|
|
|
|
form.on('switch(cookie-user-enable)', function (obj) {
|
|
let operate = obj.elem.checked ? 'enable' : 'disable'
|
|
let loading = layer.load()
|
|
$.ajax({
|
|
url: MODULE_PATH + operate,
|
|
data: JSON.stringify({cookieUserId: this.value}),
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
type: 'put',
|
|
success: function (result) {
|
|
layer.close(loading)
|
|
if (result.success) {
|
|
popup.success(result.msg)
|
|
} else {
|
|
popup.failure(result.msg)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
window.add = function () {
|
|
layer.open({
|
|
type: 2,
|
|
title: '新增登录用户',
|
|
shade: 0.1,
|
|
area: ['700px', '680px'],
|
|
content: MODULE_PATH + 'add'
|
|
})
|
|
}
|
|
|
|
window.edit = function (obj) {
|
|
layer.open({
|
|
type: 2,
|
|
title: '编辑登录用户',
|
|
shade: 0.1,
|
|
area: ['700px', '680px'],
|
|
content: MODULE_PATH + 'edit?cookieUserId=' + obj.data['id']
|
|
})
|
|
}
|
|
|
|
window.remove = function (obj) {
|
|
layer.confirm('确定要删除该登录用户吗?', {icon: 3, title: '提示'}, function (index) {
|
|
layer.close(index)
|
|
let loading = layer.load()
|
|
$.ajax({
|
|
url: MODULE_PATH + 'remove/' + obj.data['id'],
|
|
dataType: 'json',
|
|
type: 'delete',
|
|
success: function (result) {
|
|
layer.close(loading)
|
|
if (result.success) {
|
|
popup.success(result.msg, function () {
|
|
obj.del()
|
|
})
|
|
} else {
|
|
popup.failure(result.msg)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
window.refresh = function (param) {
|
|
table.reload('cookie-user-table', {where: param})
|
|
}
|
|
})
|
|
</script>
|
|
</html>
|