update-min-width.sh 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # 为所有表格添加列头最小宽度,确保内容完整显示
  3. # 作者: AI助手
  4. # 日期: 2024年5月
  5. # 查找所有包含表格的HTML文件
  6. files=$(grep -l "table-container" pages/*.html)
  7. for file in $files; do
  8. echo "正在处理: $file"
  9. # 使用sed查找表头并添加最小宽度类
  10. sed -i '' 's/<th>地块编号<\/th>/<th class="min-w-[120px]">地块编号<\/th>/g' "$file"
  11. sed -i '' 's/<th>地块名称<\/th>/<th class="min-w-[120px]">地块名称<\/th>/g' "$file"
  12. sed -i '' 's/<th>所属农场<\/th>/<th class="min-w-[120px]">所属农场<\/th>/g' "$file"
  13. sed -i '' 's/<th>所属区域<\/th>/<th class="min-w-[100px]">所属区域<\/th>/g' "$file"
  14. sed -i '' 's/<th>地块类型<\/th>/<th class="min-w-[100px]">地块类型<\/th>/g' "$file"
  15. sed -i '' 's/<th>面积(亩)<\/th>/<th class="min-w-[90px]">面积(亩)<\/th>/g' "$file"
  16. sed -i '' 's/<th>种植作物<\/th>/<th class="min-w-[120px]">种植作物<\/th>/g' "$file"
  17. sed -i '' 's/<th>主要作物<\/th>/<th class="min-w-[120px]">主要作物<\/th>/g' "$file"
  18. sed -i '' 's/<th>土壤类型<\/th>/<th class="min-w-[100px]">土壤类型<\/th>/g' "$file"
  19. sed -i '' 's/<th>灌溉方式<\/th>/<th class="min-w-[100px]">灌溉方式<\/th>/g' "$file"
  20. sed -i '' 's/<th>使用状态<\/th>/<th class="min-w-[100px]">使用状态<\/th>/g' "$file"
  21. sed -i '' 's/<th>状态<\/th>/<th class="min-w-[80px]">状态<\/th>/g' "$file"
  22. sed -i '' 's/<th>绑定设备<\/th>/<th class="min-w-[100px]">绑定设备<\/th>/g' "$file"
  23. sed -i '' 's/<th>绑定人员<\/th>/<th class="min-w-[100px]">绑定人员<\/th>/g' "$file"
  24. sed -i '' 's/<th>负责人<\/th>/<th class="min-w-[100px]">负责人<\/th>/g' "$file"
  25. sed -i '' 's/<th>创建时间<\/th>/<th class="min-w-[150px]">创建时间<\/th>/g' "$file"
  26. sed -i '' 's/<th>上次更新<\/th>/<th class="min-w-[150px]">上次更新<\/th>/g' "$file"
  27. sed -i '' 's/<th>地理位置<\/th>/<th class="min-w-[150px]">地理位置<\/th>/g' "$file"
  28. sed -i '' 's/<th>开垦日期<\/th>/<th class="min-w-[100px]">开垦日期<\/th>/g' "$file"
  29. sed -i '' 's/<th>设备数量<\/th>/<th class="min-w-[80px]">设备数量<\/th>/g' "$file"
  30. # 设备管理相关
  31. sed -i '' 's/<th>设备编号<\/th>/<th class="min-w-[120px]">设备编号<\/th>/g' "$file"
  32. sed -i '' 's/<th>设备名称<\/th>/<th class="min-w-[120px]">设备名称<\/th>/g' "$file"
  33. sed -i '' 's/<th>设备类型<\/th>/<th class="min-w-[100px]">设备类型<\/th>/g' "$file"
  34. sed -i '' 's/<th>所属地块<\/th>/<th class="min-w-[120px]">所属地块<\/th>/g' "$file"
  35. sed -i '' 's/<th>设备型号<\/th>/<th class="min-w-[100px]">设备型号<\/th>/g' "$file"
  36. sed -i '' 's/<th>厂家<\/th>/<th class="min-w-[100px]">厂家<\/th>/g' "$file"
  37. sed -i '' 's/<th>安装日期<\/th>/<th class="min-w-[100px]">安装日期<\/th>/g' "$file"
  38. sed -i '' 's/<th>最后活动时间<\/th>/<th class="min-w-[150px]">最后活动时间<\/th>/g' "$file"
  39. # 用户管理相关
  40. sed -i '' 's/<th>用户名<\/th>/<th class="min-w-[120px]">用户名<\/th>/g' "$file"
  41. sed -i '' 's/<th>姓名<\/th>/<th class="min-w-[100px]">姓名<\/th>/g' "$file"
  42. sed -i '' 's/<th>手机号<\/th>/<th class="min-w-[120px]">手机号<\/th>/g' "$file"
  43. sed -i '' 's/<th>邮箱<\/th>/<th class="min-w-[180px]">邮箱<\/th>/g' "$file"
  44. sed -i '' 's/<th>角色<\/th>/<th class="min-w-[100px]">角色<\/th>/g' "$file"
  45. sed -i '' 's/<th>部门<\/th>/<th class="min-w-[100px]">部门<\/th>/g' "$file"
  46. # 操作相关
  47. sed -i '' 's/<th>操作<\/th>/<th class="min-w-[150px]">操作<\/th>/g' "$file"
  48. echo "完成处理: $file"
  49. done
  50. # 移除表头可能存在的whitespace-nowrap类名,避免与CSS样式冲突
  51. files=$(grep -l "whitespace-nowrap" pages/*.html)
  52. for file in $files; do
  53. echo "正在清理whitespace-nowrap: $file"
  54. sed -i '' 's/class="whitespace-nowrap min-w-/class="min-w-/g' "$file"
  55. echo "完成清理: $file"
  56. done
  57. echo "所有表格表头宽度优化完成!"