From 08ff88cb2dab5667f2785c5ce979276effd03cd4 Mon Sep 17 00:00:00 2001 From: 3octaves <873551943@qq.com> Date: Thu, 7 Nov 2024 15:51:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20redis=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E6=8B=93=E6=89=91=E3=80=81=E8=AE=BF=E9=97=AE=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=20#7619?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/cluster-entry/cluster-entry-details.ts | 6 +++--- .../db-manage/common/cluster-entry-config/Index.vue | 8 +++++--- .../common/cluster-oprations/ClusterPassword.vue | 11 +++++++---- .../list/components/list/components/EntryPanel.vue | 8 +++++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dbm-ui/frontend/src/services/model/cluster-entry/cluster-entry-details.ts b/dbm-ui/frontend/src/services/model/cluster-entry/cluster-entry-details.ts index 6f5a9670fb..cd7f42fedb 100644 --- a/dbm-ui/frontend/src/services/model/cluster-entry/cluster-entry-details.ts +++ b/dbm-ui/frontend/src/services/model/cluster-entry/cluster-entry-details.ts @@ -43,13 +43,13 @@ export interface ClbPolarisTargetDetails { url: string; } -export default class ClusterEntryDetail { +export default class ClusterEntryDetail { cluster_entry_type: string; // 'dns' | 'clb' | 'polaris' | 'clbDns' entry: string; role: string; - target_details: (DnsTargetDetails | ClbPolarisTargetDetails)[]; + target_details: T[]; - constructor(payload = {} as ClusterEntryDetail) { + constructor(payload = {} as ClusterEntryDetail) { this.cluster_entry_type = payload.cluster_entry_type; this.entry = payload.entry; this.role = payload.role; diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-entry-config/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-entry-config/Index.vue index 4fccdb471b..8c5d9294e2 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/cluster-entry-config/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-entry-config/Index.vue @@ -67,7 +67,7 @@ import { useI18n } from 'vue-i18n'; import { useRequest } from 'vue-request'; - import type { DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details'; + import ClusterEntryDetailModel, { type DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details'; import { getClusterEntries } from '@services/source/clusterEntry'; import type { DBTypes } from '@common/const'; @@ -121,8 +121,10 @@ type: item.cluster_entry_type, entry: item.entry, role: item.role, - ips: item.isDns ? (item.target_details as DnsTargetDetails[]).map((row) => row.ip).join('\n') : '', - port: item.target_details[0]?.port, + ips: item.isDns + ? (item as ClusterEntryDetailModel).target_details.map((row) => row.ip).join('\n') + : '', + port: (item as ClusterEntryDetailModel).target_details[0]?.port, })), ); }, diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ClusterPassword.vue b/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ClusterPassword.vue index 6e27d7aece..3997723f5f 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ClusterPassword.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ClusterPassword.vue @@ -126,7 +126,10 @@ import { useI18n } from 'vue-i18n'; import { useRequest } from 'vue-request'; - import type { ClbPolarisTargetDetails, DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details'; + import ClusterEntryDetailModel, { + type ClbPolarisTargetDetails, + type DnsTargetDetails, + } from '@services/model/cluster-entry/cluster-entry-details'; import { getClusterEntries } from '@services/source/clusterEntry'; import { getRedisPassword } from '@services/source/redis'; @@ -222,16 +225,16 @@ res.forEach((item) => { if (item.target_details.length) { if (item.isClb) { - const targetDetailItem = item.target_details[0] as ClbPolarisTargetDetails; + const targetDetailItem = (item as ClusterEntryDetailModel).target_details[0]; dataObj.value.clb.list[0].value = `${targetDetailItem.clb_ip}:${targetDetailItem.port}`; dataObj.value.clb.list[1].value = `${targetDetailItem.clb_domain}:${targetDetailItem.port}`; } else if (item.isPolaris) { - const targetDetailItem = item.target_details[0] as ClbPolarisTargetDetails; + const targetDetailItem = (item as ClusterEntryDetailModel).target_details[0]; dataObj.value.polary.list[0].value = targetDetailItem.polaris_l5; dataObj.value.polary.list[0].shareLink = targetDetailItem.url; dataObj.value.polary.list[1].value = `${targetDetailItem.polaris_name}:${targetDetailItem.port}`; } else if (item.isNodeEntry) { - const targetDetailItem = item.target_details[0] as DnsTargetDetails; + const targetDetailItem = (item as ClusterEntryDetailModel).target_details[0]; dataObj.value.nodes.list[0].value = `${item.entry}:${targetDetailItem.port}`; } } diff --git a/dbm-ui/frontend/src/views/db-manage/redis/list/components/list/components/EntryPanel.vue b/dbm-ui/frontend/src/views/db-manage/redis/list/components/list/components/EntryPanel.vue index 000317c20f..f121faaf03 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/list/components/list/components/EntryPanel.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/list/components/list/components/EntryPanel.vue @@ -49,7 +49,9 @@ import { useI18n } from 'vue-i18n'; import { useRequest } from 'vue-request'; - import { type ClbPolarisTargetDetails } from '@services/model/cluster-entry/cluster-entry-details'; + import ClusterEntryDetailModel, { + type ClbPolarisTargetDetails, + } from '@services/model/cluster-entry/cluster-entry-details'; import { getClusterEntries } from '@services/source/clusterEntry'; import { useCopy } from '@hooks'; @@ -110,11 +112,11 @@ onSuccess: (res) => { const entryItem = res[0]; if (entryItem.isClb) { - const targetDetailItem = entryItem.target_details[0] as ClbPolarisTargetDetails; + const targetDetailItem = (entryItem as ClusterEntryDetailModel).target_details[0]; dataObj.clb.list[0].value = targetDetailItem.clb_ip; dataObj.clb.list[1].value = targetDetailItem.clb_domain; } else if (entryItem.isPolaris) { - const targetDetailItem = entryItem.target_details[0] as ClbPolarisTargetDetails; + const targetDetailItem = (entryItem as ClusterEntryDetailModel).target_details[0]; dataObj.polaris.list[0].value = targetDetailItem.polaris_l5; dataObj.polaris.list[1].value = targetDetailItem.polaris_name; dataObj.polaris.list[0].shareLink = targetDetailItem.url;