Commit ea07f522514a52d4cbdaadb03980ff139156f01a
Merge branch 'ww' into 'main'
perf: board component dashboard component dynamic set max value See merge request huang/yun-teng-iot-front!348
Showing
5 changed files
with
14 additions
and
4 deletions
| @@ -44,3 +44,6 @@ VITE_CONTENT_SECURITY_POLICY = false | @@ -44,3 +44,6 @@ VITE_CONTENT_SECURITY_POLICY = false | ||
| 44 | 44 | ||
| 45 | # Alarm Notify Polling Interval Time | 45 | # Alarm Notify Polling Interval Time | 
| 46 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 5000 | 46 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 5000 | 
| 47 | + | ||
| 48 | +# Alarm Notify Auto Close Time | ||
| 49 | +VITE_ALARM_NOTIFY_DURATION = 5000 | 
| @@ -45,3 +45,6 @@ VITE_CONTENT_SECURITY_POLICY = false | @@ -45,3 +45,6 @@ VITE_CONTENT_SECURITY_POLICY = false | ||
| 45 | 45 | ||
| 46 | # Alarm Notify Polling Interval Time | 46 | # Alarm Notify Polling Interval Time | 
| 47 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 60000 | 47 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME = 60000 | 
| 48 | + | ||
| 49 | +# Alarm Notify Auto Close Time | ||
| 50 | +VITE_ALARM_NOTIFY_DURATION = 5000 | 
| @@ -9,12 +9,14 @@ interface UseAlarmNotifyParams { | @@ -9,12 +9,14 @@ interface UseAlarmNotifyParams { | ||
| 9 | alarmNotifyStatus?: AlarmStatus; | 9 | alarmNotifyStatus?: AlarmStatus; | 
| 10 | interval?: number; | 10 | interval?: number; | 
| 11 | color?: string; | 11 | color?: string; | 
| 12 | + duration?: number; | ||
| 12 | } | 13 | } | 
| 13 | 14 | ||
| 14 | export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | 15 | export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | 
| 15 | const { | 16 | const { | 
| 16 | alarmNotifyStatus = AlarmStatus.ACTIVE_UN_ACK, | 17 | alarmNotifyStatus = AlarmStatus.ACTIVE_UN_ACK, | 
| 17 | interval = import.meta.env.VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME, | 18 | interval = import.meta.env.VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME, | 
| 19 | + duration = import.meta.env.VITE_ALARM_NOTIFY_DURATION, | ||
| 18 | color = 'orange', | 20 | color = 'orange', | 
| 19 | } = params; | 21 | } = params; | 
| 20 | const alarmNotifyStatusMean = AlarmStatusMean[alarmNotifyStatus]; | 22 | const alarmNotifyStatusMean = AlarmStatusMean[alarmNotifyStatus]; | 
| @@ -40,10 +42,9 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -40,10 +42,9 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 40 | 42 | ||
| 41 | const severityMean = alarmLevel(severity); | 43 | const severityMean = alarmLevel(severity); | 
| 42 | 44 | ||
| 43 | - console.log('enter'); | ||
| 44 | notification.open({ | 45 | notification.open({ | 
| 45 | message: '设备告警', | 46 | message: '设备告警', | 
| 46 | - duration: null, | 47 | + duration, | 
| 47 | key, | 48 | key, | 
| 48 | description: h('div', {}, [ | 49 | description: h('div', {}, [ | 
| 49 | h('div', { style: { marginRight: '5px' } }, [ | 50 | h('div', { style: { marginRight: '5px' } }, [ | 
| @@ -61,8 +62,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | @@ -61,8 +62,6 @@ export function useAlarmNotify(params: UseAlarmNotifyParams = {}) { | ||
| 61 | ]), | 62 | ]), | 
| 62 | icon: h(ExclamationCircleOutlined, { style: { color: '#faa22d' } }), | 63 | icon: h(ExclamationCircleOutlined, { style: { color: '#faa22d' } }), | 
| 63 | onClose: () => { | 64 | onClose: () => { | 
| 64 | - console.log('enter close'); | ||
| 65 | - // currentNotifyId = null; | ||
| 66 | key = null; | 65 | key = null; | 
| 67 | }, | 66 | }, | 
| 68 | btn: h( | 67 | btn: h( | 
| @@ -279,9 +279,12 @@ const handleValue = (value: any) => { | @@ -279,9 +279,12 @@ const handleValue = (value: any) => { | ||
| 279 | 279 | ||
| 280 | export const update_instrument_1_value = (params: DashBoardValue) => { | 280 | export const update_instrument_1_value = (params: DashBoardValue) => { | 
| 281 | const { value = 0, unit = '°C', fontColor } = params; | 281 | const { value = 0, unit = '°C', fontColor } = params; | 
| 282 | + let max = value > 1 ? Number(1 + Array(String(value).length).fill(0).join('')) / 2 : 100 / 2; | ||
| 283 | + max = value > max ? max * 2 : max; | ||
| 282 | return { | 284 | return { | 
| 283 | series: [ | 285 | series: [ | 
| 284 | { | 286 | { | 
| 287 | + max: max < 100 ? 100 : max, | ||
| 285 | data: [{ value: handleValue(value) }], | 288 | data: [{ value: handleValue(value) }], | 
| 286 | detail: { | 289 | detail: { | 
| 287 | formatter: `{value} ${unit ?? ''}`, | 290 | formatter: `{value} ${unit ?? ''}`, | 
| @@ -289,6 +292,7 @@ export const update_instrument_1_value = (params: DashBoardValue) => { | @@ -289,6 +292,7 @@ export const update_instrument_1_value = (params: DashBoardValue) => { | ||
| 289 | }, | 292 | }, | 
| 290 | }, | 293 | }, | 
| 291 | { | 294 | { | 
| 295 | + max: max < 100 ? 100 : max, | ||
| 292 | data: [{ value: handleValue(value) }], | 296 | data: [{ value: handleValue(value) }], | 
| 293 | }, | 297 | }, | 
| 294 | ], | 298 | ], | 
| @@ -73,6 +73,7 @@ declare global { | @@ -73,6 +73,7 @@ declare global { | ||
| 73 | VITE_GENERATE_UI: string; | 73 | VITE_GENERATE_UI: string; | 
| 74 | VITE_CONTENT_SECURITY_POLICY: boolean; | 74 | VITE_CONTENT_SECURITY_POLICY: boolean; | 
| 75 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME: number; | 75 | VITE_ALARM_NOTIFY_POLLING_INTERVAL_TIME: number; | 
| 76 | + VITE_ALARM_NOTIFY_DURATION: number; | ||
| 76 | } | 77 | } | 
| 77 | 78 | ||
| 78 | declare function parseInt(s: string | number, radix?: number): number; | 79 | declare function parseInt(s: string | number, radix?: number): number; |