From e9fcdc7d2eaf452c05d8f58ba6b7363923767a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 27 Nov 2024 11:35:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- napcat.webui/src/pages/NetWork.vue | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/napcat.webui/src/pages/NetWork.vue b/napcat.webui/src/pages/NetWork.vue index fc878b96..ca0c8e8b 100644 --- a/napcat.webui/src/pages/NetWork.vue +++ b/napcat.webui/src/pages/NetWork.vue @@ -175,14 +175,7 @@ const operateType = ref(''); //配置项索引 const configIndex = ref(0); //保存时所用数据 -interface NetworkConfigType { - [key: string]: any; - websocketClients: any[]; - websocketServers: any[]; - httpClients: any[]; - httpServers: any[]; -} -const networkConfig: NetworkConfigType = { +const networkConfig: NetworkConfig & { [key: string]: any; } = { websocketClients: [], websocketServers: [], httpClients: [], @@ -199,22 +192,12 @@ const WebConfg = ref( ['websocketClients', []], ]) ); -interface TypeChType { - [key: string]: string; - httpServers: string; - httpClients: string; - websocketServers: string; - websocketClients: string; -} const typeCh: Record = { httpServers: 'HTTP 服务器', httpClients: 'HTTP 客户端', websocketServers: 'WebSocket 服务器', websocketClients: 'WebSocket 客户端', }; -const getKeyByValue = (obj: TypeChType, value: string): string | undefined => { - return Object.entries(obj).find(([_, v]) => v === value)?.[0]; -}; const cardConfig = ref([]); const getComponent = (type: ComponentKey) => { return componentMap[type]; @@ -229,7 +212,7 @@ const addConfig = () => { const editConfig = (item: any) => { dialogTitle.value = '修改配置'; - const type = getKeyByValue(typeCh, item.type); + const type = typeCh[item.type as ComponentKey] ?? ''; if (type) { newTab.value = { name: item.name, data: item, type: type }; } @@ -238,7 +221,7 @@ const editConfig = (item: any) => { visibleBody.value = true; }; const delConfig = (item: any) => { - const type = getKeyByValue(typeCh, item.type); + const type = typeCh[item.type as ComponentKey] ?? ''; if (type) { newTab.value = { name: item.name, data: item, type: type }; }