feat(settings): use webListen URI format for Web API address
- rename webPort field/label to webListen (Web API 监听地址) - seed initial form state from webListen with legacy webPort fallback - save webListen URI string while deriving legacy webPort integer for backend compatibility
This commit is contained in:
+20
-9
@@ -151,6 +151,9 @@ function SettingsForm({
|
||||
...initialConfig,
|
||||
TCPListen: toAddrString(initialConfig.TCPListen),
|
||||
UDPListen: toAddrString(initialConfig.UDPListen),
|
||||
webListen:
|
||||
initialConfig.webListen ??
|
||||
(initialConfig.webPort ? `http://0.0.0.0:${initialConfig.webPort}` : 'http://0.0.0.0:4665'),
|
||||
}))
|
||||
const [tunEnabled, setTunEnabled] = useState<boolean>(() =>
|
||||
initialConfig.enableTUN ??
|
||||
@@ -209,9 +212,19 @@ function SettingsForm({
|
||||
form.denyConnectionBroadcast ??
|
||||
form.denyLineTableBroadcast ??
|
||||
false
|
||||
const webListen = form.webListen?.trim() || 'http://0.0.0.0:4665'
|
||||
let webPort = 4665
|
||||
try {
|
||||
const parsedPort = new URL(webListen).port
|
||||
if (parsedPort) webPort = parseInt(parsedPort, 10)
|
||||
} catch {
|
||||
// Java backend validates the canonical listen address.
|
||||
}
|
||||
|
||||
const updatedConfig: Record<string, unknown> = {
|
||||
...form,
|
||||
webListen,
|
||||
webPort,
|
||||
externalEndpoints: updatedExternalEndpoints,
|
||||
openConnections: updatedExternalEndpoints,
|
||||
autoConnections: updatedAutoConnections,
|
||||
@@ -485,23 +498,21 @@ function SettingsForm({
|
||||
)}
|
||||
|
||||
<Field>
|
||||
<FieldLabel htmlFor="webPort">Web 控制台端口</FieldLabel>
|
||||
<FieldLabel htmlFor="webListen">Web API 监听地址</FieldLabel>
|
||||
<Input
|
||||
id="webPort"
|
||||
type="number"
|
||||
min={1}
|
||||
max={65535}
|
||||
placeholder="4665"
|
||||
value={form.webPort ?? 4665}
|
||||
id="webListen"
|
||||
type="text"
|
||||
placeholder="http://0.0.0.0:4665"
|
||||
value={form.webListen ?? 'http://0.0.0.0:4665'}
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
webPort: parseInt(e.target.value) || 4665,
|
||||
webListen: e.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<FieldDescription>
|
||||
Web API 与前端仪表盘托管监听端口(默认 4665)
|
||||
Web API 与前端仪表盘托管监听地址(默认 http://0.0.0.0:4665)
|
||||
</FieldDescription>
|
||||
</Field>
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export interface KLALBControllerConfig {
|
||||
enableTUN?: boolean
|
||||
TUNName?: string | null
|
||||
webUI?: boolean
|
||||
webListen?: string
|
||||
webPort?: number
|
||||
nogui?: boolean
|
||||
TCPListen?: string
|
||||
|
||||
Reference in New Issue
Block a user