| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/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>/<th class="min-w-[120px]">地块编号<\/th>/g' "$file"
- sed -i '' 's/<th>地块名称<\/th>/<th class="min-w-[120px]">地块名称<\/th>/g' "$file"
- sed -i '' 's/<th>所属农场<\/th>/<th class="min-w-[120px]">所属农场<\/th>/g' "$file"
- sed -i '' 's/<th>所属区域<\/th>/<th class="min-w-[100px]">所属区域<\/th>/g' "$file"
- sed -i '' 's/<th>地块类型<\/th>/<th class="min-w-[100px]">地块类型<\/th>/g' "$file"
- sed -i '' 's/<th>面积(亩)<\/th>/<th class="min-w-[90px]">面积(亩)<\/th>/g' "$file"
- sed -i '' 's/<th>种植作物<\/th>/<th class="min-w-[120px]">种植作物<\/th>/g' "$file"
- sed -i '' 's/<th>主要作物<\/th>/<th class="min-w-[120px]">主要作物<\/th>/g' "$file"
- sed -i '' 's/<th>土壤类型<\/th>/<th class="min-w-[100px]">土壤类型<\/th>/g' "$file"
- sed -i '' 's/<th>灌溉方式<\/th>/<th class="min-w-[100px]">灌溉方式<\/th>/g' "$file"
- sed -i '' 's/<th>使用状态<\/th>/<th class="min-w-[100px]">使用状态<\/th>/g' "$file"
- sed -i '' 's/<th>状态<\/th>/<th class="min-w-[80px]">状态<\/th>/g' "$file"
- sed -i '' 's/<th>绑定设备<\/th>/<th class="min-w-[100px]">绑定设备<\/th>/g' "$file"
- sed -i '' 's/<th>绑定人员<\/th>/<th class="min-w-[100px]">绑定人员<\/th>/g' "$file"
- sed -i '' 's/<th>负责人<\/th>/<th class="min-w-[100px]">负责人<\/th>/g' "$file"
- sed -i '' 's/<th>创建时间<\/th>/<th class="min-w-[150px]">创建时间<\/th>/g' "$file"
- sed -i '' 's/<th>上次更新<\/th>/<th class="min-w-[150px]">上次更新<\/th>/g' "$file"
- sed -i '' 's/<th>地理位置<\/th>/<th class="min-w-[150px]">地理位置<\/th>/g' "$file"
- sed -i '' 's/<th>开垦日期<\/th>/<th class="min-w-[100px]">开垦日期<\/th>/g' "$file"
- sed -i '' 's/<th>设备数量<\/th>/<th class="min-w-[80px]">设备数量<\/th>/g' "$file"
-
- # 设备管理相关
- sed -i '' 's/<th>设备编号<\/th>/<th class="min-w-[120px]">设备编号<\/th>/g' "$file"
- sed -i '' 's/<th>设备名称<\/th>/<th class="min-w-[120px]">设备名称<\/th>/g' "$file"
- sed -i '' 's/<th>设备类型<\/th>/<th class="min-w-[100px]">设备类型<\/th>/g' "$file"
- sed -i '' 's/<th>所属地块<\/th>/<th class="min-w-[120px]">所属地块<\/th>/g' "$file"
- sed -i '' 's/<th>设备型号<\/th>/<th class="min-w-[100px]">设备型号<\/th>/g' "$file"
- sed -i '' 's/<th>厂家<\/th>/<th class="min-w-[100px]">厂家<\/th>/g' "$file"
- sed -i '' 's/<th>安装日期<\/th>/<th class="min-w-[100px]">安装日期<\/th>/g' "$file"
- sed -i '' 's/<th>最后活动时间<\/th>/<th class="min-w-[150px]">最后活动时间<\/th>/g' "$file"
-
- # 用户管理相关
- sed -i '' 's/<th>用户名<\/th>/<th class="min-w-[120px]">用户名<\/th>/g' "$file"
- sed -i '' 's/<th>姓名<\/th>/<th class="min-w-[100px]">姓名<\/th>/g' "$file"
- sed -i '' 's/<th>手机号<\/th>/<th class="min-w-[120px]">手机号<\/th>/g' "$file"
- sed -i '' 's/<th>邮箱<\/th>/<th class="min-w-[180px]">邮箱<\/th>/g' "$file"
- sed -i '' 's/<th>角色<\/th>/<th class="min-w-[100px]">角色<\/th>/g' "$file"
- sed -i '' 's/<th>部门<\/th>/<th class="min-w-[100px]">部门<\/th>/g' "$file"
-
- # 操作相关
- sed -i '' 's/<th>操作<\/th>/<th class="min-w-[150px]">操作<\/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 "所有表格表头宽度优化完成!"
|