fix: default flow to vision in client add modals

This commit is contained in:
root 2026-04-26 01:05:09 +08:00
parent 64ceb8343f
commit b47bac3dc6
3 changed files with 69 additions and 2 deletions

View file

@ -0,0 +1,52 @@
Task Record
Date: 2026-04-26
Related Module: client add modals (web/html)
Change Type: Fix
Background
Although backend flow auto-fill was implemented for eligible new clients, the add-client UI still initialized `flow` as empty by default.
This made the feature appear non-functional during client creation.
Changes
Updated UI defaults for new VLESS clients in add dialogs:
- `web/html/modals/client_modal.html`
- In single add flow, when inbound `canEnableTlsFlow()` is true and client flow is empty, default to `xtls-rprx-vision`.
- `web/html/modals/client_bulk_modal.html`
- On modal show, default selected bulk `flow` to `xtls-rprx-vision` when `canEnableTlsFlow()` is true.
- In `newClient(...)` for VLESS, initialize empty flow to `xtls-rprx-vision` under the same condition.
Impact
Affected modules or files.
- `web/html/modals/client_modal.html`
- `web/html/modals/client_bulk_modal.html`
Whether APIs, database, config, build, or compatibility are affected.
- No API contract changes.
- No database schema changes.
- UI behavior change only for default values in eligible flow-required scenarios.
Whether upstream or downstream callers are affected.
- Panel operators adding clients now immediately see expected default flow value.
Verification
List validation commands or checks performed.
- `go test ./web/...`
State the result.
- Passed.
If not verified, explain why.
- No remote runtime interaction was performed in this local environment.
Risks And Follow-Up
Remaining risks.
- Existing browser cache may keep older template assets until refresh/reload.
Recommended follow-up work.
- Verify add-client and bulk-add flows in panel UI for VLESS+TCP+TLS/Reality in deployed environment.

View file

@ -213,13 +213,22 @@
this.flow = "";
this.dbInbound = new DBInbound(dbInbound);
this.inbound = dbInbound.toInbound();
if (this.inbound.canEnableTlsFlow()) {
this.flow = "xtls-rprx-vision";
}
this.delayedStart = false;
this.reset = 0;
},
newClient(protocol) {
switch (protocol) {
case Protocols.VMESS: return new Inbound.VmessSettings.VMESS();
case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
case Protocols.VLESS: {
const client = new Inbound.VLESSSettings.VLESS();
if (clientsBulkModal.inbound?.canEnableTlsFlow() && !client.flow) {
client.flow = "xtls-rprx-vision";
}
return client;
}
case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
case Protocols.SHADOWSOCKS: {
const method = clientsBulkModal.inbound?.settings?.method || '';

View file

@ -73,7 +73,13 @@
addClient(inbound, clients) {
switch (inbound.protocol) {
case Protocols.VMESS: return clients.push(new Inbound.VmessSettings.VMESS());
case Protocols.VLESS: return clients.push(new Inbound.VLESSSettings.VLESS());
case Protocols.VLESS: {
const client = new Inbound.VLESSSettings.VLESS();
if (inbound.canEnableTlsFlow() && !client.flow) {
client.flow = "xtls-rprx-vision";
}
return clients.push(client);
}
case Protocols.TROJAN: return clients.push(new Inbound.TrojanSettings.Trojan());
case Protocols.SHADOWSOCKS: return clients.push(new Inbound.ShadowsocksSettings.Shadowsocks(inbound.settings.method, RandomUtil.randomShadowsocksPassword(inbound.settings.method)));
default: return null;