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 : '未知';
};
// 格式化时间