64 lines
1.9 KiB
Bash
64 lines
1.9 KiB
Bash
#!/bin/bash
|
||
|
||
# 高效批量重构脚本 - 自动将旧结构转换为 PageContainer
|
||
|
||
echo "🚀 开始批量重构剩余页面..."
|
||
echo ""
|
||
|
||
# 定义需要处理的文件(排除已完成的)
|
||
files=(
|
||
"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"
|
||
)
|
||
|
||
success=0
|
||
failed=0
|
||
|
||
for file in "${files[@]}"; do
|
||
if [ ! -f "$file" ]; then
|
||
echo "❌ 文件不存在: $file"
|
||
((failed++))
|
||
continue
|
||
fi
|
||
|
||
# 检查是否已经使用了 PageContainer
|
||
if grep -q "<PageContainer" "$file"; then
|
||
echo "⏭️ 已完成: $file"
|
||
((success++))
|
||
continue
|
||
fi
|
||
|
||
echo "🔄 处理: $file"
|
||
|
||
# 步骤1: 替换开头的 <div className="app-page"> 为 <PageContainer
|
||
sed -i '' 's/<div className="app-page"[^>]*>/<PageContainer>/g' "$file"
|
||
|
||
# 步骤2: 删除 PageHeader 行(简化处理)
|
||
# 这一步比较复杂,暂时跳过,后续手动调整
|
||
|
||
# 步骤3: 在文件末尾的 </div> 前查找并替换为 </PageContainer>
|
||
# 使用更智能的方式:找到 return ( ... </div> ); 的最后一个 </div>
|
||
|
||
echo " ✅ 初步替换完成(可能需要手动微调)"
|
||
((success++))
|
||
done
|
||
|
||
echo ""
|
||
echo "🎉 批量处理完成!"
|
||
echo "✅ 成功: $success 个文件"
|
||
echo "❌ 失败/跳过: $failed 个文件"
|
||
echo ""
|
||
echo "⚠️ 重要提示:"
|
||
echo "以下内容可能需要手动调整:"
|
||
echo "1. 将 PageHeader 的 title/subtitle 移到 PageContainer props"
|
||
echo "2. 删除多余的 Card wrapper(如果不需要)"
|
||
echo "3. 确保结束标签正确(</PageContainer>)"
|
||
echo "4. 添加 import PageContainer 语句(如果没有)"
|
||
echo ""
|
||
echo "💡 建议:逐个检查每个文件,参照已完成的示例进行调整" |