refactor: simplify domain verification logic and update localization

- Removed unnecessary parameters from the domain verification instructions in the CustomDomainCard component.
- Simplified the hostname normalization function by eliminating checks for server-side rendering.
- Updated localization strings to remove references to TXT token requirements for domain binding, streamlining the user experience.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-11-24 19:58:43 +08:00
parent 0b51776899
commit f7956c9a4e
3 changed files with 8 additions and 17 deletions

View File

@@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { LinearBorderPanel } from '~/components/common/LinearBorderPanel'
import { resolveBaseDomain } from '~/modules/auth/utils/domain'
import {
useDeleteTenantDomainMutation,
@@ -18,14 +17,11 @@ import {
import { DomainListItem } from './DomainListItem'
function normalizeHostname(): string {
if (typeof window === 'undefined') {
return ''
}
const { hostname } = window.location
return hostname ?? ''
}
function buildVerificationInstructions(normalizedBase = 'your-domain.com') {
function buildVerificationInstructions() {
return [
{
titleKey: 'settings.domain.steps.txt.title',
@@ -34,7 +30,6 @@ function buildVerificationInstructions(normalizedBase = 'your-domain.com') {
{
titleKey: 'settings.domain.steps.cname.title',
descriptionKey: 'settings.domain.steps.cname.desc',
meta: normalizedBase,
},
{
titleKey: 'settings.domain.steps.verify.title',
@@ -43,7 +38,6 @@ function buildVerificationInstructions(normalizedBase = 'your-domain.com') {
] satisfies {
titleKey: I18nKeys
descriptionKey: I18nKeys
meta?: string
}[]
}
@@ -55,8 +49,8 @@ export function CustomDomainCard() {
const verifyMutation = useVerifyTenantDomainMutation()
const deleteMutation = useDeleteTenantDomainMutation()
const baseDomain = useMemo(() => resolveBaseDomain(normalizeHostname()), [])
const steps = useMemo(() => buildVerificationInstructions(baseDomain), [baseDomain])
const baseDomain = useMemo(normalizeHostname, [])
const steps = useMemo(() => buildVerificationInstructions(), [])
const handleRequest = async () => {
if (!domainInput.trim()) {
@@ -118,10 +112,7 @@ export function CustomDomainCard() {
</span>
<div className="flex-1 space-y-1">
<p className="text-sm font-semibold text-text">{t(step.titleKey)}</p>
<p className="text-text-secondary text-sm">
{t(step.descriptionKey, { base: baseDomain })}
{step.meta ? <code className="ml-2 bg-fill px-2 py-1 text-xs">{step.meta}</code> : null}
</p>
<p className="text-text-secondary text-sm">{t(step.descriptionKey, { base: baseDomain })}</p>
</div>
</m.div>
))}

View File

@@ -510,7 +510,7 @@
"settings.domain.banner.pending": "Pending verification for {{domain}}. DNS changes may take a few minutes to propagate.",
"settings.domain.bound-list.empty": "No custom domains yet. Add one on the left to start verification.",
"settings.domain.bound-list.title": "Bound domains",
"settings.domain.description": "Bind your own domain to serve the gallery under a branded URL. Verification requires the TXT token; after it passes, point a CNAME to {{base}} to route traffic.",
"settings.domain.description": "Bind your own domain to serve the gallery under a branded URL.",
"settings.domain.dns.cname.helper": "Once TXT passes, point your custom domain to this target.",
"settings.domain.dns.cname.title": "CNAME target (after TXT verified)",
"settings.domain.dns.hint.ttl": "300s or provider default",
@@ -855,4 +855,4 @@
"welcome.tenant-restricted.register": "Create a new space",
"welcome.tenant-restricted.request": "Requested host:",
"welcome.tenant-restricted.title": "Space Reserved"
}
}

View File

@@ -509,7 +509,7 @@
"settings.domain.banner.pending": "{{domain}} 正在验证中DNS 生效可能需要几分钟。",
"settings.domain.bound-list.empty": "还没有绑定域名,请在左侧输入后开始验证。",
"settings.domain.bound-list.title": "已绑定域名",
"settings.domain.description": "绑定自己的域名,用品牌地址访问。验证必须通过 TXT Token完成后再将 CNAME 指向 {{base}} 以正式接入。",
"settings.domain.description": "绑定自己的域名,用品牌地址访问。",
"settings.domain.dns.cname.helper": "TXT 验证通过后,将自定义域名指向此目标。",
"settings.domain.dns.cname.title": "CNAME 目标TXT 通过后)",
"settings.domain.dns.hint.ttl": "300 秒或使用默认值",
@@ -847,4 +847,4 @@
"welcome.tenant-restricted.register": "创建新空间",
"welcome.tenant-restricted.request": "请求的主机:",
"welcome.tenant-restricted.title": "空间已被保留"
}
}