fix: 自动适配CUPS不同版本的CSS类名
- 模板默认使用旧类名(header/body/footer)兼容CUPS 2.4.1 - 安装脚本自动检测目标系统CUPS版本的CSS类名 - 如果是新版CUPS(使用cups-header等),自动替换模板类名 - 解决不同CUPS版本CSS样式不加载的问题 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<title>{title} - CUPS 打印管理</title>
|
<title>{title} - CUPS 打印管理</title>
|
||||||
</head>
|
</head>
|
||||||
<body onload="check_cookies();">
|
<body onload="check_cookies();">
|
||||||
<div class="cups-header">
|
<div class="header">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="https://openprinting.github.io/cups/" target="_blank">OpenPrinting CUPS</a></li>
|
<li><a href="https://openprinting.github.io/cups/" target="_blank">OpenPrinting CUPS</a></li>
|
||||||
<li><a {SECTION=admin?class="active" :}href="/">首页</a></li>
|
<li><a {SECTION=admin?class="active" :}href="/">首页</a></li>
|
||||||
@@ -35,6 +35,6 @@
|
|||||||
<li><a {SECTION=printers?class="active" :}href="/printers/">打印机</a></li>
|
<li><a {SECTION=printers?class="active" :}href="/printers/">打印机</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="cups-body">
|
<div class="body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cups-footer">CUPS 和 CUPS 标志是 <a href="http://www.apple.com">Apple Inc.</a> 的商标 | 中文汉化版</div>
|
<div class="footer">CUPS 和 CUPS 标志是 <a href="http://www.apple.com">Apple Inc.</a> 的商标 | 中文汉化版</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -694,6 +694,23 @@ install_chinese_templates() {
|
|||||||
fi
|
fi
|
||||||
cp -f "$templates_dir"/*.tmpl /usr/share/cups/templates/
|
cp -f "$templates_dir"/*.tmpl /usr/share/cups/templates/
|
||||||
success "中文模板已设为默认"
|
success "中文模板已设为默认"
|
||||||
|
|
||||||
|
# 自动适配CSS类名(兼容不同CUPS版本)
|
||||||
|
# CUPS 2.4.7+ 使用 cups-header/cups-body/cups-footer
|
||||||
|
# CUPS 2.4.1 及更早版本使用 header/body/footer
|
||||||
|
local css_file="/usr/share/cups/doc-root/cups.css"
|
||||||
|
if [ -f "$css_file" ]; then
|
||||||
|
if grep -q "\.cups-header" "$css_file"; then
|
||||||
|
info "检测到新版CUPS CSS类名,自动适配模板..."
|
||||||
|
# 替换为新类名
|
||||||
|
sed -i 's/class="header"/class="cups-header"/g' "$templates_dir/header.tmpl" /usr/share/cups/templates/header.tmpl 2>/dev/null
|
||||||
|
sed -i 's/class="body"/class="cups-body"/g' "$templates_dir/header.tmpl" /usr/share/cups/templates/header.tmpl 2>/dev/null
|
||||||
|
sed -i 's/class="footer"/class="cups-footer"/g' "$templates_dir/trailer.tmpl" /usr/share/cups/templates/trailer.tmpl 2>/dev/null
|
||||||
|
success "CSS类名已适配为新版格式"
|
||||||
|
else
|
||||||
|
info "检测到旧版CUPS CSS类名,模板兼容"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 安装虚拟PDF打印机(用于测试连接)
|
# 安装虚拟PDF打印机(用于测试连接)
|
||||||
|
|||||||
Reference in New Issue
Block a user