From 73c41b76abd35fc97ec1cd2521b8b1725aeafdcd Mon Sep 17 00:00:00 2001 From: peng Date: Mon, 3 Nov 2025 11:30:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20-=20=E8=B7=AF=E7=94=B1=E9=94=99=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crop-x/src/app/(app)/layout.tsx | 1345 +--------------- crop-x/src/app/layout.tsx | 1356 ++++++++++++++++- crop-x/src/app/page.tsx | 2 +- crop-x/src/components/auth/AuthContext.tsx | 62 +- crop-x/src/components/layouts/Navbar.tsx | 37 +- .../layouts/components/MessageBell.tsx | 2 - 6 files changed, 1424 insertions(+), 1380 deletions(-) diff --git a/crop-x/src/app/(app)/layout.tsx b/crop-x/src/app/(app)/layout.tsx index f1dba1c..39fba96 100644 --- a/crop-x/src/app/(app)/layout.tsx +++ b/crop-x/src/app/(app)/layout.tsx @@ -1,1349 +1,12 @@ 'use client'; -import {Navbar1} from "@/components/layouts/Navbar" -import {SideBarOld} from '@/components/layouts/SideBar/SideBarOld' -import '@/styles/globals.css' -import { ThemeProvider } from 'next-themes' -import { usePathname } from 'next/navigation' -import { Toaster } from '@/components/ui/sonner' -import { Building2, Users, Cog, Activity, Mail, UserCircle, Database, Map, BarChart3, Cloud, TrendingUp, GitCompare, AlertTriangle, FileText, MapPin, Settings, User, Package, Navigation, Zap, Target, PieChart, Calendar, Shield, Tractor, Clipboard, ClipboardCheck, Brain, Droplets, Book, ShoppingCart } from 'lucide-react' +// (app) layout - 空的布局,只作为路由分组使用 +// 所有的导航和布局逻辑都在根 layout 中处理 -const navbarData = { - logo: { - url: "/", - src: "https://deifkwefumgah.cloudfront.net/shadcnblocks/block/logos/shadcnblockscom-icon.svg", - alt: "Crop-X Logo", - title: "智慧农业生产管理系统", - }, - menu: [ - { - title: "智能农机管理系统", - url: "/agricultural-machinery", - description: "农机档案、实时监控、精准作业管理", - icon: , - }, - { - title: "地块信息管理系统", - url: "/land-information", - description: "地块档案、地图管理、空间分析", - icon: , - }, - { - title: "农事操作管理系统", - url: "/farming-operation", - description: "农事计划、任务管理、操作执行", - icon: , - }, - { - title: "农业资产管理系统", - url: "/agricultural-asset", - description: "基础信息、采购管理、库存管理", - icon: , - }, - { - title: "AI作物模型精准决策系统", - url: "/ai-crop-model", - description: "数据感知、模型应用、智能决策", - icon: , - }, - { - title: "水肥一体化控制系统", - url: "/water-fertilizer-control", - description: "水肥机管理、智能灌溉、配方管理", - icon: , - }, - { - title: "中心配置管理系统", - url: "/central-config", - description: "租户管理、用户管理、系统监控", - icon: , - }, - { - title: "API 测试示例", - url: "/api-example", - description: "测试和展示 OpenAPI 客户端调用", - icon: , - }, - ], - auth: { - login: { title: "登录", url: "/login" }, - signup: { title: "注册", url: "/register" }, - }, -}; - -const centralConfigData = { - navMain: [ - { - title: '个人中心', - url: "/central-config/personal-center", - icon: , - items: [ - { - title: "个人信息", - url: "/central-config/personal-center/personal-info", - isActive: false - },{ - title: "账户安全", - url: "/central-config/personal-center/account-security", - isActive: false - }, - ] - }, - { - title: "租户管理", - url: "/central-config/tenant", - icon: , - items: [ - { - title: "企业管理", - url: "/central-config/tenant/enterprise-management", - isActive: false - }, - { - title: "企业审核", - url: "/central-config/tenant/enterprise-audit", - isActive: false - }, - { - title: "审核历史", - url: "/central-config/tenant/audit-history", - isActive: false - }, - { - title: "企业信息", - url: "/central-config/tenant/enterprise-info", - isActive: false - }, - { - title: "用户管理", - url: "/central-config/tenant/user-management", - isActive: false - } - ] - }, - { - title: "用户管理", - url: "/central-config/user", - icon: , - items: [ - { - title: "员工管理", - url: "/central-config/user/employee", - isActive: false - }, - { - title: "角色管理", - url: "/central-config/user/role", - isActive: false - }, - { - title: "菜单管理", - url: "/central-config/user/menu", - isActive: false - }, - { - title: "权限配置管理", - url: "/central-config/user/permission", - isActive: false - } - ] - }, - { - title: "系统参数", - url: "/central-config/system", - icon: , - items: [ - { - title: "系统设置", - url: "/central-config/system/settings", - isActive: false - }, - { - title: "分类字典", - url: "/central-config/system/category", - isActive: false - }, - { - title: "数据字典", - url: "/central-config/system/dictionary", - isActive: false - } - ] - }, - { - title: "系统监控", - url: "/central-config/monitor", - icon: , - items: [ - { - title: "登录日志", - url: "/central-config/monitor/login-log", - isActive: false - }, - { - title: "操作日志", - url: "/central-config/monitor/operation-log", - isActive: false - }, - { - title: "性能监控", - url: "/central-config/monitor/performance", - isActive: false - }, - { - title: "网络日志", - url: "/central-config/monitor/network-log", - isActive: false - } - ] - }, - { - title: "消息中心", - url: "/central-config/message", - icon: , - items: [ - { - title: "消息发送", - url: "/central-config/message/send", - isActive: false - }, - { - title: "消息模版", - url: "/central-config/message/template", - isActive: false - }, - { - title: "消息日志", - url: "/central-config/message/log", - isActive: false - } - ] - } - ] -} -// 地块信息管理 -const fieldMessageManagement = { - navMain: [ - { - title: "地块档案管理", - url: "/land-information/archive", - icon: , - items: [ - { - title: "地块档案管理", - url: "/land-information/archive/manage", - isActive: false - }, - { - title: "地块分类与标签管理", - url: "/land-information/archive/classification", - isActive: false - }, - { - title: "统计分析", - url: "/land-information/archive/statistics", - isActive: false - } - ] - }, - { - title: "地块数字化与地图管理", - url: "/land-information/map", - icon: , - items: [ - { - title: "GIS地图管理", - url: "/land-information/map/gis", - isActive: false - }, - { - title: "数字化绘制与编辑", - url: "/land-information/map/draw", - isActive: false - }, - { - title: "空间数据管理", - url: "/land-information/map/spatial-query", - isActive: false - }, - { - title: "地块影像", - url: "/land-information/map/satellite", - isActive: false - } - ] - }, - { - title: "空间分析与决策支持", - url: "/land-information/analysis", - icon: , - items: [ - { - title: "土壤基础数据", - url: "/land-information/analysis/soil-data", - isActive: false - }, - { - title: "分层采样分析", - url: "/land-information/analysis/layer-sampling", - isActive: false - }, - { - title: "土壤质量评价", - url: "/land-information/analysis/soil-quality", - isActive: false - } - ] - }, - { - title: "地块环境监测", - url: "/land-information/monitoring", - icon: , - items: [ - { - title: "气象监测", - url: "/land-information/monitoring/weather", - isActive: false - }, - { - title: "环境监测", - url: "/land-information/monitoring/environment", - isActive: false - } - ] - }, - { - title: "地块适宜性评价", - url: "/land-information/suitability", - icon: , - items: [ - { - title: "多因子综合评价", - url: "/land-information/suitability/multiFactor", - isActive: false - }, - { - title: "自动化空间分析", - url: "/land-information/suitability/auto", - isActive: false - }, - { - title: "作物适配推荐", - url: "/land-information/suitability/recommend", - isActive: false - } - ] - }, - { - title: "地块对比分析", - url: "/land-information/comparison", - icon: , - items: [ - { - title: "多维度指标看板", - url: "/land-information/comparison/indicator", - isActive: false - }, - { - title: "可视化图表分析", - url: "/land-information/comparison/chart", - isActive: false - }, - { - title: "对比报告生成", - url: "/land-information/comparison/report", - isActive: false - } - ] - }, - { - title: "地块风险预警", - url: "/land-information/risk", - icon: , - items: [ - { - title: "实时风险监测", - url: "/land-information/risk/monitoring", - isActive: false - }, - { - title: "预警推送管理", - url: "/land-information/risk/push", - isActive: false - }, - { - title: "预警处置跟踪", - url: "/land-information/risk/disposal", - isActive: false - } - ] - } - ] -} - -// 农机管理 -const machineryManagement = { - navMain: [ - { - title: "农机档案", - url: "/agricultural-machinery/archive", - icon: , - items: [ - { - title: "农机录入维护", - url: "/agricultural-machinery/archive/entry", - isActive: false - }, - { - title: "农机分类管理", - url: "/agricultural-machinery/archive/classification", - isActive: false - }, - { - title: "农机二维码管理", - url: "/agricultural-machinery/archive/qrcode", - isActive: false - } - ] - }, - { - title: "驾驶员档案", - url: "/agricultural-machinery/driver-archive", - icon: , - items: [ - { - title: "驾驶员信息管理", - url: "/agricultural-machinery/driver-archive/info", - isActive: false - }, - { - title: "驾驶员任务管理", - url: "/agricultural-machinery/driver-archive/task", - isActive: false - } - ] - }, - { - title: "农机负载管理", - url: "/agricultural-machinery/load-management", - icon: , - items: [ - { - title: "负载类型管理", - url: "/agricultural-machinery/load-management/type", - isActive: false - }, - { - title: "负载参数管理", - url: "/agricultural-machinery/load-management/parameter", - isActive: false - }, - { - title: "负载设备库", - url: "/agricultural-machinery/load-management/library", - isActive: false - }, - { - title: "负载设备管理", - url: "/agricultural-machinery/load-management/device", - isActive: false - } - ] - }, - { - title: "设备实时监控与定位", - url: "/agricultural-machinery/monitoring", - icon: , - items: [ - { - title: "实时定位监控", - url: "/agricultural-machinery/monitoring/location", - isActive: false - }, - { - title: "作业状态监控", - url: "/agricultural-machinery/monitoring/status", - isActive: false - }, - { - title: "作业数据监控", - url: "/agricultural-machinery/monitoring/operation", - isActive: false - } - ] - }, - { - title: "远程诊断与故障预警", - url: "/agricultural-machinery/fault-diagnosis", - icon: , - items: [ - { - title: "故障预警规则", - url: "/agricultural-machinery/fault-diagnosis/alert-rules", - isActive: false - }, - { - title: "故障预警管理", - url: "/agricultural-machinery/fault-diagnosis/warning", - isActive: false - }, - { - title: "设备健康管理", - url: "/agricultural-machinery/fault-diagnosis/health", - isActive: false - }, - { - title: "设备参数监控", - url: "/agricultural-machinery/fault-diagnosis/parameter", - isActive: false - } - ] - }, - { - title: "精准作业管理与支持", - url: "/agricultural-machinery/precision-operation", - icon: , - items: [ - { - title: "作业记录管理", - url: "/agricultural-machinery/precision-operation/record", - isActive: false - }, - { - title: "路径规划管理", - url: "/agricultural-machinery/precision-operation/route", - isActive: false - }, - { - title: "作业计划调度", - url: "/agricultural-machinery/precision-operation/dispatch", - isActive: false - }, - { - title: "作业驾驶舱", - url: "/agricultural-machinery/precision-operation/cockpit", - isActive: false - } - ] - }, - { - title: "数据管理与分析报告", - url: "/agricultural-machinery/data-analysis", - icon: , - items: [ - { - title: "作业数据分析", - url: "/agricultural-machinery/data-analysis/analysis", - isActive: false - }, - { - title: "历史数据对比", - url: "/agricultural-machinery/data-analysis/comparison", - isActive: false - } - ] - }, - { - title: "农机管理与调度", - url: "/agricultural-machinery/scheduling", - icon: , - items: [ - { - title: "任务分配管理", - url: "/agricultural-machinery/scheduling/assignment", - isActive: false - }, - { - title: "实时调度管理", - url: "/agricultural-machinery/scheduling/dispatch", - isActive: false - }, - { - title: "轨迹回放管理", - url: "/agricultural-machinery/scheduling/playback", - isActive: false - } - ] - }, - { - title: "安全与安防", - url: "/agricultural-machinery/security", - icon: , - items: [ - { - title: "地理围栏管理", - url: "/agricultural-machinery/security/fence", - isActive: false - } - ] - } - ] -} - -// 农事操作管理系统 -const farmingOperation = { - navMain: [ - { - title: "农事计划", - url: "/farming-operation/planning", - icon: , - items: [ - { - title: "农事计划创建", - url: "/farming-operation/planning/creation", - isActive: false - }, - { - title: "农事计划分配", - url: "/farming-operation/planning/allocation", - isActive: false - }, - { - title: "农事计划进度", - url: "/farming-operation/planning/progress", - isActive: false - } - ] - }, - { - title: "农事任务", - url: "/farming-operation/task", - icon: , - items: [ - { - title: "任务管理", - url: "/farming-operation/task/management", - isActive: false - }, - { - title: "任务分配", - url: "/farming-operation/task/assignment", - isActive: false - }, - { - title: "任务监控", - url: "/farming-operation/task/monitoring", - isActive: false - }, - { - title: "任务统计", - url: "/farming-operation/task/statistics", - isActive: false - } - ] - }, - { - title: "农事执行", - url: "/farming-operation/execution", - icon: , - items: [ - { - title: "执行类型", - url: "/farming-operation/execution/type", - isActive: false - }, - { - title: "执行记录", - url: "/farming-operation/execution/record", - isActive: false - }, - { - title: "执行日志", - url: "/farming-operation/execution/log", - isActive: false - } - ] - }, - { - title: "农事日历", - url: "/farming-operation/calendar", - icon: , - items: [ - { - title: "日历视图", - url: "/farming-operation/calendar/view", - isActive: false - }, - { - title: "甘特图", - url: "/farming-operation/calendar/gantt", - isActive: false - }, - { - title: "进度跟踪", - url: "/farming-operation/calendar/progress", - isActive: false - } - ] - }, - { - title: "农事档案", - url: "/farming-operation/archive", - icon: , - items: [ - { - title: "档案聚合", - url: "/farming-operation/archive/aggregation", - isActive: false - }, - { - title: "档案查看", - url: "/farming-operation/archive/view", - isActive: false - }, - { - title: "档案追溯", - url: "/farming-operation/archive/trace", - isActive: false - } - ] - }, - { - title: "农事知识库", - url: "/farming-operation/knowledge", - icon: , - items: [ - { - title: "知识管理", - url: "/farming-operation/knowledge/management", - isActive: false - }, - { - title: "知识分类", - url: "/farming-operation/knowledge/category", - isActive: false - }, - { - title: "知识搜索", - url: "/farming-operation/knowledge/search", - isActive: false - } - ] - }, - { - title: "绩效管理", - url: "/farming-operation/performance", - icon: , - items: [ - { - title: "员工绩效", - url: "/farming-operation/performance/staff", - isActive: false - }, - { - title: "工时统计", - url: "/farming-operation/performance/hours", - isActive: false - }, - { - title: "绩效统计", - url: "/farming-operation/performance/statistics", - isActive: false - }, - { - title: "绩效调度", - url: "/farming-operation/performance/schedule", - isActive: false - } - ] - }, - { - title: "农事问题协同", - url: "/farming-operation/issue", - icon: , - items: [ - { - title: "问题上报", - url: "/farming-operation/issue/report", - isActive: false - }, - { - title: "问题分配", - url: "/farming-operation/issue/assign", - isActive: false - }, - { - title: "问题协同", - url: "/farming-operation/issue/collaborate", - isActive: false - } - ] - } - ] -} - -// 农业资产管理系统 -const agricultureAsset = { - navMain: [ - { - title: "基础信息管理", - url: "/agricultural-asset/basic", - icon: , - items: [ - { - title: "物料信息", - url: "/agricultural-asset/basic/materials", - isActive: false - }, - { - title: "农具信息", - url: "/agricultural-asset/basic/tools", - isActive: false - }, - { - title: "供应商信息", - url: "/agricultural-asset/basic/suppliers", - isActive: false - }, - { - title: "客户信息", - url: "/agricultural-asset/basic/customers", - isActive: false - } - ] - }, - { - title: "采购管理", - url: "/agricultural-asset/purchase", - icon: , - items: [ - { - title: "采购计划", - url: "/agricultural-asset/purchase/plan", - isActive: false - }, - { - title: "采购订单", - url: "/agricultural-asset/purchase/order", - isActive: false - } - ] - }, - { - title: "库存管理", - url: "/agricultural-asset/inventory", - icon: , - items: [ - { - title: "入库管理", - url: "/agricultural-asset/inventory/in", - isActive: false - }, - { - title: "出库管理", - url: "/agricultural-asset/inventory/out", - isActive: false - }, - { - title: "库存盘点", - url: "/agricultural-asset/inventory/check", - isActive: false - }, - { - title: "库存预警", - url: "/agricultural-asset/inventory/warning", - isActive: false - }, - { - title: "库存明细", - url: "/agricultural-asset/inventory/detail", - isActive: false - }, - { - title: "库位管理", - url: "/agricultural-asset/inventory/location", - isActive: false - }, - { - title: "补货建议", - url: "/agricultural-asset/inventory/suggest", - isActive: false - } - ] - }, - { - title: "物资领用", - url: "/agricultural-asset/requisition", - icon: , - items: [ - { - title: "领用申请", - url: "/agricultural-asset/requisition/apply", - isActive: false - }, - { - title: "领用审批", - url: "/agricultural-asset/requisition/approval", - isActive: false - }, - { - title: "领用发放", - url: "/agricultural-asset/requisition/checkout", - isActive: false - }, - { - title: "领用记录", - url: "/agricultural-asset/requisition/record", - isActive: false - } - ] - }, - { - title: "物资归还", - url: "/agricultural-asset/return", - icon: , - items: [ - { - title: "归还登记", - url: "/agricultural-asset/return/register", - isActive: false - }, - { - title: "归还处理", - url: "/agricultural-asset/return/process", - isActive: false - }, - { - title: "归还结算", - url: "/agricultural-asset/return/settlement", - isActive: false - }, - { - title: "归还历史", - url: "/agricultural-asset/return/history", - isActive: false - } - ] - }, - { - title: "农资农具管理", - url: "/agricultural-asset/equipment", - icon: , - items: [ - { - title: "设备档案", - url: "/agricultural-asset/equipment/archive", - isActive: false - }, - { - title: "设备调度", - url: "/agricultural-asset/equipment/dispatch", - isActive: false - }, - { - title: "设备维护", - url: "/agricultural-asset/equipment/maintenance", - isActive: false - }, - { - title: "设备折旧", - url: "/agricultural-asset/equipment/depreciation", - isActive: false - }, - { - title: "设备处置", - url: "/agricultural-asset/equipment/disposal", - isActive: false - } - ] - }, - { - title: "可视化报表", - url: "/agricultural-asset/report", - icon: , - items: [ - { - title: "总览报表", - url: "/agricultural-asset/report/overview", - isActive: false - }, - { - title: "库存报表", - url: "/agricultural-asset/report/inventory", - isActive: false - }, - { - title: "消耗报表", - url: "/agricultural-asset/report/consumption", - isActive: false - } - ] - } - ] -} - -// AI作物模型精准决策系统 -const aiCropModel = { - navMain: [ - { - title: "全域数据感知中心", - url: "/ai-crop-model/data-sense-center", - icon: , - items: [ - { - title: "多源数据接入", - url: "/ai-crop-model/data-sense-center/external", - isActive: false - }, - { - title: "物联设备数据接入", - url: "/ai-crop-model/data-sense-center/iot", - isActive: false - }, - { - title: "设备类型管理", - url: "/ai-crop-model/data-sense-center/device-type", - isActive: false - }, - { - title: "设备参数管理", - url: "/ai-crop-model/data-sense-center/device-parameter", - isActive: false - } - ] - }, - { - title: "模型接入集成", - url: "/ai-crop-model/model-integration", - icon: , - items: [ - { - title: "模型接入", - url: "/ai-crop-model/model-integration/access", - isActive: false - }, - { - title: "模型管理", - url: "/ai-crop-model/model-integration/management", - isActive: false - } - ] - }, - { - title: "模型应用中心", - url: "/ai-crop-model/model-application", - icon: , - items: [ - { - title: "生成调度", - url: "/ai-crop-model/model-application/generation", - isActive: false - }, - { - title: "应用调度", - url: "/ai-crop-model/model-application/scheduling", - isActive: false - } - ] - }, - { - title: "智能决策生成", - url: "/ai-crop-model/decision", - icon: , - items: [ - { - title: "业务融合", - url: "/ai-crop-model/decision/fusion", - isActive: false - }, - { - title: "决策模拟", - url: "/ai-crop-model/decision/simulation", - isActive: false - }, - { - title: "决策日志", - url: "/ai-crop-model/decision/log", - isActive: false - } - ] - }, - { - title: "智能决策支持", - url: "/ai-crop-model/support", - icon: , - items: [ - { - title: "决策仪表盘", - url: "/ai-crop-model/support/dashboard", - isActive: false - }, - { - title: "决策详情", - url: "/ai-crop-model/support/detail", - isActive: false - } - ] - }, - { - title: "决策应用", - url: "/ai-crop-model/application", - icon: , - items: [ - { - title: "设备控制", - url: "/ai-crop-model/application/device-control", - isActive: false - }, - { - title: "外部系统", - url: "/ai-crop-model/application/external-system", - isActive: false - } - ] - }, - { - title: "AI知识库", - url: "/ai-crop-model/knowledge", - icon: , - items: [ - { - title: "知识生成", - url: "/ai-crop-model/knowledge/generation", - isActive: false - } - ] - }, - { - title: "监控中心", - url: "/ai-crop-model/monitoring", - icon: , - items: [ - { - title: "模型监控", - url: "/ai-crop-model/monitoring/model", - isActive: false - }, - { - title: "审计监控", - url: "/ai-crop-model/monitoring/audit", - isActive: false - }, - { - title: "预警监控", - url: "/ai-crop-model/monitoring/alert", - isActive: false - } - ] - } - ] -} - -// 水肥一体化控制系统 -const waterFertilizerControl = { - navMain: [ - { - title: "水肥机管理", - url: "/water-fertilizer-control/wf-management", - icon: , - items: [ - { - title: "设备管理", - url: "/water-fertilizer-control/wf-management/device", - isActive: false - }, - { - title: "组件管理", - url: "/water-fertilizer-control/wf-management/component", - isActive: false - }, - { - title: "参数配置", - url: "/water-fertilizer-control/wf-management/parameter", - isActive: false - }, - { - title: "映射关系", - url: "/water-fertilizer-control/wf-management/mapping", - isActive: false - } - ] - }, - { - title: "智能灌溉", - url: "/water-fertilizer-control/smart", - icon: , - items: [ - { - title: "模型配置", - url: "/water-fertilizer-control/smart/model-config", - isActive: false - }, - { - title: "自动灌溉", - url: "/water-fertilizer-control/smart/auto", - isActive: false - }, - { - title: "手动灌溉", - url: "/water-fertilizer-control/smart/manual", - isActive: false - }, - { - title: "实时监控", - url: "/water-fertilizer-control/smart/realtime", - isActive: false - }, - { - title: "历史记录", - url: "/water-fertilizer-control/smart/history", - isActive: false - } - ] - }, - { - title: "施肥配方管理", - url: "/water-fertilizer-control/fertilizer", - icon: , - items: [ - { - title: "水量控制", - url: "/water-fertilizer-control/fertilizer/water-control", - isActive: false - }, - { - title: "液位设定", - url: "/water-fertilizer-control/fertilizer/level-setting", - isActive: false - }, - { - title: "搅拌控制", - url: "/water-fertilizer-control/fertilizer/stirring-control", - isActive: false - }, - { - title: "历史数据", - url: "/water-fertilizer-control/fertilizer/history-data", - isActive: false - } - ] - }, - { - title: "水肥控制", - url: "/water-fertilizer-control/wf-control", - icon: , - items: [ - { - title: "参数设置", - url: "/water-fertilizer-control/wf-control/params", - isActive: false - }, - { - title: "水箱实时监控", - url: "/water-fertilizer-control/wf-control/tank-realtime", - isActive: false - }, - { - title: "阀门控制", - url: "/water-fertilizer-control/wf-control/valve-control", - isActive: false - }, - { - title: "阀门实时监控", - url: "/water-fertilizer-control/wf-control/valve-realtime", - isActive: false - }, - { - title: "施肥历史", - url: "/water-fertilizer-control/wf-control/fertilizer-history", - isActive: false - }, - { - title: "阀门历史", - url: "/water-fertilizer-control/wf-control/valve-history", - isActive: false - } - ] - }, - { - title: "实时监测与预警", - url: "/water-fertilizer-control/monitoring", - icon: , - items: [ - { - title: "预警逻辑", - url: "/water-fertilizer-control/monitoring/alert-logic", - isActive: false - }, - { - title: "阈值预警", - url: "/water-fertilizer-control/monitoring/threshold-alert", - isActive: false - }, - { - title: "通知推送", - url: "/water-fertilizer-control/monitoring/notification-push", - isActive: false - } - ] - } - ] -} - -function RootLayoutContent({ +export default function AppLayout({ children, }: { children: React.ReactNode }) { - const pathname = usePathname(); - - // 根据当前路径动态选择侧边栏数据 - const getSidebarData = () => { - // 获取当前路径的一级路由 - const firstLevelPath = '/' + pathname.split('/')[1]; - - switch (firstLevelPath) { - case '/agricultural-machinery': - return machineryManagement; - case '/land-information': - return fieldMessageManagement; - case '/farming-operation': - return farmingOperation; - case '/agricultural-asset': - return agricultureAsset; - case '/ai-crop-model': - return aiCropModel; - case '/water-fertilizer-control': - return waterFertilizerControl; - case '/central-config': - return centralConfigData; - default: - return machineryManagement; // 默认返回农机管理 - } - }; - - const sidebarData = getSidebarData(); - - return ( -
- -
- - {children} - -
-
- ); -} - -export default function RootLayout({ - children, -}: { - children: React.ReactNode -}) { - return ( - - - - {children} - - - - - ) + return <>{children}; } \ No newline at end of file diff --git a/crop-x/src/app/layout.tsx b/crop-x/src/app/layout.tsx index c243284..6c68a93 100644 --- a/crop-x/src/app/layout.tsx +++ b/crop-x/src/app/layout.tsx @@ -1,10 +1,1346 @@ 'use client'; import "@/styles/globals.css" import { useEffect } from 'react'; +import { usePathname } from 'next/navigation'; import { AuthProvider } from '@/components/auth/AuthContext'; import { ClientAuthInterceptor } from '@/components/auth/ClientAuthInterceptor'; +import { ThemeProvider } from 'next-themes'; +import { Toaster } from '@/components/ui/sonner'; +import { Building2, Users, Cog, Activity, Mail, UserCircle, Database, Map, BarChart3, Cloud, TrendingUp, GitCompare, AlertTriangle, FileText, MapPin, Settings, User, Package, Navigation, Zap, Target, PieChart, Calendar, Shield, Tractor, Clipboard, ClipboardCheck, Brain, Droplets, Book, ShoppingCart } from 'lucide-react'; -export default function AppLayout({ +// 导入导航和侧边栏组件 +import {Navbar1} from "@/components/layouts/Navbar" +import {SideBarOld} from '@/components/layouts/SideBar/SideBarOld' + +const navbarData = { + logo: { + url: "/", + src: "https://deifkwefumgah.cloudfront.net/shadcnblocks/block/logos/shadcnblockscom-icon.svg", + alt: "Crop-X Logo", + title: "智慧农业生产管理系统", + }, + menu: [ + { + title: "智能农机管理系统", + url: "/agricultural-machinery", + description: "农机档案、实时监控、精准作业管理", + icon: , + }, + { + title: "地块信息管理系统", + url: "/land-information", + description: "地块档案、地图管理、空间分析", + icon: , + }, + { + title: "农事操作管理系统", + url: "/farming-operation", + description: "农事计划、任务管理、操作执行", + icon: , + }, + { + title: "农业资产管理系统", + url: "/agricultural-asset", + description: "基础信息、采购管理、库存管理", + icon: , + }, + { + title: "AI作物模型精准决策系统", + url: "/ai-crop-model", + description: "数据感知、模型应用、智能决策", + icon: , + }, + { + title: "水肥一体化控制系统", + url: "/water-fertilizer-control", + description: "水肥机管理、智能灌溉、配方管理", + icon: , + }, + { + title: "中心配置管理系统", + url: "/central-config", + description: "租户管理、用户管理、系统监控", + icon: , + }, + { + title: "API 测试示例", + url: "/api-example", + description: "测试和展示 OpenAPI 客户端调用", + icon: , + }, + ], + auth: { + login: { title: "登录", url: "/login" }, + signup: { title: "注册", url: "/register" }, + }, +}; + +const centralConfigData = { + navMain: [ + { + title: '个人中心', + url: "/central-config/personal-center", + icon: , + items: [ + { + title: "个人信息", + url: "/central-config/personal-center/personal-info", + isActive: false + },{ + title: "账户安全", + url: "/central-config/personal-center/account-security", + isActive: false + }, + ] + }, + { + title: "租户管理", + url: "/central-config/tenant", + icon: , + items: [ + { + title: "企业管理", + url: "/central-config/tenant/enterprise-management", + isActive: false + }, + { + title: "企业审核", + url: "/central-config/tenant/enterprise-audit", + isActive: false + }, + { + title: "审核历史", + url: "/central-config/tenant/audit-history", + isActive: false + }, + { + title: "企业信息", + url: "/central-config/tenant/enterprise-info", + isActive: false + }, + { + title: "用户管理", + url: "/central-config/tenant/user-management", + isActive: false + } + ] + }, + { + title: "用户管理", + url: "/central-config/user", + icon: , + items: [ + { + title: "员工管理", + url: "/central-config/user/employee", + isActive: false + }, + { + title: "角色管理", + url: "/central-config/user/role", + isActive: false + }, + { + title: "菜单管理", + url: "/central-config/user/menu", + isActive: false + }, + { + title: "权限配置管理", + url: "/central-config/user/permission", + isActive: false + } + ] + }, + { + title: "系统参数", + url: "/central-config/system", + icon: , + items: [ + { + title: "系统设置", + url: "/central-config/system/settings", + isActive: false + }, + { + title: "分类字典", + url: "/central-config/system/category", + isActive: false + }, + { + title: "数据字典", + url: "/central-config/system/dictionary", + isActive: false + } + ] + }, + { + title: "系统监控", + url: "/central-config/monitor", + icon: , + items: [ + { + title: "登录日志", + url: "/central-config/monitor/login-log", + isActive: false + }, + { + title: "操作日志", + url: "/central-config/monitor/operation-log", + isActive: false + }, + { + title: "性能监控", + url: "/central-config/monitor/performance", + isActive: false + }, + { + title: "网络日志", + url: "/central-config/monitor/network-log", + isActive: false + } + ] + }, + { + title: "消息中心", + url: "/central-config/message", + icon: , + items: [ + { + title: "消息发送", + url: "/central-config/message/send", + isActive: false + }, + { + title: "消息模版", + url: "/central-config/message/template", + isActive: false + }, + { + title: "消息日志", + url: "/central-config/message/log", + isActive: false + } + ] + } + ] +} + +// 地块信息管理 +const fieldMessageManagement = { + navMain: [ + { + title: "地块档案管理", + url: "/land-information/archive", + icon: , + items: [ + { + title: "地块档案管理", + url: "/land-information/archive/manage", + isActive: false + }, + { + title: "地块分类与标签管理", + url: "/land-information/archive/classification", + isActive: false + }, + { + title: "统计分析", + url: "/land-information/archive/statistics", + isActive: false + } + ] + }, + { + title: "地块数字化与地图管理", + url: "/land-information/map", + icon: , + items: [ + { + title: "GIS地图管理", + url: "/land-information/map/gis", + isActive: false + }, + { + title: "数字化绘制与编辑", + url: "/land-information/map/draw", + isActive: false + }, + { + title: "空间数据管理", + url: "/land-information/map/spatial-query", + isActive: false + }, + { + title: "地块影像", + url: "/land-information/map/satellite", + isActive: false + } + ] + }, + { + title: "空间分析与决策支持", + url: "/land-information/analysis", + icon: , + items: [ + { + title: "土壤基础数据", + url: "/land-information/analysis/soil-data", + isActive: false + }, + { + title: "分层采样分析", + url: "/land-information/analysis/layer-sampling", + isActive: false + }, + { + title: "土壤质量评价", + url: "/land-information/analysis/soil-quality", + isActive: false + } + ] + }, + { + title: "地块环境监测", + url: "/land-information/monitoring", + icon: , + items: [ + { + title: "气象监测", + url: "/land-information/monitoring/weather", + isActive: false + }, + { + title: "环境监测", + url: "/land-information/monitoring/environment", + isActive: false + } + ] + }, + { + title: "地块适宜性评价", + url: "/land-information/suitability", + icon: , + items: [ + { + title: "多因子综合评价", + url: "/land-information/suitability/multiFactor", + isActive: false + }, + { + title: "自动化空间分析", + url: "/land-information/suitability/auto", + isActive: false + }, + { + title: "作物适配推荐", + url: "/land-information/suitability/recommend", + isActive: false + } + ] + }, + { + title: "地块对比分析", + url: "/land-information/comparison", + icon: , + items: [ + { + title: "多维度指标看板", + url: "/land-information/comparison/indicator", + isActive: false + }, + { + title: "可视化图表分析", + url: "/land-information/comparison/chart", + isActive: false + }, + { + title: "对比报告生成", + url: "/land-information/comparison/report", + isActive: false + } + ] + }, + { + title: "地块风险预警", + url: "/land-information/risk", + icon: , + items: [ + { + title: "实时风险监测", + url: "/land-information/risk/monitoring", + isActive: false + }, + { + title: "预警推送管理", + url: "/land-information/risk/push", + isActive: false + }, + { + title: "预警处置跟踪", + url: "/land-information/risk/disposal", + isActive: false + } + ] + } + ] +} + +// 农机管理 +const machineryManagement = { + navMain: [ + { + title: "农机档案", + url: "/agricultural-machinery/archive", + icon: , + items: [ + { + title: "农机录入维护", + url: "/agricultural-machinery/archive/entry", + isActive: false + }, + { + title: "农机分类管理", + url: "/agricultural-machinery/archive/classification", + isActive: false + }, + { + title: "农机二维码管理", + url: "/agricultural-machinery/archive/qrcode", + isActive: false + } + ] + }, + { + title: "驾驶员档案", + url: "/agricultural-machinery/driver-archive", + icon: , + items: [ + { + title: "驾驶员信息管理", + url: "/agricultural-machinery/driver-archive/info", + isActive: false + }, + { + title: "驾驶员任务管理", + url: "/agricultural-machinery/driver-archive/task", + isActive: false + } + ] + }, + { + title: "农机负载管理", + url: "/agricultural-machinery/load-management", + icon: , + items: [ + { + title: "负载类型管理", + url: "/agricultural-machinery/load-management/type", + isActive: false + }, + { + title: "负载参数管理", + url: "/agricultural-machinery/load-management/parameter", + isActive: false + }, + { + title: "负载设备库", + url: "/agricultural-machinery/load-management/library", + isActive: false + }, + { + title: "负载设备管理", + url: "/agricultural-machinery/load-management/device", + isActive: false + } + ] + }, + { + title: "设备实时监控与定位", + url: "/agricultural-machinery/monitoring", + icon: , + items: [ + { + title: "实时定位监控", + url: "/agricultural-machinery/monitoring/location", + isActive: false + }, + { + title: "作业状态监控", + url: "/agricultural-machinery/monitoring/status", + isActive: false + }, + { + title: "作业数据监控", + url: "/agricultural-machinery/monitoring/operation", + isActive: false + } + ] + }, + { + title: "远程诊断与故障预警", + url: "/agricultural-machinery/fault-diagnosis", + icon: , + items: [ + { + title: "故障预警规则", + url: "/agricultural-machinery/fault-diagnosis/alert-rules", + isActive: false + }, + { + title: "故障预警管理", + url: "/agricultural-machinery/fault-diagnosis/warning", + isActive: false + }, + { + title: "设备健康管理", + url: "/agricultural-machinery/fault-diagnosis/health", + isActive: false + }, + { + title: "设备参数监控", + url: "/agricultural-machinery/fault-diagnosis/parameter", + isActive: false + } + ] + }, + { + title: "精准作业管理与支持", + url: "/agricultural-machinery/precision-operation", + icon: , + items: [ + { + title: "作业记录管理", + url: "/agricultural-machinery/precision-operation/record", + isActive: false + }, + { + title: "路径规划管理", + url: "/agricultural-machinery/precision-operation/route", + isActive: false + }, + { + title: "作业计划调度", + url: "/agricultural-machinery/precision-operation/dispatch", + isActive: false + }, + { + title: "作业驾驶舱", + url: "/agricultural-machinery/precision-operation/cockpit", + isActive: false + } + ] + }, + { + title: "数据管理与分析报告", + url: "/agricultural-machinery/data-analysis", + icon: , + items: [ + { + title: "作业数据分析", + url: "/agricultural-machinery/data-analysis/analysis", + isActive: false + }, + { + title: "历史数据对比", + url: "/agricultural-machinery/data-analysis/comparison", + isActive: false + } + ] + }, + { + title: "农机管理与调度", + url: "/agricultural-machinery/scheduling", + icon: , + items: [ + { + title: "任务分配管理", + url: "/agricultural-machinery/scheduling/assignment", + isActive: false + }, + { + title: "实时调度管理", + url: "/agricultural-machinery/scheduling/dispatch", + isActive: false + }, + { + title: "轨迹回放管理", + url: "/agricultural-machinery/scheduling/playback", + isActive: false + } + ] + }, + { + title: "安全与安防", + url: "/agricultural-machinery/security", + icon: , + items: [ + { + title: "地理围栏管理", + url: "/agricultural-machinery/security/fence", + isActive: false + } + ] + } + ] +} + +// 农事操作管理系统 +const farmingOperation = { + navMain: [ + { + title: "农事计划", + url: "/farming-operation/planning", + icon: , + items: [ + { + title: "农事计划创建", + url: "/farming-operation/planning/creation", + isActive: false + }, + { + title: "农事计划分配", + url: "/farming-operation/planning/allocation", + isActive: false + }, + { + title: "农事计划进度", + url: "/farming-operation/planning/progress", + isActive: false + } + ] + }, + { + title: "农事任务", + url: "/farming-operation/task", + icon: , + items: [ + { + title: "任务管理", + url: "/farming-operation/task/management", + isActive: false + }, + { + title: "任务分配", + url: "/farming-operation/task/assignment", + isActive: false + }, + { + title: "任务监控", + url: "/farming-operation/task/monitoring", + isActive: false + }, + { + title: "任务统计", + url: "/farming-operation/task/statistics", + isActive: false + } + ] + }, + { + title: "农事执行", + url: "/farming-operation/execution", + icon: , + items: [ + { + title: "执行类型", + url: "/farming-operation/execution/type", + isActive: false + }, + { + title: "执行记录", + url: "/farming-operation/execution/record", + isActive: false + }, + { + title: "执行日志", + url: "/farming-operation/execution/log", + isActive: false + } + ] + }, + { + title: "农事日历", + url: "/farming-operation/calendar", + icon: , + items: [ + { + title: "日历视图", + url: "/farming-operation/calendar/view", + isActive: false + }, + { + title: "甘特图", + url: "/farming-operation/calendar/gantt", + isActive: false + }, + { + title: "进度跟踪", + url: "/farming-operation/calendar/progress", + isActive: false + } + ] + }, + { + title: "农事档案", + url: "/farming-operation/archive", + icon: , + items: [ + { + title: "档案聚合", + url: "/farming-operation/archive/aggregation", + isActive: false + }, + { + title: "档案查看", + url: "/farming-operation/archive/view", + isActive: false + }, + { + title: "档案追溯", + url: "/farming-operation/archive/trace", + isActive: false + } + ] + }, + { + title: "农事知识库", + url: "/farming-operation/knowledge", + icon: , + items: [ + { + title: "知识管理", + url: "/farming-operation/knowledge/management", + isActive: false + }, + { + title: "知识分类", + url: "/farming-operation/knowledge/category", + isActive: false + }, + { + title: "知识搜索", + url: "/farming-operation/knowledge/search", + isActive: false + } + ] + }, + { + title: "绩效管理", + url: "/farming-operation/performance", + icon: , + items: [ + { + title: "员工绩效", + url: "/farming-operation/performance/staff", + isActive: false + }, + { + title: "工时统计", + url: "/farming-operation/performance/hours", + isActive: false + }, + { + title: "绩效统计", + url: "/farming-operation/performance/statistics", + isActive: false + }, + { + title: "绩效调度", + url: "/farming-operation/performance/schedule", + isActive: false + } + ] + }, + { + title: "农事问题协同", + url: "/farming-operation/issue", + icon: , + items: [ + { + title: "问题上报", + url: "/farming-operation/issue/report", + isActive: false + }, + { + title: "问题分配", + url: "/farming-operation/issue/assign", + isActive: false + }, + { + title: "问题协同", + url: "/farming-operation/issue/collaborate", + isActive: false + } + ] + } + ] +} + +// 农业资产管理系统 +const agricultureAsset = { + navMain: [ + { + title: "基础信息管理", + url: "/agricultural-asset/basic", + icon: , + items: [ + { + title: "物料信息", + url: "/agricultural-asset/basic/materials", + isActive: false + }, + { + title: "农具信息", + url: "/agricultural-asset/basic/tools", + isActive: false + }, + { + title: "供应商信息", + url: "/agricultural-asset/basic/suppliers", + isActive: false + }, + { + title: "客户信息", + url: "/agricultural-asset/basic/customers", + isActive: false + } + ] + }, + { + title: "采购管理", + url: "/agricultural-asset/purchase", + icon: , + items: [ + { + title: "采购计划", + url: "/agricultural-asset/purchase/plan", + isActive: false + }, + { + title: "采购订单", + url: "/agricultural-asset/purchase/order", + isActive: false + } + ] + }, + { + title: "库存管理", + url: "/agricultural-asset/inventory", + icon: , + items: [ + { + title: "入库管理", + url: "/agricultural-asset/inventory/in", + isActive: false + }, + { + title: "出库管理", + url: "/agricultural-asset/inventory/out", + isActive: false + }, + { + title: "库存盘点", + url: "/agricultural-asset/inventory/check", + isActive: false + }, + { + title: "库存预警", + url: "/agricultural-asset/inventory/warning", + isActive: false + }, + { + title: "库存明细", + url: "/agricultural-asset/inventory/detail", + isActive: false + }, + { + title: "库位管理", + url: "/agricultural-asset/inventory/location", + isActive: false + }, + { + title: "补货建议", + url: "/agricultural-asset/inventory/suggest", + isActive: false + } + ] + }, + { + title: "物资领用", + url: "/agricultural-asset/requisition", + icon: , + items: [ + { + title: "领用申请", + url: "/agricultural-asset/requisition/apply", + isActive: false + }, + { + title: "领用审批", + url: "/agricultural-asset/requisition/approval", + isActive: false + }, + { + title: "领用发放", + url: "/agricultural-asset/requisition/checkout", + isActive: false + }, + { + title: "领用记录", + url: "/agricultural-asset/requisition/record", + isActive: false + } + ] + }, + { + title: "物资归还", + url: "/agricultural-asset/return", + icon: , + items: [ + { + title: "归还登记", + url: "/agricultural-asset/return/register", + isActive: false + }, + { + title: "归还处理", + url: "/agricultural-asset/return/process", + isActive: false + }, + { + title: "归还结算", + url: "/agricultural-asset/return/settlement", + isActive: false + }, + { + title: "归还历史", + url: "/agricultural-asset/return/history", + isActive: false + } + ] + }, + { + title: "农资农具管理", + url: "/agricultural-asset/equipment", + icon: , + items: [ + { + title: "设备档案", + url: "/agricultural-asset/equipment/archive", + isActive: false + }, + { + title: "设备调度", + url: "/agricultural-asset/equipment/dispatch", + isActive: false + }, + { + title: "设备维护", + url: "/agricultural-asset/equipment/maintenance", + isActive: false + }, + { + title: "设备折旧", + url: "/agricultural-asset/equipment/depreciation", + isActive: false + }, + { + title: "设备处置", + url: "/agricultural-asset/equipment/disposal", + isActive: false + } + ] + }, + { + title: "可视化报表", + url: "/agricultural-asset/report", + icon: , + items: [ + { + title: "总览报表", + url: "/agricultural-asset/report/overview", + isActive: false + }, + { + title: "库存报表", + url: "/agricultural-asset/report/inventory", + isActive: false + }, + { + title: "消耗报表", + url: "/agricultural-asset/report/consumption", + isActive: false + } + ] + } + ] +} + +// AI作物模型精准决策系统 +const aiCropModel = { + navMain: [ + { + title: "全域数据感知中心", + url: "/ai-crop-model/data-sense-center", + icon: , + items: [ + { + title: "多源数据接入", + url: "/ai-crop-model/data-sense-center/external", + isActive: false + }, + { + title: "物联设备数据接入", + url: "/ai-crop-model/data-sense-center/iot", + isActive: false + }, + { + title: "设备类型管理", + url: "/ai-crop-model/data-sense-center/device-type", + isActive: false + }, + { + title: "设备参数管理", + url: "/ai-crop-model/data-sense-center/device-parameter", + isActive: false + } + ] + }, + { + title: "模型接入集成", + url: "/ai-crop-model/model-integration", + icon: , + items: [ + { + title: "模型接入", + url: "/ai-crop-model/model-integration/access", + isActive: false + }, + { + title: "模型管理", + url: "/ai-crop-model/model-integration/management", + isActive: false + } + ] + }, + { + title: "模型应用中心", + url: "/ai-crop-model/model-application", + icon: , + items: [ + { + title: "生成调度", + url: "/ai-crop-model/model-application/generation", + isActive: false + }, + { + title: "应用调度", + url: "/ai-crop-model/model-application/scheduling", + isActive: false + } + ] + }, + { + title: "智能决策生成", + url: "/ai-crop-model/decision", + icon: , + items: [ + { + title: "业务融合", + url: "/ai-crop-model/decision/fusion", + isActive: false + }, + { + title: "决策模拟", + url: "/ai-crop-model/decision/simulation", + isActive: false + }, + { + title: "决策日志", + url: "/ai-crop-model/decision/log", + isActive: false + } + ] + }, + { + title: "智能决策支持", + url: "/ai-crop-model/support", + icon: , + items: [ + { + title: "决策仪表盘", + url: "/ai-crop-model/support/dashboard", + isActive: false + }, + { + title: "决策详情", + url: "/ai-crop-model/support/detail", + isActive: false + } + ] + }, + { + title: "决策应用", + url: "/ai-crop-model/application", + icon: , + items: [ + { + title: "设备控制", + url: "/ai-crop-model/application/device-control", + isActive: false + }, + { + title: "外部系统", + url: "/ai-crop-model/application/external-system", + isActive: false + } + ] + }, + { + title: "AI知识库", + url: "/ai-crop-model/knowledge", + icon: , + items: [ + { + title: "知识生成", + url: "/ai-crop-model/knowledge/generation", + isActive: false + } + ] + }, + { + title: "监控中心", + url: "/ai-crop-model/monitoring", + icon: , + items: [ + { + title: "模型监控", + url: "/ai-crop-model/monitoring/model", + isActive: false + }, + { + title: "审计监控", + url: "/ai-crop-model/monitoring/audit", + isActive: false + }, + { + title: "预警监控", + url: "/ai-crop-model/monitoring/alert", + isActive: false + } + ] + } + ] +} + +// 水肥一体化控制系统 +const waterFertilizerControl = { + navMain: [ + { + title: "水肥机管理", + url: "/water-fertilizer-control/wf-management", + icon: , + items: [ + { + title: "设备管理", + url: "/water-fertilizer-control/wf-management/device", + isActive: false + }, + { + title: "组件管理", + url: "/water-fertilizer-control/wf-management/component", + isActive: false + }, + { + title: "参数配置", + url: "/water-fertilizer-control/wf-management/parameter", + isActive: false + }, + { + title: "映射关系", + url: "/water-fertilizer-control/wf-management/mapping", + isActive: false + } + ] + }, + { + title: "智能灌溉", + url: "/water-fertilizer-control/smart", + icon: , + items: [ + { + title: "模型配置", + url: "/water-fertilizer-control/smart/model-config", + isActive: false + }, + { + title: "自动灌溉", + url: "/water-fertilizer-control/smart/auto", + isActive: false + }, + { + title: "手动灌溉", + url: "/water-fertilizer-control/smart/manual", + isActive: false + }, + { + title: "实时监控", + url: "/water-fertilizer-control/smart/realtime", + isActive: false + }, + { + title: "历史记录", + url: "/water-fertilizer-control/smart/history", + isActive: false + } + ] + }, + { + title: "施肥配方管理", + url: "/water-fertilizer-control/fertilizer", + icon: , + items: [ + { + title: "水量控制", + url: "/water-fertilizer-control/fertilizer/water-control", + isActive: false + }, + { + title: "液位设定", + url: "/water-fertilizer-control/fertilizer/level-setting", + isActive: false + }, + { + title: "搅拌控制", + url: "/water-fertilizer-control/fertilizer/stirring-control", + isActive: false + }, + { + title: "历史数据", + url: "/water-fertilizer-control/fertilizer/history-data", + isActive: false + } + ] + }, + { + title: "水肥控制", + url: "/water-fertilizer-control/wf-control", + icon: , + items: [ + { + title: "参数设置", + url: "/water-fertilizer-control/wf-control/params", + isActive: false + }, + { + title: "水箱实时监控", + url: "/water-fertilizer-control/wf-control/tank-realtime", + isActive: false + }, + { + title: "阀门控制", + url: "/water-fertilizer-control/wf-control/valve-control", + isActive: false + }, + { + title: "阀门实时监控", + url: "/water-fertilizer-control/wf-control/valve-realtime", + isActive: false + }, + { + title: "施肥历史", + url: "/water-fertilizer-control/wf-control/fertilizer-history", + isActive: false + }, + { + title: "阀门历史", + url: "/water-fertilizer-control/wf-control/valve-history", + isActive: false + } + ] + }, + { + title: "实时监测与预警", + url: "/water-fertilizer-control/monitoring", + icon: , + items: [ + { + title: "预警逻辑", + url: "/water-fertilizer-control/monitoring/alert-logic", + isActive: false + }, + { + title: "阈值预警", + url: "/water-fertilizer-control/monitoring/threshold-alert", + isActive: false + }, + { + title: "通知推送", + url: "/water-fertilizer-control/monitoring/notification-push", + isActive: false + } + ] + } + ] +} + +// 根据当前路径动态选择侧边栏数据 +const getSidebarData = (pathname: string) => { + // 获取当前路径的一级路由 + const firstLevelPath = '/' + pathname.split('/')[1]; + + switch (firstLevelPath) { + case '/agricultural-machinery': + return machineryManagement; + case '/land-information': + return fieldMessageManagement; + case '/farming-operation': + return farmingOperation; + case '/agricultural-asset': + return agricultureAsset; + case '/ai-crop-model': + return aiCropModel; + case '/water-fertilizer-control': + return waterFertilizerControl; + case '/central-config': + return centralConfigData; + default: + return machineryManagement; // 默认返回农机管理 + } +}; + +// 应用布局组件 +function AppLayoutContent({ + children, +}: { + children: React.ReactNode +}) { + const pathname = usePathname(); + + // 检查是否为登录页面或认证相关页面 + const isAuthPage = pathname?.startsWith('/login') || pathname?.startsWith('/register'); + + // 如果是认证页面,直接渲染子组件,不显示导航栏和侧边栏 + if (isAuthPage) { + return <>{children}; + } + + const sidebarData = getSidebarData(pathname); + + return ( +
+ +
+ + {children} + +
+
+ ); +} + +export default function RootLayout({ children, }: { children: React.ReactNode @@ -17,11 +1353,19 @@ export default function AppLayout({ return ( - - - {children} - - + + + + {children} + + + + ) diff --git a/crop-x/src/app/page.tsx b/crop-x/src/app/page.tsx index 3b1eca7..8ef5598 100644 --- a/crop-x/src/app/page.tsx +++ b/crop-x/src/app/page.tsx @@ -4,7 +4,7 @@ export default function HomePage() { return (
- +
); } \ No newline at end of file diff --git a/crop-x/src/components/auth/AuthContext.tsx b/crop-x/src/components/auth/AuthContext.tsx index 1b9e092..261b9e5 100644 --- a/crop-x/src/components/auth/AuthContext.tsx +++ b/crop-x/src/components/auth/AuthContext.tsx @@ -236,24 +236,54 @@ export function AuthProvider({ children }: AuthProviderProps) { } }; - // 初始化时检查 localStorage并验证用户 + // 统一的认证初始化和路由监听 React.useEffect(() => { - // 检查是否有存储的用户信息和 token,并设置 cookie - const storedUser = localStorage.getItem('user'); - if (storedUser) { - try { - const userData = JSON.parse(storedUser); - if (userData.token && !document.cookie.includes('auth-token')) { - setTokenCookie(userData.token); - console.log('🔄 初始化时设置cookie'); - } - } catch (error) { - console.error('解析存储用户信息失败:', error); - localStorage.removeItem('user'); - } - } + // 处理当前路径的逻辑 + const handleCurrentPath = () => { + const currentPath = typeof window !== 'undefined' ? window.location.pathname : ''; - validateUser(); + // 如果在登录页面,跳过验证,直接设置为非加载状态 + if (currentPath.startsWith('/login')) { + console.log('📄 检测到登录页面,跳过用户验证'); + stopTokenRefresh(); // 停止任何正在进行的 token 刷新 + setLoading(false); + return; + } + + // 检查是否有存储的用户信息和 token,并设置 cookie + const storedUser = localStorage.getItem('user'); + if (storedUser) { + try { + const userData = JSON.parse(storedUser); + if (userData.token && !document.cookie.includes('auth-token')) { + setTokenCookie(userData.token); + console.log('🔄 初始化时设置cookie'); + } + } catch (error) { + console.error('解析存储用户信息失败:', error); + localStorage.removeItem('user'); + } + } + + // 只有在非登录页面才进行用户验证 + validateUser(); + }; + + // 立即处理当前路径 + handleCurrentPath(); + + // 监听路由变化 + const handlePathChange = () => { + console.log('🔄 路由变化,重新检查认证状态'); + handleCurrentPath(); + }; + + // 监听 popstate 事件(浏览器前进后退) + window.addEventListener('popstate', handlePathChange); + + return () => { + window.removeEventListener('popstate', handlePathChange); + }; }, []); // 清理定时器 diff --git a/crop-x/src/components/layouts/Navbar.tsx b/crop-x/src/components/layouts/Navbar.tsx index 811c184..7015dc4 100644 --- a/crop-x/src/components/layouts/Navbar.tsx +++ b/crop-x/src/components/layouts/Navbar.tsx @@ -5,10 +5,9 @@ import { Sprout, Map, Clipboard, Package, Brain, Droplets, Settings } from 'luci import { MessageBell } from './components/MessageBell'; import { UserProfile } from './components/UserProfile'; import { ThemeToggle } from './ThemeToggle'; -import { AuthProvider } from './components/auth/AuthContext'; import { useElementHeight } from '@/hooks/useElementHeight'; import { useViewHeight } from '@/hooks/useViewHeight'; -import { usePathname } from 'next/navigation'; +import { usePathname, useRouter } from 'next/navigation'; import { useRef, useEffect, useState } from 'react'; // 注释掉 Accordion 相关导入,因为不再需要二级菜单 // import { @@ -69,6 +68,7 @@ const Navbar1 = ({ navbarData }: Navbar1Props) => { const menu = navbarData.menu const auth = navbarData.auth const pathname = usePathname() + const router = useRouter() const containerStyle = { maxWidth:"100%",marginLeft:"0px",marginRight:"0px",paddingLeft:"1rem",paddingRight:"0rem" } @@ -107,8 +107,7 @@ const Navbar1 = ({ navbarData }: Navbar1Props) => { }; return ( - -
+
{/* Desktop Menu */}
@@ -195,7 +194,7 @@ const Navbar1 = ({ navbarData }: Navbar1Props) => {
{/* 简化移动端菜单,不再使用 Accordion */}
- {menu.map((item) => renderMobileMenuItem(item, isMenuActive))} + {menu.map((item) => renderMobileMenuItem(item, isMenuActive, router))}
@@ -216,11 +215,10 @@ const Navbar1 = ({ navbarData }: Navbar1Props) => {
- ); }; -const renderMenuItem = (item: MenuItem, isMenuActive: (url: string) => boolean) => { +const renderMenuItem = (item: MenuItem, isMenuActive: (url: string) => boolean, router: any) => { // 注释掉二级菜单相关代码,项目不需要二级菜单 // if (item.items) { // return ( @@ -238,14 +236,20 @@ const renderMenuItem = (item: MenuItem, isMenuActive: (url: string) => boolean) // ); // } + const handleClick = (e: React.MouseEvent) => { + e.preventDefault(); + router.push(item.url); + }; + return ( boolean) ); }; -const renderMobileMenuItem = (item: MenuItem, isMenuActive: (url: string) => boolean) => { +const renderMobileMenuItem = (item: MenuItem, isMenuActive: (url: string) => boolean, router: any) => { // 注释掉移动端二级菜单相关代码 // if (item.items) { // return ( @@ -293,12 +297,17 @@ const renderMobileMenuItem = (item: MenuItem, isMenuActive: (url: string) => boo // ); // } + const handleClick = (e: React.MouseEvent) => { + e.preventDefault(); + router.push(item.url); + }; + return ( - boo {item.title} - + ); }; diff --git a/crop-x/src/components/layouts/components/MessageBell.tsx b/crop-x/src/components/layouts/components/MessageBell.tsx index 2b2321f..18b717c 100644 --- a/crop-x/src/components/layouts/components/MessageBell.tsx +++ b/crop-x/src/components/layouts/components/MessageBell.tsx @@ -2,7 +2,6 @@ import { useState } from 'react'; import { Bell, CheckCircle, X } from 'lucide-react'; -import { useAuth } from './auth/AuthContext'; import { toast } from 'sonner'; import { Badge } from './ui/badge'; import { Button } from './ui/button'; @@ -25,7 +24,6 @@ interface MessageBellProps { } export function MessageBell({ onMessageClick }: MessageBellProps) { - const { authState } = useAuth(); const [showMessages, setShowMessages] = useState(false); const [showMessageDetail, setShowMessageDetail] = useState(false); const [selectedMessage, setSelectedMessage] = useState(null);