#!/bin/bash
# 为所有表格添加列头最小宽度,确保内容完整显示
# 作者: AI助手
# 日期: 2024年5月
# 查找所有包含表格的HTML文件
files=$(grep -l "table-container" pages/*.html)
for file in $files; do
echo "正在处理: $file"
# 使用sed查找表头并添加最小宽度类
sed -i '' 's/
地块编号<\/th>/ | 地块编号<\/th>/g' "$file"
sed -i '' 's/ | 地块名称<\/th>/ | 地块名称<\/th>/g' "$file"
sed -i '' 's/ | 所属农场<\/th>/ | 所属农场<\/th>/g' "$file"
sed -i '' 's/ | 所属区域<\/th>/ | 所属区域<\/th>/g' "$file"
sed -i '' 's/ | 地块类型<\/th>/ | 地块类型<\/th>/g' "$file"
sed -i '' 's/ | 面积(亩)<\/th>/ | 面积(亩)<\/th>/g' "$file"
sed -i '' 's/ | 种植作物<\/th>/ | 种植作物<\/th>/g' "$file"
sed -i '' 's/ | 主要作物<\/th>/ | 主要作物<\/th>/g' "$file"
sed -i '' 's/ | 土壤类型<\/th>/ | 土壤类型<\/th>/g' "$file"
sed -i '' 's/ | 灌溉方式<\/th>/ | 灌溉方式<\/th>/g' "$file"
sed -i '' 's/ | 使用状态<\/th>/ | 使用状态<\/th>/g' "$file"
sed -i '' 's/ | 状态<\/th>/ | 状态<\/th>/g' "$file"
sed -i '' 's/ | 绑定设备<\/th>/ | 绑定设备<\/th>/g' "$file"
sed -i '' 's/ | 绑定人员<\/th>/ | 绑定人员<\/th>/g' "$file"
sed -i '' 's/ | 负责人<\/th>/ | 负责人<\/th>/g' "$file"
sed -i '' 's/ | 创建时间<\/th>/ | 创建时间<\/th>/g' "$file"
sed -i '' 's/ | 上次更新<\/th>/ | 上次更新<\/th>/g' "$file"
sed -i '' 's/ | 地理位置<\/th>/ | 地理位置<\/th>/g' "$file"
sed -i '' 's/ | 开垦日期<\/th>/ | 开垦日期<\/th>/g' "$file"
sed -i '' 's/ | 设备数量<\/th>/ | 设备数量<\/th>/g' "$file"
# 设备管理相关
sed -i '' 's/ | 设备编号<\/th>/ | 设备编号<\/th>/g' "$file"
sed -i '' 's/ | 设备名称<\/th>/ | 设备名称<\/th>/g' "$file"
sed -i '' 's/ | 设备类型<\/th>/ | 设备类型<\/th>/g' "$file"
sed -i '' 's/ | 所属地块<\/th>/ | 所属地块<\/th>/g' "$file"
sed -i '' 's/ | 设备型号<\/th>/ | 设备型号<\/th>/g' "$file"
sed -i '' 's/ | 厂家<\/th>/ | 厂家<\/th>/g' "$file"
sed -i '' 's/ | 安装日期<\/th>/ | 安装日期<\/th>/g' "$file"
sed -i '' 's/ | 最后活动时间<\/th>/ | 最后活动时间<\/th>/g' "$file"
# 用户管理相关
sed -i '' 's/ | 用户名<\/th>/ | 用户名<\/th>/g' "$file"
sed -i '' 's/ | 姓名<\/th>/ | 姓名<\/th>/g' "$file"
sed -i '' 's/ | 手机号<\/th>/ | 手机号<\/th>/g' "$file"
sed -i '' 's/ | 邮箱<\/th>/ | 邮箱<\/th>/g' "$file"
sed -i '' 's/ | 角色<\/th>/ | 角色<\/th>/g' "$file"
sed -i '' 's/ | 部门<\/th>/ | 部门<\/th>/g' "$file"
# 操作相关
sed -i '' 's/ | 操作<\/th>/ | 操作<\/th>/g' "$file"
echo "完成处理: $file"
done
# 移除表头可能存在的whitespace-nowrap类名,避免与CSS样式冲突
files=$(grep -l "whitespace-nowrap" pages/*.html)
for file in $files; do
echo "正在清理whitespace-nowrap: $file"
sed -i '' 's/class="whitespace-nowrap min-w-/class="min-w-/g' "$file"
echo "完成清理: $file"
done
echo "所有表格表头宽度优化完成!" |