refactor: extract getPortStatusVal
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* - 响应式数据处理和布局
|
||||
*/
|
||||
|
||||
import { transformPortSpeed } from '../../helper';
|
||||
import { getPortStatusVal, transformPortSpeed } from '../../helper';
|
||||
import type { NdmSwitchPortInfo } from '@/apis/domains';
|
||||
import { NCard, NGrid, NGridItem, NPopover } from 'naive-ui';
|
||||
import { computed, toRefs } from 'vue';
|
||||
@@ -240,9 +240,7 @@ const getPortStatusClass = (port: NdmSwitchPortInfo) => {
|
||||
</div>
|
||||
<div class="port-info-row">
|
||||
<span class="label">状态:</span>
|
||||
<span class="value" :class="getPortStatusClass(port)">
|
||||
{{ port.upDown === 1 ? '启用' : port.upDown === 2 ? '禁用' : '未知' }}
|
||||
</span>
|
||||
<span class="value" :class="getPortStatusClass(port)">{{ getPortStatusVal(port) }}</span>
|
||||
</div>
|
||||
<div class="port-info-row">
|
||||
<span class="label">上行速率:</span>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import type { NdmSwitchPortInfo } from '@/apis/domains';
|
||||
import { JAVA_UNSIGNED_INTEGER_MAX_VALUE, NDM_SWITCH_PROBE_INTERVAL } from '@/constants';
|
||||
|
||||
export const getPortStatusVal = (portInfo: NdmSwitchPortInfo): string => {
|
||||
const { upDown } = portInfo;
|
||||
return upDown === 1 ? '启用' : upDown === 2 ? '禁用' : '未知';
|
||||
};
|
||||
|
||||
export const transformPortSpeed = (portInfo: NdmSwitchPortInfo, type: 'in' | 'out' | 'total'): string => {
|
||||
const units = ['B/s', 'KB/s', 'MB/s', 'GB/s', 'TB/s'];
|
||||
const { inBytes, lastInBytes, outBytes, lastOutBytes, inFlow, outFlow, flow } = portInfo;
|
||||
|
||||
Reference in New Issue
Block a user