From 560e8e71e3808f7f09f716cc616bbf6c35e53d1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com>
Date: Fri, 20 Mar 2026 16:47:57 +0800
Subject: [PATCH] :triangular_flag_on_post: Optimize custom domain UI.
---
site/src/locales/en.json | 1 +
site/src/locales/zh.json | 1 +
.../ProxyFormPage/ProxyFormPage.view.tsx | 49 +++++++++++++++----
.../Proxies/ProxyFormPage/useProxyForm.ts | 31 +++++-------
4 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/site/src/locales/en.json b/site/src/locales/en.json
index 1a50001..43d1de1 100644
--- a/site/src/locales/en.json
+++ b/site/src/locales/en.json
@@ -281,6 +281,7 @@
"customDomainsLabel": "Custom Domains",
"customDomainsPlaceholder": "example.com, www.example.com",
"customDomainsDesc": "Multiple domains separated by commas",
+ "addCustomDomain": "Add Domain",
"subdomain": "Subdomain",
"subdomainPlaceholder": "myapp",
"subdomainDesc": "Subdomain for the proxy",
diff --git a/site/src/locales/zh.json b/site/src/locales/zh.json
index 09ef85a..f539fb9 100644
--- a/site/src/locales/zh.json
+++ b/site/src/locales/zh.json
@@ -281,6 +281,7 @@
"customDomainsLabel": "自定义域名",
"customDomainsPlaceholder": "example.com, www.example.com",
"customDomainsDesc": "多个域名用逗号分隔",
+ "addCustomDomain": "添加域名",
"subdomain": "子域名",
"subdomainPlaceholder": "myapp",
"subdomainDesc": "代理的子域名",
diff --git a/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx b/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx
index 2897a49..9b716da 100644
--- a/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx
+++ b/site/src/pages/Proxies/ProxyFormPage/ProxyFormPage.view.tsx
@@ -58,7 +58,7 @@ interface ProxyFormPageViewProps {
isHttpType: boolean;
isSocks5Plugin: boolean;
mounted: boolean;
- onChange: (field: keyof ProxyFormData, value: string | boolean) => void;
+ onChange: (field: keyof ProxyFormData, value: string | boolean | string[]) => void;
onSubmit: () => void;
onCancel: () => void;
onNavigateToServers: () => void;
@@ -240,15 +240,44 @@ export function ProxyFormPageView({
{isHttpType ? (
<>
- onChange("customDomains", e.target.value)}
- />
-
- {t("proxy.customDomainsDesc")}
-
+
+ {formData.customDomains.map((domain, index) => (
+
+ {
+ const next = [...formData.customDomains];
+ next[index] = e.target.value;
+ onChange("customDomains", next);
+ }}
+ />
+
+
+ ))}
+
+
{
try {
setLoadingServers(true);
- const records = await pb.collection("fh_servers").getFullList({
- sort: "-created",
- fields: "id,serverName,bootStatus,networkStatus",
- });
- const list = records.map((r) => ({
- id: r.id,
- serverName: r.serverName as string,
- bootStatus: (r.bootStatus as string) || "stopped",
- networkStatus: r.networkStatus as ServerOption["networkStatus"],
- }));
+ const res = await apiGet("/api/servers/options");
+ if (!res.ok) throw new Error("Failed to fetch servers");
+ const list: ServerOption[] = await res.json();
setServers(list);
if (list.length > 0 && !isEditing) {
setFormData((prev) => ({ ...prev, serverId: list[0].id }));
@@ -107,7 +101,7 @@ export function useProxyForm() {
localPort: String(record.localPort || ""),
remotePort: String(record.remotePort || ""),
subdomain: (record.subdomain as string) || "",
- customDomains: (record.customDomains as string[] | undefined)?.join(", ") || "",
+ customDomains: (record.customDomains as string[] | undefined) || [],
encryption: (record.transport as Record | undefined)?.use_encryption || false,
compression: (record.transport as Record | undefined)?.use_compression || false,
description: (record.description as string) || "",
@@ -145,7 +139,7 @@ export function useProxyForm() {
setErrors((prev) => ({ ...prev, [field]: error }));
};
- const handleChange = (field: keyof ProxyFormData, value: string | boolean) => {
+ const handleChange = (field: keyof ProxyFormData, value: string | boolean | string[]) => {
setFormData((prev) => {
const next = { ...prev, [field]: value };
if (field === "type" && value !== "tcp" && prev.pluginEnabled && prev.pluginType === "socks5") {
@@ -154,6 +148,9 @@ export function useProxyForm() {
return next;
});
if (typeof value === "string") validateField(field, value);
+ if (Array.isArray(value) && field === "customDomains") {
+ setErrors((prev) => ({ ...prev, customDomains: undefined }));
+ }
};
const validate = (data: ProxyFormData): boolean => {
@@ -178,7 +175,7 @@ export function useProxyForm() {
else if (!REGEX.PORT.test(data.remotePort)) newErrors.remotePort = t("proxy.errorInvalidPort");
}
- if (isHttp && !data.subdomain && !data.customDomains) {
+ if (isHttp && !data.subdomain && data.customDomains.length === 0) {
newErrors.subdomain = t("proxy.errorSubdomainRequired");
}
@@ -205,9 +202,7 @@ export function useProxyForm() {
localPort: formData.localPort,
remotePort: formData.remotePort,
subdomain: formData.subdomain,
- customDomains: formData.customDomains
- ? formData.customDomains.split(",").map((d) => d.trim()).filter(Boolean)
- : [],
+ customDomains: formData.customDomains,
transport: {
use_encryption: formData.encryption,
use_compression: formData.compression,