From 2848a9ad0b00b2af59292ae9b178a8685d88ca19 Mon Sep 17 00:00:00 2001 From: bwstudio Date: Wed, 9 Sep 2026 20:17:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugins):=20=E4=BF=AE=E5=A4=8D=20Cookie=20?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=AD=90=E9=A1=B5=E9=9D=A2=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=B8=8E=E4=BE=A7=E6=A0=8F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: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 页打开时侧栏父菜单仍能展开子菜单。 --- .../b2c3d4e5f6a7_fix_cookie_menu_open_type.py | 33 ++++++++++++ .../templates/system/cookie_user/main.html | 52 +++++++++---------- 2 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 migrations/versions/b2c3d4e5f6a7_fix_cookie_menu_open_type.py diff --git a/migrations/versions/b2c3d4e5f6a7_fix_cookie_menu_open_type.py b/migrations/versions/b2c3d4e5f6a7_fix_cookie_menu_open_type.py new file mode 100644 index 0000000..451ec6f --- /dev/null +++ b/migrations/versions/b2c3d4e5f6a7_fix_cookie_menu_open_type.py @@ -0,0 +1,33 @@ +"""fix cookie menu open_type to _iframe + +Cookie 管理下的「登录用户」/「登录网站」菜单项在 admin_power 表中 +open_type 为 NULL,导致点击时没有被以 iframe 方式加载进内容区, +表格无法显示、页面被弹到独立窗口(表现为侧栏父菜单点不开子菜单)。 +修正为 _iframe 与框架其它页面保持一致。 + +Revision ID: b2c3d4e5f6a7 +Revises: 1230ff234df9 +""" +from alembic import op + + +# revision identifiers, used by Alembic. +revision = 'b2c3d4e5f6a7' +down_revision = '1230ff234df9' +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute( + "UPDATE admin_power SET open_type='_iframe' " + "WHERE url IN ('/system/cookie-user/', '/system/cookie-site/') " + "AND (open_type IS NULL OR open_type='')" + ) + + +def downgrade(): + op.execute( + "UPDATE admin_power SET open_type=NULL " + "WHERE url IN ('/system/cookie-user/', '/system/cookie-site/')" + ) diff --git a/plugins/cookieManager/templates/system/cookie_user/main.html b/plugins/cookieManager/templates/system/cookie_user/main.html index 563da23..4298d42 100644 --- a/plugins/cookieManager/templates/system/cookie_user/main.html +++ b/plugins/cookieManager/templates/system/cookie_user/main.html @@ -1,37 +1,37 @@ - - + + 登录用户 {% include 'system/common/header.html' %} - + {# 查询表单 #} -
-
-
-
- -
- +
+
+ +
+ +
+
- -
- + +
+
- -
- + + +
- -
@@ -39,9 +39,9 @@
{# 用户表格 #} -
-
- +
+
+