refactor(ui): use shared default proxy port in settings cards

- replace inline 8317 defaults with CLIPROXY_DEFAULT_PORT

- keep HTTPS fallback behavior at 443 unchanged
This commit is contained in:
Tam Nhu Tran committed 2026-02-18 03:10:10 +07:00
1 parent a53e6cbd25
commit 5788ddc3b7
3 files changed
+7 -3

No files matched your search

@@ -24,6 +24,7 @@ import { LocalProxyCard } from './local-proxy-card';
import { RemoteProxyCard } from './remote-proxy-card'; import { RemoteProxyCard } from './remote-proxy-card';
import { ProxyStatusWidget } from '@/components/monitoring/proxy-status-widget'; import { ProxyStatusWidget } from '@/components/monitoring/proxy-status-widget';
import { api } from '@/lib/api-client'; import { api } from '@/lib/api-client';
import { CLIPROXY_DEFAULT_PORT } from '@/lib/preset-utils';
/** LocalStorage key for debug mode preference */ /** LocalStorage key for debug mode preference */
const DEBUG_MODE_KEY = 'ccs_debug_mode'; const DEBUG_MODE_KEY = 'ccs_debug_mode';
@@ -165,7 +166,7 @@ export default function ProxySection() {
const portInput = config.remote.port !== undefined ? config.remote.port.toString() : ''; const portInput = config.remote.port !== undefined ? config.remote.port.toString() : '';
const authTokenInput = config.remote.auth_token ?? ''; const authTokenInput = config.remote.auth_token ?? '';
const managementKeyInput = config.remote.management_key ?? ''; const managementKeyInput = config.remote.management_key ?? '';
const localPortInput = (config.local.port ?? 8317).toString(); const localPortInput = (config.local.port ?? CLIPROXY_DEFAULT_PORT).toString();
const displayHost = editedHost ?? hostInput; const displayHost = editedHost ?? hostInput;
const displayPort = editedPort ?? portInput; const displayPort = editedPort ?? portInput;
@@ -5,6 +5,7 @@
import { Switch } from '@/components/ui/switch'; import { Switch } from '@/components/ui/switch';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { CLIPROXY_DEFAULT_PORT } from '@/lib/preset-utils';
import type { CliproxyServerConfig } from '../../types'; import type { CliproxyServerConfig } from '../../types';
interface LocalProxyCardProps { interface LocalProxyCardProps {
@@ -38,7 +39,7 @@ export function LocalProxyCard({
value={displayLocalPort} value={displayLocalPort}
onChange={(e) => setEditedLocalPort(e.target.value)} onChange={(e) => setEditedLocalPort(e.target.value)}
onBlur={onSaveLocalPort} onBlur={onSaveLocalPort}
placeholder="8317" placeholder={`${CLIPROXY_DEFAULT_PORT}`}
className="font-mono max-w-32" className="font-mono max-w-32"
disabled={saving} disabled={saving}
/> />
@@ -13,6 +13,7 @@ import {
SelectValue, SelectValue,
} from '@/components/ui/select'; } from '@/components/ui/select';
import { Cloud, RefreshCw, Wifi, WifiOff, CheckCircle2 } from 'lucide-react'; import { Cloud, RefreshCw, Wifi, WifiOff, CheckCircle2 } from 'lucide-react';
import { CLIPROXY_DEFAULT_PORT } from '@/lib/preset-utils';
import type { CliproxyServerConfig, RemoteProxyStatus } from '../../types'; import type { CliproxyServerConfig, RemoteProxyStatus } from '../../types';
interface RemoteProxyCardProps { interface RemoteProxyCardProps {
@@ -59,7 +60,8 @@ export function RemoteProxyCard({
const remoteConfig = config.remote; const remoteConfig = config.remote;
// HTTP defaults to 8317 (CLIProxyAPI default), HTTPS to 443 (standard SSL) // HTTP defaults to 8317 (CLIProxyAPI default), HTTPS to 443 (standard SSL)
const getDefaultPort = (protocol: 'http' | 'https') => (protocol === 'https' ? 443 : 8317); const getDefaultPort = (protocol: 'http' | 'https') =>
protocol === 'https' ? 443 : CLIPROXY_DEFAULT_PORT;
return ( return (
<div className="space-y-4 p-4 rounded-lg border bg-muted/30"> <div className="space-y-4 p-4 rounded-lg border bg-muted/30">