SQL历史记录样式由css/common.css控制,但安全覆盖方式是通过自定义主题的theme.css文件添加规则,并在config.inc.php中指定ThemeDefault为custom。
phpmyadmin 5.x 的 sql 历史记录(即「sql 查询」标签页下方的 history 区域)样式主要由 js/dist/history.js 动态生成 dom,但最终渲染依赖于 templates/sql/history.twig 模板和全局 css 文件 css/common.css 中的 .history-entry、.history-query、.history-time 等类。直接修改 common.css 最有效,但要注意升级覆盖风险。
不建议直接改 common.css,推荐通过自定义 CSS 注入方式:
config.inc.php 中启用自定义主题支持:$cfg['ThemePath'] = 'themes';(确保路径存在)themes/custom/,复制一份 theme.css 进去(可从任一内置主题如 themes/pmahomme/theme.css 复制)theme.css 末尾添加覆盖规则,例如:.history-entry { padding: 6px 10px; border-bottom: 1px solid #eee; }.history-query { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.9em; }.history-time { color: #666; font-size: 0.8em; }
config.inc.php 中指定主题:$cfg['ThemeDefault'] = 'custom';
常见原因有三个:
theme.css 或 common.css —— 强制刷新(Ctrl+Shift+R 或清空缓存)themes/pmahomme/theme.css,但当前实际启用的主题不是 pmahomme(查 $cfg['ThemeDefault'] 值).history-entry .history-query 比单独的 .history-query 优先级高,需加权或用 !important(仅调试时临时用)不能靠纯 CSS 实现,因为 phpMyAdmin 不给不同 SQL 类型加 class。必须改 JS 逻辑:
js/dist/history.js(或源码中 js/src/history.js)appendHistoryEntry 或类似名)if (/^s*selectb/i.test(query)) { classes += ' history-select'; }
theme.css 里写 .history-select .history-query { background: #f0f9ff; }
注意:这类 JS 修改会在升级时丢失,且需重新构建前端资源(npm run build),实际生产环境慎用。
立即学习“PHP免费学习笔记(深入)”;