ci/woodpecker/push/woodpecker Pipeline was successful
Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { lazy } from 'react';
|
|
import {
|
|
Activity,
|
|
Fuel,
|
|
MapPinned,
|
|
Route,
|
|
Truck,
|
|
Wallet,
|
|
Zap,
|
|
} from 'lucide-react';
|
|
import type { ModuleConfig } from '../components/Shell';
|
|
import { canAccessEnergy, canAccessScheduling } from '../shared/auth/roles';
|
|
import type { PathSet } from './routing';
|
|
|
|
const AssetsModule = lazy(() => import('../modules/assets/AssetsModule'));
|
|
const MileageModule = lazy(() => import('../modules/mileage/MileageModule'));
|
|
const SchedulingModule = lazy(() => import('../modules/scheduling/SchedulingModule'));
|
|
const HydrogenModule = lazy(() => import('../modules/energy/HydrogenModule'));
|
|
const ElectricModule = lazy(() => import('../modules/energy/ElectricModule'));
|
|
const EtcModule = lazy(() => import('../modules/energy/EtcModule'));
|
|
const VehicleHeatmapModule = lazy(() => import('../modules/vehicle-heatmap/VehicleHeatmapModule'));
|
|
const HydrogenHeatmapModule = lazy(() => import('../modules/hydrogen-heatmap/HydrogenHeatmapModule'));
|
|
|
|
const ASSET_MODULES: ModuleConfig[] = [
|
|
{ id: 'assets', label: '资产管理', icon: Truck, component: AssetsModule },
|
|
{ id: 'mileage', label: '里程管理', icon: Route, component: MileageModule },
|
|
];
|
|
|
|
const VEHICLE_HEATMAP_MODULE: ModuleConfig = {
|
|
id: 'vehicle-heatmap',
|
|
label: '车辆',
|
|
icon: MapPinned,
|
|
component: VehicleHeatmapModule,
|
|
};
|
|
|
|
const HYDROGEN_HEATMAP_MODULE: ModuleConfig = {
|
|
id: 'hydrogen-heatmap',
|
|
label: '加氢',
|
|
icon: MapPinned,
|
|
component: HydrogenHeatmapModule,
|
|
};
|
|
|
|
const SCHEDULING_MODULE: ModuleConfig = {
|
|
id: 'scheduling',
|
|
label: '智能调度',
|
|
icon: Activity,
|
|
component: SchedulingModule,
|
|
};
|
|
|
|
const ENERGY_MODULES: ModuleConfig[] = [
|
|
{ id: 'hydrogen', label: '氢费BI', icon: Fuel, component: HydrogenModule },
|
|
{ id: 'electric', label: '电能', icon: Zap, component: ElectricModule },
|
|
{ id: 'etc', label: 'ETC', icon: Wallet, component: EtcModule },
|
|
];
|
|
|
|
/** 根据主路径和角色生成导航;返回新数组,避免调用方修改静态注册表。 */
|
|
export function buildModules(
|
|
pathSet: PathSet,
|
|
roles: readonly string[] | null | undefined,
|
|
): ModuleConfig[] {
|
|
if (pathSet === 'energy') return [...ENERGY_MODULES];
|
|
|
|
const heatmapChildren = canAccessEnergy(roles)
|
|
? [HYDROGEN_HEATMAP_MODULE, VEHICLE_HEATMAP_MODULE]
|
|
: [VEHICLE_HEATMAP_MODULE];
|
|
const modules: ModuleConfig[] = [
|
|
...ASSET_MODULES,
|
|
{ id: 'heatmap', label: '热力图', icon: MapPinned, children: heatmapChildren },
|
|
];
|
|
if (canAccessScheduling(roles)) modules.push(SCHEDULING_MODULE);
|
|
return modules;
|
|
}
|