From 42cfdefb7449bab1209a55dfda7c28dd3ab9d1e8 Mon Sep 17 00:00:00 2001 From: lijun Date: Wed, 28 Jan 2026 21:48:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AD=96=E7=95=A5=E5=8C=B9?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/vpn-policy.vue | 139 +++++++++++++++++++++++++++----- 1 file changed, 117 insertions(+), 22 deletions(-) diff --git a/src/views/system/vpn-policy.vue b/src/views/system/vpn-policy.vue index 866bc37..e6ab313 100644 --- a/src/views/system/vpn-policy.vue +++ b/src/views/system/vpn-policy.vue @@ -65,11 +65,32 @@ - - - - + + + {{ showCustomProtocolInput ? '取消' : '+ 自定义' }} + +
+ + 添加 +
@@ -235,12 +256,32 @@ - - - - - + + + {{ showCustomProtocolInput ? '取消' : '+ 自定义' }} + +
+ + 添加 +
@@ -358,12 +399,32 @@ - - - - - + + + {{ showCustomProtocolInput ? '取消' : '+ 自定义' }} + +
+ + 添加 +
@@ -418,6 +479,46 @@ import { import { match } from 'assert'; import { el } from 'element-plus/es/locale'; +// 全局协议选项数组 +const protocolOptions = ref([ + { label: '全部协议', value: 0 }, + { label: 'ICMP', value: 1 }, + { label: 'IGMP', value: 2}, + { label: 'TCP', value: 6 }, + { label: 'EGP', value: 8 }, + { label: 'IGP', value: 9 }, + { label: 'UDP', value: 17 }, + { label: 'GRE', value: 47 }, + { label: 'ESP', value: 50 }, + { label:"AH", value: 51}, + { label: 'IPv6-ICMP', value: 58}, +]); + +// 自定义协议输入 +const customProtocolInput = ref(''); +const showCustomProtocolInput = ref(false); + +// 添加自定义协议 +const addCustomProtocol = () => { + const value = parseInt(customProtocolInput.value); + if (isNaN(value) || value < 0 || value > 512) { + ElMessage.error('协议号必须在0-512范围内'); + return; + } + + // 检查是否已存在 + const exists = protocolOptions.value.some(item => item.value === value); + if (exists) { + ElMessage.warning('该协议号已存在'); + return; + } + + protocolOptions.value.push({ label: `自定义(${value})`, value }); + customProtocolInput.value = ''; + showCustomProtocolInput.value = false; + ElMessage.success('添加自定义协议成功'); +}; + // VPN策略基础接口定义 interface VPNPolicyBase { name: string; @@ -1090,14 +1191,8 @@ const getDstValue = (policy: VPNPolicy) => { // 获取协议文本 const getProtocolText = (protocol: number) => { - const protocols: {[key: number]: string} = { - 0: '全部', - 1: 'ICMP', - 6: 'TCP', - 17: 'UDP', - 255: '其他' - }; - return protocols[protocol] || '未知'; + const found = protocolOptions.value.find(item => item.value === protocol); + return found ? found.label : '未知'; }; // 格式化时间