64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
export const POWER_STATUS = {
|
|
NOT_CHARGING: 0,
|
|
CHARGING: 1,
|
|
FULL: 2,
|
|
} as const
|
|
|
|
export type PowerStatus = (typeof POWER_STATUS)[keyof typeof POWER_STATUS]
|
|
|
|
export const POWER_STATUS_VALUES = [POWER_STATUS.NOT_CHARGING, POWER_STATUS.CHARGING, POWER_STATUS.FULL] as const
|
|
|
|
export const BATTERY_LIST_SORT = {
|
|
CREATED_AT_DESC: 'createdAtDesc',
|
|
CREATED_AT_ASC: 'createdAtAsc',
|
|
POWER_DESC: 'powerDesc',
|
|
POWER_ASC: 'powerAsc',
|
|
} as const
|
|
|
|
export type BatteryListSort = (typeof BATTERY_LIST_SORT)[keyof typeof BATTERY_LIST_SORT]
|
|
|
|
export const BATTERY_LIST_SORT_VALUES = [
|
|
BATTERY_LIST_SORT.CREATED_AT_DESC,
|
|
BATTERY_LIST_SORT.CREATED_AT_ASC,
|
|
BATTERY_LIST_SORT.POWER_DESC,
|
|
BATTERY_LIST_SORT.POWER_ASC,
|
|
] as const
|
|
|
|
export const MYSQL_BOOLEAN = {
|
|
TRUE: 'true',
|
|
FALSE: 'false',
|
|
} as const
|
|
|
|
export function toMysqlBoolean(value: boolean) {
|
|
return value ? MYSQL_BOOLEAN.TRUE : MYSQL_BOOLEAN.FALSE
|
|
}
|
|
|
|
export function fromMysqlBoolean(value: string | boolean) {
|
|
if (typeof value === 'boolean') return value
|
|
return value.toLowerCase() === MYSQL_BOOLEAN.TRUE
|
|
}
|
|
|
|
export const DEVICE_STATUS = {
|
|
HEALTHY: '健康',
|
|
WATCH: '关注',
|
|
WARNING: '预警',
|
|
} as const
|
|
|
|
export type DeviceStatus = (typeof DEVICE_STATUS)[keyof typeof DEVICE_STATUS]
|
|
|
|
export const EVENT_SEVERITY = {
|
|
HIGH: '高',
|
|
MEDIUM: '中',
|
|
LOW: '低',
|
|
} as const
|
|
|
|
export type EventSeverity = (typeof EVENT_SEVERITY)[keyof typeof EVENT_SEVERITY]
|
|
|
|
export const SOH_THRESHOLDS = {
|
|
WARNING: 85,
|
|
WATCH: 90,
|
|
LOW_POWER: 20,
|
|
HIGH_RISK_SCORE: 70,
|
|
WATCH_RISK_SCORE: 40,
|
|
} as const
|