根因:admin_power 菜单表中「登录用户」「登录网站」两个叶子菜单的 open_type 为 NULL,被渲染成 menu-open-type="null",点击时 Pear Admin 不会以 iframe 方式把页面加载进内容区——表格永远不显示,且页面被弹到 独立窗口,表现为"侧栏父菜单点不开子菜单"。其它页面型菜单的 open_type 均为 _iframe。 处理: - 新增迁移 b2c3d4e5f6a7,将这两行 open_type 修正为 _iframe(按 url 幂等匹配) - 清理 cookie_user/main.html 中被外部工具注入的 data-page-node-id 噪声属性 验证:本地起服务 + Playwright 登录后点击菜单项,确认内容区生成 iframe、 表格正常渲染(含工具栏、默认工具栏刷新/筛选/打印/导出、新增按钮,空表显示 "暂无登录用户"),且 cookie 页打开时侧栏父菜单仍能展开子菜单。
213 lines
7.8 KiB
HTML
213 lines
7.8 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>
|
|
|
|
<script type="text/html" id="col-cookie-user-value">
|
|
{{# var v = d.cookie_value || ''; }}
|
|
{{# if(v.length > 30){ }}
|
|
<span title="{{ v }}">{{ v.slice(0, 30) }}...</span>
|
|
{{# } else { }}
|
|
<span>{{ v }}</span>
|
|
{{# } }}
|
|
</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: 'Cookie值', field: 'cookie_value', align: 'center', minWidth: 200, templet: '#col-cookie-user-value'},
|
|
{title: '域名', field: 'domain', align: 'center'},
|
|
{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>
|