refactor: enhance VLESS testseed initialization and button functionality in inbound modal

This commit is contained in:
lolka1333 2025-12-14 12:53:12 +01:00
parent d2201c8fd4
commit c4e9f3d9f5
2 changed files with 35 additions and 6 deletions

View file

@ -73,7 +73,7 @@
<template v-if="inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443')"> <template v-if="inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443')">
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }"> <a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
<a-form-item label="Vision Seed"> <a-form-item label="Vision Seed">
<a-row :gutter="8" v-if="inbound.settings.testseed && inbound.settings.testseed.length >= 4"> <a-row :gutter="8">
<a-col :span="6"> <a-col :span="6">
<a-input-number v-model.number="inbound.settings.testseed[0]" :min="0" :max="9999" :style="{ width: '100%' }" placeholder="900" addon-before="[0]"></a-input-number> <a-input-number v-model.number="inbound.settings.testseed[0]" :min="0" :max="9999" :style="{ width: '100%' }" placeholder="900" addon-before="[0]"></a-input-number>
</a-col> </a-col>
@ -88,10 +88,10 @@
</a-col> </a-col>
</a-row> </a-row>
<a-space :size="8" :style="{ marginTop: '8px' }"> <a-space :size="8" :style="{ marginTop: '8px' }">
<a-button type="primary" @click="inbound.settings.testseed = [Math.floor(Math.random()*1000), Math.floor(Math.random()*1000), Math.floor(Math.random()*1000), Math.floor(Math.random()*1000)]"> <a-button type="primary" @click="setRandomTestseed">
Rand Rand
</a-button> </a-button>
<a-button @click="inbound.settings.testseed = [900, 500, 900, 256]"> <a-button @click="resetTestseed">
Reset Reset
</a-button> </a-button>
</a-space> </a-space>

View file

@ -27,10 +27,16 @@
this.inbound = new Inbound(); this.inbound = new Inbound();
} }
// Ensure testseed is initialized for VLESS protocol with vision flow // Ensure testseed is initialized for VLESS protocol with vision flow
// Use Vue.set to ensure reactivity
if (this.inbound.protocol === Protocols.VLESS && this.inbound.settings && this.inbound.settings.vlesses) { if (this.inbound.protocol === Protocols.VLESS && this.inbound.settings && this.inbound.settings.vlesses) {
const hasVisionFlow = this.inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443'); const hasVisionFlow = this.inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443');
if (hasVisionFlow && (!this.inbound.settings.testseed || !Array.isArray(this.inbound.settings.testseed) || this.inbound.settings.testseed.length < 4)) { if (hasVisionFlow && (!this.inbound.settings.testseed || !Array.isArray(this.inbound.settings.testseed) || this.inbound.settings.testseed.length < 4)) {
this.inbound.settings.testseed = [900, 500, 900, 256]; // Use Vue.set to ensure the array is reactive
if (typeof this.$set === 'function') {
this.$set(this.inbound.settings, 'testseed', [900, 500, 900, 256]);
} else {
this.inbound.settings.testseed = [900, 500, 900, 256];
}
} }
} }
if (dbInbound) { if (dbInbound) {
@ -102,6 +108,18 @@
client.flow = ""; client.flow = "";
}); });
} }
},
// Ensure testseed is always initialized when vision flow is enabled
'inModal.inbound.settings.vlesses': {
handler() {
if (inModal.inbound.protocol === Protocols.VLESS && inModal.inbound.settings && inModal.inbound.settings.vlesses) {
const hasVisionFlow = inModal.inbound.settings.vlesses.some(c => c.flow === 'xtls-rprx-vision' || c.flow === 'xtls-rprx-vision-udp443');
if (hasVisionFlow && (!inModal.inbound.settings.testseed || !Array.isArray(inModal.inbound.settings.testseed) || inModal.inbound.settings.testseed.length < 4)) {
inModal.inbound.settings.testseed = [900, 500, 900, 256];
}
}
},
deep: true
} }
}, },
methods: { methods: {
@ -221,9 +239,20 @@
this.inbound.settings.decryption = 'none'; this.inbound.settings.decryption = 'none';
this.inbound.settings.encryption = 'none'; this.inbound.settings.encryption = 'none';
this.inbound.settings.selectedAuth = undefined; this.inbound.settings.selectedAuth = undefined;
},
setRandomTestseed() {
// Ensure testseed is initialized
if (!inModal.inbound.settings.testseed || !Array.isArray(inModal.inbound.settings.testseed) || inModal.inbound.settings.testseed.length < 4) {
inModal.inbound.settings.testseed = [900, 500, 900, 256];
}
const newSeed = [Math.floor(Math.random()*1000), Math.floor(Math.random()*1000), Math.floor(Math.random()*1000), Math.floor(Math.random()*1000)];
inModal.inbound.settings.testseed = newSeed;
},
resetTestseed() {
// Reset testseed to default values
inModal.inbound.settings.testseed = [900, 500, 900, 256];
} }
}
},
}); });
</script> </script>