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:
@@ -694,6 +694,23 @@ install_chinese_templates() {
|
||||
fi
|
||||
cp -f "$templates_dir"/*.tmpl /usr/share/cups/templates/
|
||||
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打印机(用于测试连接)
|
||||
|
||||
Reference in New Issue
Block a user