diff --git a/frontend/add-imports.sh b/frontend/add-imports.sh new file mode 100755 index 0000000..0358fbd --- /dev/null +++ b/frontend/add-imports.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# 批量添加 PageContainer import 到所有需要优化的页面 + +files=( + "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/business/MeetingDetail.tsx" + "src/pages/business/RealtimeAsrSession.tsx" + "src/pages/system/logs/index.tsx" + "src/pages/system/sys-params/index.tsx" + "src/pages/system/platform-settings/index.tsx" + "src/pages/system/dictionaries/index.tsx" + "src/pages/organization/orgs/index.tsx" + "src/pages/organization/tenants/index.tsx" + "src/pages/devices/index.tsx" + "src/pages/bindings/role-permission/index.tsx" + "src/pages/bindings/user-role/index.tsx" + "src/pages/profile/index.tsx" +) + +for file in "${files[@]}"; do + if [ -f "$file" ]; then + # 检查是否已经导入了 PageContainer + if ! grep -q "import PageContainer" "$file"; then + # 查找 PageHeader 的导入行并在其后添加 PageContainer + sed -i '' '/import PageHeader/a\ +import PageContainer from "@/components/shared/PageContainer"; +' "$file" + echo "✅ Added PageContainer import to: $file" + else + echo "⏭️ Already has PageContainer: $file" + fi + else + echo "❌ File not found: $file" + fi +done + +echo "" +echo "🎉 Import addition completed!" \ No newline at end of file diff --git a/frontend/batch-refactor-v2.sh b/frontend/batch-refactor-v2.sh new file mode 100644 index 0000000..c504d82 --- /dev/null +++ b/frontend/batch-refactor-v2.sh @@ -0,0 +1,64 @@ +#!/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 "]*>//g' "$file" + + # 步骤2: 删除 PageHeader 行(简化处理) + # 这一步比较复杂,暂时跳过,后续手动调整 + + # 步骤3: 在文件末尾的 前查找并替换为 + # 使用更智能的方式:找到 return ( ... ); 的最后一个 + + 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. 确保结束标签正确()" +echo "4. 添加 import PageContainer 语句(如果没有)" +echo "" +echo "💡 建议:逐个检查每个文件,参照已完成的示例进行调整" \ No newline at end of file diff --git a/frontend/batch-refactor.sh b/frontend/batch-refactor.sh new file mode 100644 index 0000000..c0e7f05 --- /dev/null +++ b/frontend/batch-refactor.sh @@ -0,0 +1,62 @@ +#!/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 " 替换为 / 替换为 (仅替换 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. 结束标签是否从 改为 " \ No newline at end of file diff --git a/frontend/src/components/shared/PageContainer/index.tsx b/frontend/src/components/shared/PageContainer/index.tsx new file mode 100644 index 0000000..d0584d7 --- /dev/null +++ b/frontend/src/components/shared/PageContainer/index.tsx @@ -0,0 +1,99 @@ +import React from 'react'; +import { Space, Typography } from 'antd'; +import type { ReactNode } from 'react'; + +const { Title, Text } = Typography; + +interface PageContainerProps { + title: ReactNode; + subtitle?: ReactNode; + children: ReactNode; + headerExtra?: ReactNode; + toolbar?: ReactNode; + className?: string; + style?: React.CSSProperties; +} + +const PageContainer: React.FC = ({ + title, + subtitle, + children, + headerExtra, + toolbar, + className = '', + style +}) => { + return ( +
+ {(title || headerExtra) && ( +
+
+ + {title} + + {subtitle && ( + + {subtitle} + + )} +
+ {headerExtra && ( +
+ {headerExtra} +
+ )} +
+ )} + + {toolbar && ( +
+ {toolbar} +
+ )} + +
+ {children} +
+
+ ); +}; + +export default PageContainer; \ No newline at end of file diff --git a/frontend/src/layouts/AppLayout.tsx b/frontend/src/layouts/AppLayout.tsx index 7c00ec8..9ff1b0a 100644 --- a/frontend/src/layouts/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout.tsx @@ -485,12 +485,12 @@ export default function AppLayout() { boxShadow: "var(--app-shadow)", overflow: "hidden", display: "flex", - flexDirection: "column" + flexDirection: "column", + flex: 1, + minHeight: 0 }} > -
- -
+