Files
smart-crop-ui/docs/Crop-X-项目完整技术架构方案-Next.js-AppRouter版本.md

756 lines
41 KiB
Markdown
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.

# Crop-X 项目完整技术架构方案 (Next.js App Router 版本)
**Session Date:** 2025-10-16
**Facilitator:** Business Analyst Mary
**Project:** 智慧农业系统 crop-x 重构 (Next.js App Router 版本)
---
## 项目概述
基于现有的智慧农业生产管理系统,在根目录下创建全新的 `crop-x` 项目,采用 **Next.js 14 App Router** + React 19 + Zustand + shadcn + Tailwind CSS 技术栈实现现代化的路由系统、用户认证模块、API管理系统和完整的业务架构。
## 技术栈
- **前端框架**: Next.js 14 + React 19 + TypeScript
- **构建工具**: Next.js 内置构建系统
- **状态管理**: Zustand
- **UI框架**: shadcn/ui + Tailwind CSS
- **路由**: Next.js App Router
- **HTTP客户端**: Axios
- **图标**: Lucide React
- **提示组件**: Sonner
## Next.js App Router 目录结构
```
D:\code\repotest\smart-crop-ui\ # 原项目(保留不变)
├── 📂 crop-x/ # 🆕 全新的重构项目 (Next.js App Router)
│ ├── 📂 app/ # 🆕 Next.js App Router 页面组件 - 7大业务模块完整层级结构
│ │ ├── 📄 layout.tsx # 🆕 根布局组件
│ │ ├── 📄 page.tsx # 🆕 首页组件
│ │ ├── 📄 loading.tsx # 🆕 全局加载组件
│ │ ├── 📄 error.tsx # 🆕 全局错误组件
│ │ ├── 📄 not-found.tsx # 🆕 404页面组件
│ │ ├── 📂 (auth)/ # 🆕 认证路由组
│ │ │ ├── 📄 layout.tsx # 认证布局
│ │ │ ├── 📂 login/ # 登录页面
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 register/ # 注册页面
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 agricultural-machinery/ # 🚙 智能农机管理系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 农机系统布局
│ │ │ ├── 📄 page.tsx # 🆕 农机系统主页面
│ │ │ ├── 📄 loading.tsx # 🆕 农机系统加载组件
│ │ │ ├── 📄 error.tsx # 🆕 农机系统错误组件
│ │ │ ├── 📂 archive/ # B级农机档案
│ │ │ │ ├── 📄 page.tsx # 🆕 档案主页
│ │ │ │ ├── 📂 machinery-entry/ # C级农机档案录入与维护
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 classification-management/ # C级农机分类与标签管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 qr-code-management/ # C级农机二维码管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 driver-archive/ # B级驾驶员档案
│ │ │ │ ├── 📄 page.tsx # 🆕 驾驶员档案主页
│ │ │ │ ├── 📂 driver-info-management/ # C级驾驶员信息管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 driver-task-management/ # C级驾驶员任务管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 monitoring/ # B级设备实时监控与定位
│ │ │ │ ├── 📄 page.tsx # 🆕 监控主页
│ │ │ │ ├── 📂 real-time-location-tracking/ # C级实时位置追踪
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 work-status-monitoring/ # C级工作状态监控
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 operation-data-monitoring/ # C级作业数据监控
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 fault-diagnosis/ # B级远程诊断与故障预警
│ │ │ │ ├── 📄 page.tsx # 🆕 故障诊断主页
│ │ │ │ ├── 📂 fault-warning/ # C级故障诊断与预警
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 health-assessment/ # C级健康评估
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 parameter-monitoring/ # C级运行参数监测
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 precision-operation/ # B级精准作业管理与支持
│ │ │ │ ├── 📄 page.tsx # 🆕 精准作业主页
│ │ │ │ ├── 📂 operation-record/ # C级作业数据记录
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 route-planning/ # C级作业路线规划
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 plan-dispatch/ # C级作业方案下发
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 driving-cockpit/ # C级农机驾驶舱
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 data-analysis/ # B级数据管理与分析报告
│ │ │ │ ├── 📄 page.tsx # 🆕 数据分析主页
│ │ │ │ ├── 📂 operation-analysis/ # C级作业数据分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 historical-data-comparison/ # C级历史数据查询与对比
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 scheduling/ # B级农机管理与调度
│ │ │ │ ├── 📄 page.tsx # 🆕 调度管理主页
│ │ │ │ ├── 📂 task-assignment/ # C级任务分配
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 real-time-dispatch/ # C级实时调度监控
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 track-playback/ # C级农机作业轨迹回放
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 security/ # B级安全与安防
│ │ │ ├── 📄 page.tsx # 🆕 安全安防主页
│ │ │ └── 📂 geo-fence/ # C级电子围栏
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 land-information/ # 🌾 地块信息管理系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 地块系统布局
│ │ │ ├── 📄 page.tsx # 🆕 地块系统主页面
│ │ │ ├── 📂 field-management/ # B级地块档案管理
│ │ │ │ ├── 📄 page.tsx # 🆕 地块档案主页
│ │ │ │ ├── 📂 field-entry/ # C级地块信息录入
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 classification-management/ # C级地块分类管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 batch-operation/ # C级批量操作
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 map-management/ # B级地图管理
│ │ │ │ ├── 📄 page.tsx # 🆕 地图管理主页
│ │ │ │ ├── 📂 gis-data/ # C级GIS数据管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 digital-drawing/ # C级数字化绘制
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 spatial-query/ # C级空间查询
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 satellite-imagery/ # C级卫星影像管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 spatial-analysis/ # B级空间分析
│ │ │ │ ├── 📄 page.tsx # 🆕 空间分析主页
│ │ │ │ ├── 📂 soil-data/ # C级土壤数据分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 layered-sampling/ # C级分层采样分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 quality-evaluation/ # C级质量评价
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 environmental-monitoring/ # B级环境监测
│ │ │ │ ├── 📄 page.tsx # 🆕 环境监测主页
│ │ │ │ ├── 📂 weather-data/ # C级气象数据监测
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 sensor-data/ # C级环境传感器数据
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 monitoring-history/ # C级监测历史记录
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 suitability-evaluation/ # B级适宜性评价
│ │ │ │ ├── 📄 page.tsx # 🆕 适宜性评价主页
│ │ │ │ ├── 📂 comprehensive-evaluation/ # C级综合评价分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 batch-analysis/ # C级批量分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 crop-recommendation/ # C级作物推荐分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 weight-configuration/ # C级权重配置管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 comparative-analysis/ # B级对比分析
│ │ │ │ ├── 📄 page.tsx # 🆕 对比分析主页
│ │ │ │ ├── 📂 multi-dimensional-metrics/ # C级多维指标分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 chart-analysis/ # C级图表分析展示
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 report-generation/ # C级报告生成管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 risk-warning/ # B级风险预警
│ │ │ ├── 📄 page.tsx # 🆕 风险预警主页
│ │ │ ├── 📂 real-time-monitoring/ # C级实时监测预警
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 early-warning-push/ # C级预警信息推送
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 disposal-tracking/ # C级处置情况跟踪
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 farming-operation/ # 📋 农事操作管理系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 农事系统布局
│ │ │ ├── 📄 page.tsx # 🆕 农事系统主页面
│ │ │ ├── 📂 farm-planning/ # B级农事计划管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农事计划主页
│ │ │ │ ├── 📂 plan-formulation/ # C级计划制定
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 resource-allocation/ # C级资源分配管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 progress-tracking/ # C级进度跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 task-management/ # B级农事任务管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农事任务主页
│ │ │ │ ├── 📂 task-creation/ # C级任务创建管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 task-assignment/ # C级任务分配派发
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 task-status-monitoring/ # C级任务状态监控
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 task-history-statistics/ # C级任务历史统计
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 operation-execution/ # B级农事执行管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农事执行主页
│ │ │ │ ├── 📂 operation-type-management/ # C级操作类型管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 operation-recording/ # C级操作记录管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 operation-log-query/ # C级操作日志查询
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 farming-calendar/ # B级农事日历管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农事日历主页
│ │ │ │ ├── 📂 calendar-visualization/ # C级日历可视化视图
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 gantt-chart-management/ # C级甘特图管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 progress-visualization/ # C级进度可视化
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 operation-archive/ # B级农事档案管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农事档案主页
│ │ │ │ ├── 📂 archive-generation/ # C级档案归集生成
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 full-dimension-view/ # C级全维视图管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 traceability-tracking/ # C级追踪溯源管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 knowledge-base/ # B级知识库管理
│ │ │ │ ├── 📄 page.tsx # 🆕 知识库主页
│ │ │ │ ├── 📂 content-management/ # C级内容管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 classification-tagging/ # C级分类标签管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 intelligent-search/ # C级智能检索功能
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 performance-management/ # B级绩效管理
│ │ │ │ ├── 📄 page.tsx # 🆕 绩效管理主页
│ │ │ │ ├── 📂 personnel-management/ # C级人员管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 work-hour-recording/ # C级工时记录管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 statistical-reports/ # C级统计报表管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 scheduling-management/ # C级排班管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 issue-collaboration/ # B级问题协同管理
│ │ │ ├── 📄 page.tsx # 🆕 问题协同主页
│ │ │ ├── 📂 issue-reporting/ # C级问题上报管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 processing-assignment/ # C级处理分派管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 online-collaboration/ # C级在线协作功能
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 agricultural-asset/ # 📦 农业资产管理系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 资产系统布局
│ │ │ ├── 📄 page.tsx # 🆕 资产系统主页面
│ │ │ ├── 📂 basic-information/ # B级基础信息管理
│ │ │ │ ├── 📄 page.tsx # 🆕 基础信息主页
│ │ │ │ ├── 📂 asset-entry/ # C级资产信息录入
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 asset-classification/ # C级资产分类管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 asset-labeling/ # C级资产标签管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 procurement-management/ # B级采购管理
│ │ │ │ ├── 📄 page.tsx # 🆕 采购管理主页
│ │ │ │ ├── 📂 procurement-planning/ # C级采购计划制定
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 supplier-management/ # C级供应商管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 procurement-tracking/ # C级采购跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 inventory-management/ # B级库存管理
│ │ │ │ ├── 📄 page.tsx # 🆕 库存管理主页
│ │ │ │ ├── 📂 stock-monitoring/ # C级库存监控管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 stock-adjustment/ # C级库存调整管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 inventory-report/ # C级库存报表管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 material-requisition/ # B级物资领用管理
│ │ │ │ ├── 📄 page.tsx # 🆕 物资领用主页
│ │ │ │ ├── 📂 requisition-application/ # C级领用申请管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 approval-workflow/ # C级审批流程管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 requisition-tracking/ # C级领用跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 material-return/ # B级物资归还管理
│ │ │ │ ├── 📄 page.tsx # 🆕 物资归还主页
│ │ │ │ ├── 📂 return-application/ # C级归还申请管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 return-approval/ # C级归还审批管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 return-tracking/ # C级归还跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 agricultural-supplies/ # B级农资农具管理
│ │ │ │ ├── 📄 page.tsx # 🆕 农资农具主页
│ │ │ │ ├── 📂 tool-management/ # C级农具管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 material-management/ # C级农资管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 maintenance-tracking/ # C级维护跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 visualization-reports/ # B级可视化报表
│ │ │ ├── 📄 page.tsx # 🆕 可视化报表主页
│ │ │ ├── 📂 asset-statement/ # C级资产报表管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 inventory-statement/ # C级库存报表管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 cost-analysis/ # C级成本分析管理
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 ai-crop-model/ # 🤖 AI作物模型精准决策系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 AI模型系统布局
│ │ │ ├── 📄 page.tsx # 🆕 AI模型系统主页面
│ │ │ ├── 📂 data-perception-center/ # B级数据感知中心
│ │ │ │ ├── 📄 page.tsx # 🆕 数据感知主页
│ │ │ │ ├── 📂 real-time-data-collection/ # C级实时数据采集
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 historical-data-analysis/ # C级历史数据分析
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 multi-source-data-fusion/ # C级多源数据融合
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 model-integration-center/ # B级模型接入集成中心
│ │ │ │ ├── 📄 page.tsx # 🆕 模型集成主页
│ │ │ │ ├── 📂 model-access-management/ # C级模型接入管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 model-version-control/ # C级模型版本控制
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 api-service-integration/ # C级API服务集成
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 model-application-center/ # B级模型应用中心
│ │ │ │ ├── 📄 page.tsx # 🆕 模型应用主页
│ │ │ │ ├── 📂 prediction-analysis/ # C级预测分析管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 optimization-recommendation/ # C级优化建议管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 scenario-simulation/ # C级场景模拟管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 intelligent-decision-generation/ # B级智能决策生成
│ │ │ │ ├── 📄 page.tsx # 🆕 智能决策主页
│ │ │ │ ├── 📂 decision-engine/ # C级决策引擎管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 rule-configuration/ # C级规则配置管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 decision-optimization/ # C级决策优化管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 intelligent-decision-support/ # B级智能决策支持
│ │ │ │ ├── 📄 page.tsx # 🆕 智能决策支持主页
│ │ │ │ ├── 📂 decision-visualization/ # C级决策可视化
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 impact-assessment/ # C级影响评估管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 decision-tracking/ # C级决策跟踪管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 decision-application/ # B级决策应用
│ │ │ │ ├── 📄 page.tsx # 🆕 决策应用主页
│ │ │ │ ├── 📂 automatic-execution/ # C级自动执行管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 manual-adjustment/ # C级手动调整管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 feedback-collection/ # C级反馈收集管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 ai-knowledge-base/ # B级AI知识库
│ │ │ │ ├── 📄 page.tsx # 🆕 AI知识库主页
│ │ │ │ ├── 📂 model-documentation/ # C级模型文档管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 case-database/ # C级案例数据库管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 expert-system/ # C级专家系统管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 monitoring-center/ # B级监控中心
│ │ │ ├── 📄 page.tsx # 🆕 监控中心主页
│ │ │ ├── 📂 model-performance/ # C级模型性能监控
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 decision-quality/ # C级决策质量监控
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 system-health/ # C级系统健康监控
│ │ │ └── 📄 page.tsx
│ │ ├── 📂 water-fertilizer-control/ # 💧 水肥一体化控制系统页面
│ │ │ ├── 📄 layout.tsx # 🆕 水肥控制布局
│ │ │ ├── 📄 page.tsx # 🆕 水肥控制主页面
│ │ │ ├── 📂 irrigation-system-management/ # B级水肥机管理
│ │ │ │ ├── 📄 page.tsx # 🆕 水肥机管理主页
│ │ │ │ ├── 📂 device-registration/ # C级设备注册管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 status-monitoring/ # C级状态监控管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 maintenance-management/ # C级维护管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 smart-irrigation/ # B级智能灌溉
│ │ │ │ ├── 📄 page.tsx # 🆕 智能灌溉主页
│ │ │ │ ├── 📂 irrigation-planning/ # C级灌溉计划管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 automated-control/ # C级自动控制管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 irrigation-optimization/ # C级灌溉优化管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 fertilizer-formula-management/ # B级施肥配方管理
│ │ │ │ ├── 📄 page.tsx # 🆕 施肥配方主页
│ │ │ │ ├── 📂 formula-configuration/ # C级配方配置管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 crop-specific-formulas/ # C级作物专用配方
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 formula-optimization/ # C级配方优化管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 integrated-control/ # B级水肥一体化控制
│ │ │ │ ├── 📄 page.tsx # 🆕 水肥一体化主页
│ │ │ │ ├── 📂 synchronized-control/ # C级同步控制管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ ├── 📂 precision-application/ # C级精准施用管理
│ │ │ │ │ └── 📄 page.tsx
│ │ │ │ └── 📂 real-time-adjustment/ # C级实时调整管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 real-time-monitoring/ # B级实时监测与预警
│ │ │ ├── 📄 page.tsx # 🆕 实时监测主页
│ │ │ ├── 📂 parameter-display/ # C级参数显示管理
│ │ │ │ └── 📄 page.tsx
│ │ │ ├── 📂 warning-system/ # C级预警系统管理
│ │ │ │ └── 📄 page.tsx
│ │ │ └── 📂 historical-analysis/ # C级历史分析管理
│ │ │ └── 📄 page.tsx
│ │ └── 📂 central-config/ # ⚙️ 中心配置管理系统页面
│ │ ├── 📄 layout.tsx # 🆕 配置系统布局
│ │ ├── 📄 page.tsx # 🆕 配置系统主页面
│ │ ├── 📂 tenant/ # B级租户管理
│ │ │ ├── 📄 page.tsx # 🆕 租户管理主页
│ │ │ ├── 📂 enterprise-audit/ # C级企业审核
│ │ │ │ └── 📄 page.tsx # 路径: /config/tenant/enterprise-audit
│ │ │ ├── 📂 audit-history/ # C级审核历史
│ │ │ │ └── 📄 page.tsx # 路径: /config/tenant/audit-history
│ │ │ ├── 📂 enterprise-info/ # C级企业信息
│ │ │ │ └── 📄 page.tsx # 路径: /config/tenant/enterprise-info
│ │ │ └── 📂 user-management/ # C级用户管理
│ │ │ └── 📄 page.tsx # 路径: /config/tenant/user-management
│ │ ├── 📂 user/ # B级用户管理
│ │ │ ├── 📄 page.tsx # 🆕 用户管理主页
│ │ │ ├── 📂 employee/ # C级员工管理
│ │ │ │ └── 📄 page.tsx # 路径: /config/user/employee
│ │ │ ├── 📂 role/ # C级角色管理
│ │ │ │ └── 📄 page.tsx # 路径: /config/user/role
│ │ │ ├── 📂 menu/ # C级菜单管理
│ │ │ │ └── 📄 page.tsx # 路径: /config/user/menu
│ │ │ └── 📂 permission/ # C级权限配置管理
│ │ │ └── 📄 page.tsx # 路径: /config/user/permission
│ │ ├── 📂 system/ # B级系统参数
│ │ │ ├── 📄 page.tsx # 🆕 系统参数主页
│ │ │ ├── 📂 settings/ # C级系统设置
│ │ │ │ └── 📄 page.tsx # 路径: /config/system/settings
│ │ │ ├── 📂 category/ # C级分类字典
│ │ │ │ └── 📄 page.tsx # 路径: /config/system/category
│ │ │ └── 📂 dictionary/ # C级数据字典
│ │ │ └── 📄 page.tsx # 路径: /config/system/dictionary
│ │ ├── 📂 monitor/ # B级系统监控
│ │ │ ├── 📄 page.tsx # 🆕 系统监控主页
│ │ │ ├── 📂 login-log/ # C级登录日志
│ │ │ │ └── 📄 page.tsx # 路径: /config/monitor/login-log
│ │ │ ├── 📂 operation-log/ # C级操作日志
│ │ │ │ └── 📄 page.tsx # 路径: /config/monitor/operation-log
│ │ │ ├── 📂 performance/ # C级性能监控
│ │ │ │ └── 📄 page.tsx # 路径: /config/monitor/performance
│ │ │ └── 📂 network-log/ # C级网络日志
│ │ │ └── 📄 page.tsx # 路径: /config/monitor/network-log
│ │ └── 📂 message/ # B级消息中心
│ │ ├── 📄 page.tsx # 🆕 消息中心主页
│ │ ├── 📂 send/ # C级消息发送
│ │ │ └── 📄 page.tsx # 路径: /config/message/send
│ │ ├── 📂 template/ # C级消息模版
│ │ │ └── 📄 page.tsx # 路径: /config/message/template
│ │ └── 📂 log/ # C级消息日志
│ │ └── 📄 page.tsx # 路径: /config/message/log
│ ├── 📂 components/ # 组件库
│ │ ├── 📂 ui/ # 基础UI组件(shadcn)
│ │ ├── 📂 layout/ # 布局组件
│ │ │ ├── 📄 Header.tsx # 顶部导航
│ │ │ ├── 📄 Sidebar.tsx # 侧边栏
│ │ │ └── 📄 MainLayout.tsx # 主布局
│ │ ├── 📂 common/ # 通用业务组件
│ │ └── 📂 business/ # 业务组件
│ ├── 📂 lib/ # 🆕 工具库 (Next.js 标准)
│ │ ├── 📄 utils.ts # 工具函数
│ │ ├── 📄 validations.ts # 表单验证
│ │ ├── 📄 constants.ts # 常量定义
│ │ └── 📄 helpers.ts # 辅助函数
│ ├── 📂 hooks/ # 自定义Hooks
│ │ ├── 📄 useAuth.ts # 认证Hook
│ │ ├── 📄 usePermission.ts # 权限Hook
│ │ └── 📄 useRouterParams.ts # 路由参数Hook
│ ├── 📂 store/ # Zustand状态管理
│ │ ├── 📄 authStore.ts # 认证状态管理
│ │ ├── 📄 globalStore.ts # 全局状态管理
│ │ └── 📂 [modules]/ # 各业务模块状态管理
│ ├── 📂 types/ # TypeScript类型
│ │ ├── 📄 auth.ts # 认证类型
│ │ ├── 📄 navigation.ts # 导航类型
│ │ └── 📄 business.ts # 业务类型
│ ├── 📂 styles/ # 样式文件
│ │ ├── 📄 globals.css # 全局样式
│ │ └── 📄 components.css # 组件样式
│ ├── 📂 public/ # 🆕 静态资源目录
│ │ ├── 📄 favicon.ico # 网站图标
│ │ ├── 📄 logo.png # 应用Logo
│ │ ├── 📄 manifest.json # PWA配置文件
│ │ └── 📂 images/ # 图片资源
│ ├── 📂 config/ # 🆕 特性优先配置系统
│ │ ├── 📂 types/ # 配置类型定义
│ │ ├── 📂 environments/ # 环境配置
│ │ ├── 📂 features/ # 特性配置
│ │ └── 📄 config-manager.ts # 配置管理器
│ ├── 📂 apis/ # 🆕 API管理系统
│ │ ├── 📄 index.ts # API统一入口
│ │ ├── 📄 interceptor.ts # 请求拦截器
│ │ └── 📂 subModules/ # 7大业务模块API
│ ├── 📄 package.json # 项目配置
│ ├── 📄 next.config.js # Next.js 配置
│ ├── 📄 tailwind.config.js # Tailwind 配置
│ ├── 📄 tsconfig.json # TypeScript 配置
│ ├── 📄 .eslintrc.js # ESLint 配置
│ ├── 📄 .prettierrc # Prettier 配置
│ └── 📄 README.md # 项目说明
```
## Next.js App Router 核心特性
### 1. 路由系统变更
**原 React Router 系统****Next.js App Router 系统**
```typescript
// 原路由方式 (React Router)
/agricultural-machinery/archive/machinery-entry
// 新路由方式 (Next.js App Router)
/agricultural-machinery/archive/machinery-entry
```
### 2. 文件命名规范
| React Router | Next.js App Router | 说明 |
|-------------|-------------------|------|
| `index.jsx` | `page.tsx` | 页面组件 |
| - | `layout.tsx` | 布局组件 |
| - | `loading.tsx` | 加载组件 |
| - | `error.tsx` | 错误组件 |
| - | `not-found.tsx` | 404页面 |
| - | `route.ts` | API路由 |
### 3. 布局系统
Next.js App Router 提供了嵌套布局系统:
```typescript
// app/layout.tsx - 根布局
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="zh-CN">
<body>
<Providers>{children}</Providers>
</body>
</html>
);
}
// app/agricultural-machinery/layout.tsx - 农机系统布局
export default function MachineryLayout({ children }: { children: React.ReactNode }) {
return (
<div className="machinery-layout">
<Sidebar />
<div className="main-content">
{children}
</div>
</div>
);
}
```
### 4. 路由组和权限控制
使用路由组 `(auth)` 实现权限控制:
```typescript
// app/(auth)/layout.tsx - 认证布局
export default function AuthLayout({ children }: { children: React.ReactNode }) {
return (
<div className="auth-layout">
{children}
</div>
);
}
// app/(auth)/login/page.tsx - 登录页面
export default function LoginPage() {
return <LoginForm />;
}
```
### 5. 数据获取方式
```typescript
// Server Components - 服务器端数据获取
async function getMachineryData() {
const res = await fetch('http://localhost:8080/api/machinery', {
cache: 'no-store'
});
return res.json();
}
export default async function MachineryPage() {
const data = await getMachineryData();
return <MachineryList data={data} />;
}
// Client Components - 客户端数据获取
'use client';
import { useState, useEffect } from 'react';
export default function MachineryPage() {
const [data, setData] = useState([]);
useEffect(() => {
fetch('/api/machinery')
.then(res => res.json())
.then(setData);
}, []);
return <MachineryList data={data} />;
}
```
### 6. API路由
```typescript
// app/api/machinery/route.ts
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
// 获取农机列表
return NextResponse.json({ machinery: [] });
}
export async function POST(request: NextRequest) {
// 创建农机
const body = await request.json();
return NextResponse.json({ success: true });
}
```
### 7. 错误处理
```typescript
// app/error.tsx - 全局错误处理
'use client';
export default function Error({ error, reset }: { error: Error; reset: () => void }) {
return (
<div>
<h2>出现了错误!</h2>
<button onClick={() => reset()}>重试</button>
</div>
);
}
// app/agricultural-machinery/error.tsx - 农机系统错误处理
export default function MachineryError({ error }: { error: Error }) {
return (
<div className="machinery-error">
<h3>农机系统错误</h3>
<p>{error.message}</p>
</div>
);
}
```
### 8. 加载状态
```typescript
// app/agricultural-machinery/loading.tsx
export default function MachineryLoading() {
return (
<div className="machinery-loading">
<div className="spinner"></div>
<p>正在加载农机数据...</p>
</div>
);
}
```
## Next.js App Router 优势
### 1. **性能优化**
- 自动代码分割
- 服务器组件渲染
- 客户端组件按需加载
- 流式渲染支持
### 2. **SEO 友好**
- 服务器端渲染 (SSR)
- 静态站点生成 (SSG)
- 增量静态再生 (ISR)
### 3. **开发体验**
- 文件系统路由
- 内置类型安全
- 热模块替换
- 快速刷新
### 4. **布局系统**
- 嵌套布局
- 共享布局
- 路由组
- 并行路由
## 迁移指南
### 从 React Router 到 Next.js App Router
1. **目录结构迁移**
```
pages/ → app/
index.jsx → page.tsx
```
2. **路由配置移除**
```typescript
// 移除 React Router 配置
// 删除 router/index.js
// 删除路由守卫组件
```
3. **布局组件重构**
```typescript
// 原 Layout.jsx
export default function Layout({ children }) {
return <div>{children}</div>;
}
// 新 layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
);
}
```
4. **数据获取重构**
```typescript
// 原 useEffect 方式
useEffect(() => {
fetchData().then(setData);
}, []);
// 新 async/await 方式
const data = await fetchData();
```
5. **导航方式变更**
```typescript
// 原 useNavigate
const navigate = useNavigate();
navigate('/machinery');
// 新 useRouter
const router = useRouter();
router.push('/machinery');
```
---
*本文档基于 Mary 的头脑风暴分析结果生成,为 crop-x 项目提供 Next.js App Router 版本的完整技术架构方案。*