Files
AIclinicalresearch/frontend-v2/src/framework/modules/ModuleErrorFallback.tsx
HaHafeng b64896a307 feat(deploy): Complete PostgreSQL migration and Docker image build
Summary:
- PostgreSQL database migration to RDS completed (90MB SQL, 11 schemas)
- Frontend Nginx Docker image built and pushed to ACR (v1.0, ~50MB)
- Python microservice Docker image built and pushed to ACR (v1.0, 1.12GB)
- Created 3 deployment documentation files

Docker Configuration Files:
- frontend-v2/Dockerfile: Multi-stage build with nginx:alpine
- frontend-v2/.dockerignore: Optimize build context
- frontend-v2/nginx.conf: SPA routing and API proxy
- frontend-v2/docker-entrypoint.sh: Dynamic env injection
- extraction_service/Dockerfile: Multi-stage build with Aliyun Debian mirror
- extraction_service/.dockerignore: Optimize build context
- extraction_service/requirements-prod.txt: Production dependencies (removed Nougat)

Deployment Documentation:
- docs/05-部署文档/00-部署进度总览.md: One-stop deployment status overview
- docs/05-部署文档/07-前端Nginx-SAE部署操作手册.md: Frontend deployment guide
- docs/05-部署文档/08-PostgreSQL数据库部署操作手册.md: Database deployment guide
- docs/00-系统总体设计/00-系统当前状态与开发指南.md: Updated with deployment status

Database Migration:
- RDS instance: pgm-2zex1m2y3r23hdn5 (2C4G, PostgreSQL 15.0)
- Database: ai_clinical_research
- Schemas: 11 business schemas migrated successfully
- Data: 3 users, 2 projects, 1204 literatures verified
- Backup: rds_init_20251224_154529.sql (90MB)

Docker Images:
- Frontend: crpi-cd5ij4pjt65mweeo.cn-beijing.personal.cr.aliyuncs.com/ai-clinical/ai-clinical_frontend-nginx:v1.0
- Python: crpi-cd5ij4pjt65mweeo.cn-beijing.personal.cr.aliyuncs.com/ai-clinical/python-extraction:v1.0

Key Achievements:
- Resolved Docker Hub network issues (using generic tags)
- Fixed 30 TypeScript compilation errors
- Removed Nougat OCR to reduce image size by 1.5GB
- Used Aliyun Debian mirror to resolve apt-get network issues
- Implemented multi-stage builds for optimization

Next Steps:
- Deploy Python microservice to SAE
- Build Node.js backend Docker image
- Deploy Node.js backend to SAE
- Deploy frontend Nginx to SAE
- End-to-end verification testing

Status: Docker images ready, SAE deployment pending
2025-12-24 18:21:55 +08:00

216 lines
6.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ErrorInfo } from 'react'
import { Result, Button, Collapse, Typography } from 'antd'
import { BugOutlined, ReloadOutlined, HomeOutlined } from '@ant-design/icons'
import { useNavigate } from 'react-router-dom'
/**
* 模块错误提示组件
*
* @description
* 当模块加载或运行出错时显示的友好错误页面
* 提供重试和返回首页的操作
*
* @version Week 2 Day 7 - 任务17
*/
const { Paragraph, Text } = Typography
interface ModuleErrorFallbackProps {
/** 错误对象 */
error: Error | null
/** 错误详细信息 */
errorInfo?: ErrorInfo | null
/** 重置错误状态的回调 */
onReset?: () => void
/** 模块名称 */
moduleName?: string
}
const ModuleErrorFallback = ({
error,
errorInfo,
onReset,
moduleName,
}: ModuleErrorFallbackProps) => {
const navigate = useNavigate()
// 是否显示详细错误信息(开发环境显示,生产环境隐藏)
const isDevelopment = import.meta.env.DEV
/**
* 处理重试
*/
const handleRetry = () => {
if (onReset) {
onReset()
} else {
// 如果没有提供onReset刷新页面
window.location.reload()
}
}
/**
* 返回首页
*/
const handleGoHome = () => {
navigate('/')
}
return (
<div className="flex-1 flex items-center justify-center bg-gray-50 p-8">
<div className="max-w-2xl w-full">
<Result
status="error"
icon={<BugOutlined style={{ fontSize: 72, color: '#ff4d4f' }} />}
title={
<span className="text-2xl">
{moduleName ? `${moduleName}模块` : '页面'}
</span>
}
subTitle={
<div className="space-y-3 mt-4">
<Paragraph className="text-gray-600">
</Paragraph>
<Paragraph className="text-gray-500 text-sm">
</Paragraph>
</div>
}
extra={
<div className="flex gap-3 justify-center">
<Button
type="primary"
icon={<ReloadOutlined />}
onClick={handleRetry}
size="large"
>
</Button>
<Button
icon={<HomeOutlined />}
onClick={handleGoHome}
size="large"
>
</Button>
</div>
}
/>
{/* 开发环境:显示详细错误信息 */}
{isDevelopment && error && (
<div className="mt-8">
<Collapse
ghost
items={[
{
key: 'error-details',
label: (
<Text type="secondary" className="text-sm">
🔧
</Text>
),
children: (
<div className="space-y-4">
{/* 错误消息 */}
<div>
<Text strong className="text-red-600"></Text>
<Paragraph
code
copyable
className="mt-2 bg-red-50 p-3 rounded"
>
{error.toString()}
</Paragraph>
</div>
{/* 错误堆栈 */}
{error.stack && (
<div>
<Text strong className="text-red-600"></Text>
<Paragraph
code
copyable
className="mt-2 bg-gray-50 p-3 rounded text-xs overflow-x-auto"
style={{ whiteSpace: 'pre-wrap' }}
>
{error.stack}
</Paragraph>
</div>
)}
{/* 组件堆栈 */}
{errorInfo?.componentStack && (
<div>
<Text strong className="text-red-600"></Text>
<Paragraph
code
copyable
className="mt-2 bg-gray-50 p-3 rounded text-xs overflow-x-auto"
style={{ whiteSpace: 'pre-wrap' }}
>
{errorInfo.componentStack}
</Paragraph>
</div>
)}
{/* 时间戳 */}
<div>
<Text type="secondary" className="text-xs">
{new Date().toLocaleString('zh-CN')}
</Text>
</div>
</div>
),
},
]}
/>
</div>
)}
{/* 生产环境错误ID提示 */}
{!isDevelopment && (
<div className="mt-6 text-center">
<Text type="secondary" className="text-xs">
ID: {Date.now().toString(36)}
</Text>
<br />
<Text type="secondary" className="text-xs">
ID
</Text>
</div>
)}
</div>
</div>
)
}
export default ModuleErrorFallback
/**
* 🎨 设计说明:
*
* 1. 用户体验:
* - ✅ 友好的错误提示(不显示技术术语)
* - ✅ 明确的操作指引(重试/返回首页)
* - ✅ 视觉上与整体风格一致Ant Design Result
*
* 2. 开发体验:
* - ✅ 开发环境显示详细错误(方便调试)
* - ✅ 错误信息可复制(方便分享给团队)
* - ✅ 显示完整堆栈(快速定位问题)
*
* 3. 生产环境:
* - ✅ 隐藏技术细节(安全性)
* - ✅ 提供错误ID方便追踪
* - ✅ 引导用户联系支持
*
* 4. 后续优化:
* - [ ] 添加"反馈问题"按钮
* - [ ] 集成错误报告系统
* - [ ] 记录用户操作路径
* - [ ] 自动重试机制(网络错误)
*/