imeeting/frontend/batch-refactor.sh

62 lines
1.9 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# 批量重构所有页面为 PageContainer 风格
echo "🚀 开始批量重构所有页面..."
echo ""
# 定义需要处理的文件列表
files=(
"src/pages/system/platform-settings/index.tsx"
"src/pages/business/HotWords.tsx"
"src/pages/business/AiModels.tsx"
"src/pages/business/ClientManagement.tsx"
"src/pages/business/ExternalAppManagement.tsx"
"src/pages/business/PromptTemplates.tsx"
"src/pages/organization/orgs/index.tsx"
"src/pages/organization/tenants/index.tsx"
"src/pages/devices/index.tsx"
"src/pages/bindings/user-role/index.tsx"
"src/pages/bindings/role-permission/index.tsx"
"src/pages/profile/index.tsx"
)
count=0
total=${#files[@]}
for file in "${files[@]}"; do
if [ -f "$file" ]; then
echo "✅ 处理: $file"
# 检查是否已经使用了 PageContainer
if grep -q "<PageContainer" "$file"; then
echo " ⏭️ 已经是 PageContainer 风格,跳过"
((count++))
continue
fi
# 使用 sed 进行基本替换(简化版)
# 将 <div className="app-page"> 替换为 <PageContainer
sed -i '' 's/<div className="app-page[^"]*">/<PageContainer/g' "$file"
# 删除 PageHeader 行(因为 title/subtitle 会移到 PageContainer
# 这一步比较复杂,暂时跳过
# 将最后的 </div> 替换为 </PageContainer>(仅替换 return 块的最后一个)
# 这个也需要更复杂的逻辑
echo " ⚠️ 已完成初步替换,可能需要手动调整"
((count++))
else
echo "❌ 文件不存在: $file"
fi
done
echo ""
echo "🎉 完成!已处理 $count / $total 个文件"
echo ""
echo "⚠️ 注意:部分文件可能还需要手动微调"
echo "请检查以下内容:"
echo "1. PageHeader 的 title/subtitle 是否正确移到了 PageContainer props"
echo "2. Card wrapper 是否已移除"
echo "3. 结束标签是否从 </div> 改为 </PageContainer>"