整理
This commit is contained in:
27
ems-frontend/src/constants/pollution.ts
Normal file
27
ems-frontend/src/constants/pollution.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @file Pollution related constants, aligned with backend enums.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the types of pollution, consistent with the `PollutionType` enum in the backend.
|
||||
* This ensures that frontend displays and data submissions are aligned with backend expectations.
|
||||
*/
|
||||
export const POLLUTION_TYPES = ['PM25', 'O3', 'NO2', 'SO2', 'OTHER'] as const;
|
||||
|
||||
/**
|
||||
* Type definition for a single pollution type.
|
||||
* Ensures type safety when working with pollution constants.
|
||||
*/
|
||||
export type PollutionType = typeof POLLUTION_TYPES[number];
|
||||
|
||||
/**
|
||||
* A map to provide human-readable names for pollution types.
|
||||
* Useful for displaying in UI components like chart legends or labels.
|
||||
*/
|
||||
export const POLLUTION_TYPE_MAP: Record<PollutionType, string> = {
|
||||
PM25: 'PM2.5',
|
||||
O3: 'O₃',
|
||||
NO2: 'NO₂',
|
||||
SO2: 'SO₂',
|
||||
OTHER: '其他',
|
||||
};
|
||||
Reference in New Issue
Block a user