refactor: extract isNvrCluster
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmNvrResultVO } from '@/apis/models';
|
||||
import { isNvrCluster } from '@/components/helper';
|
||||
import dayjs from 'dayjs';
|
||||
import { NButton, NCard, NDatePicker, NFlex, NGi, NGrid, NSelect, type DatePickerProps, type SelectOption } from 'naive-ui';
|
||||
import { computed, onMounted, reactive, ref, toRefs, useTemplateRef } from 'vue';
|
||||
@@ -66,12 +67,11 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
const diagCards = computed<SelectOption[]>(() => {
|
||||
const isCluster = (maybeNvrCluster: NdmNvrResultVO) => !!maybeNvrCluster.clusterList?.trim() && maybeNvrCluster.clusterList !== maybeNvrCluster.ipAddress;
|
||||
const baseOptions: SelectOption[] = [
|
||||
{ label: '设备状态', value: 'status' },
|
||||
{ label: '设备告警', value: 'alarm' },
|
||||
];
|
||||
if (!isCluster(ndmNvr.value)) {
|
||||
if (!isNvrCluster(ndmNvr.value)) {
|
||||
baseOptions.push({ label: '硬件使用率', value: 'usage' }, { label: '硬盘健康', value: 'health' });
|
||||
}
|
||||
return baseOptions;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmNvrDiagInfo } from '@/apis/domains';
|
||||
import type { NdmNvrResultVO } from '@/apis/models';
|
||||
import { isNvrCluster } from '@/components/helper';
|
||||
import { useDebugModeStore } from '@/stores/debug-mode';
|
||||
import { destr } from 'destr';
|
||||
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
|
||||
@@ -46,10 +47,7 @@ const diskHealth = computed(() => lastDiagInfo.value?.info.diskHealth);
|
||||
const groupInfoList = computed(() => lastDiagInfo.value?.info.groupInfoList);
|
||||
|
||||
const isCluster = computed(() => {
|
||||
const { ipAddress, clusterList } = ndmNvr.value;
|
||||
if (!clusterList?.trim()) return false;
|
||||
if (clusterList === ipAddress) return false;
|
||||
return true;
|
||||
return isNvrCluster(ndmNvr.value);
|
||||
});
|
||||
|
||||
const selectedTab = ref('设备状态');
|
||||
|
||||
Reference in New Issue
Block a user