Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(cloud): streamline domain verification and management

Timothy Yin3b86721a533c
diff --git a/apps/cloud/app/assets/cloud.css b/apps/cloud/app/assets/cloud.css
index 5b538516..ac71e613 100644
--- a/apps/cloud/app/assets/cloud.css
+++ b/apps/cloud/app/assets/cloud.css
@@ -1404,7 +1404,8 @@
/* Keep native pinch zoom available; 16px controls avoid iOS focus magnification. */
@media (max-width: 700px), (pointer: coarse) {
- .cf-root :is(input, select, textarea) {
+ .cf-root :is(input, select, textarea),
+ .cf-cloud-body :is(input, select, textarea) {
font-size: 16px;
}
}
@@ -2474,3 +2475,306 @@
min-width: 0;
font-size: 12px;
}
+
+.cf-domain-section-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+}
+.cf-domain-section-heading h2 {
+ font-size: 14px;
+ font-weight: 600;
+}
+.cf-domain-default-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 12px 20px;
+ min-width: 0;
+}
+.cf-domain-default-row > code {
+ overflow-wrap: anywhere;
+ font-size: 13px;
+}
+.cf-domain-default-footer {
+ border-top: 1px solid var(--border);
+ padding: 10px 20px;
+}
+.cf-domain-custom-section {
+ display: grid;
+ gap: 12px;
+}
+.cf-domain-empty {
+ display: grid;
+ justify-items: center;
+ gap: 6px;
+ padding: 32px 20px;
+ text-align: center;
+ border: 1px dashed var(--border);
+ border-radius: var(--radius);
+ color: var(--muted-foreground);
+}
+.cf-domain-empty h3 {
+ color: var(--foreground);
+ font-size: 14px;
+ font-weight: 550;
+}
+.cf-domain-card {
+ min-width: 0;
+ background: var(--card);
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
+ overflow: hidden;
+}
+.cf-domain-card-header {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 16px 18px 6px;
+}
+.cf-domain-icon {
+ flex-shrink: 0;
+ color: var(--muted-foreground);
+}
+.cf-domain-card-identity {
+ min-width: 0;
+ flex: 1;
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+.cf-domain-card-identity h3 {
+ font-size: 13px;
+ font-weight: 600;
+ overflow-wrap: anywhere;
+}
+.cf-domain-primary {
+ color: var(--muted-foreground);
+ font-size: 11px;
+}
+.cf-domain-guidance {
+ padding: 0 18px;
+}
+.cf-domain-card-toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ flex-wrap: wrap;
+ padding: 10px 12px;
+}
+.cf-domain-inline-actions {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 6px;
+}
+.cf-domain-details {
+ display: grid;
+ gap: 14px;
+ border-top: 1px solid var(--border);
+ padding: 18px;
+ min-width: 0;
+}
+.cf-domain-steps {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ gap: 10px;
+}
+.cf-domain-steps li {
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ font-size: 11px;
+ color: var(--muted-foreground);
+}
+.cf-domain-step-number {
+ display: flex;
+ width: 20px;
+ height: 20px;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+ border: 1px solid var(--border);
+ border-radius: 50%;
+ font-size: 10px;
+}
+.cf-domain-steps .is-complete {
+ color: var(--primary);
+}
+.cf-domain-steps .is-complete .cf-domain-step-number {
+ background: var(--primary);
+ color: var(--primary-foreground);
+ border-color: var(--primary);
+}
+.cf-domain-steps .is-current {
+ color: var(--foreground);
+ font-weight: 600;
+}
+.cf-domain-steps .is-current .cf-domain-step-number {
+ border-color: var(--primary);
+}
+.cf-domain-dns-record {
+ display: grid;
+ grid-template-columns: 65px minmax(0, 1fr);
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ overflow: hidden;
+ font-size: 12px;
+}
+.cf-domain-dns-record > div {
+ display: grid;
+ align-content: start;
+ gap: 5px;
+ padding: 10px 12px;
+ min-width: 0;
+}
+.cf-domain-dns-record > div > span {
+ font-size: 11px;
+ color: var(--muted-foreground);
+}
+.cf-domain-dns-record code {
+ overflow-wrap: anywhere;
+ white-space: normal;
+ font-size: 12px;
+}
+.cf-domain-dns-record .cf-domain-record-value {
+ position: relative;
+ grid-column: 1/-1;
+ padding-right: 42px;
+ border-top: 1px solid var(--border);
+ background: var(--background);
+}
+.cf-domain-record-value .cf-button {
+ position: absolute;
+ top: 12px;
+ right: 8px;
+}
+.cf-domain-verification-status {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ flex-wrap: wrap;
+ color: var(--muted-foreground);
+ font-size: 11px;
+}
+.cf-domain-verification-status > span:last-child {
+ margin-left: auto;
+}
+.cf-domain-technical {
+ min-width: 0;
+ color: var(--muted-foreground);
+ font-size: 11px;
+}
+.cf-domain-technical summary {
+ cursor: pointer;
+ width: fit-content;
+ padding: 4px 0;
+}
+.cf-domain-technical dl {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 12px;
+ margin: 8px 0 0;
+}
+.cf-domain-technical dd {
+ margin: 3px 0 0;
+ overflow-wrap: anywhere;
+ color: var(--foreground);
+}
+.cf-domain-card > .cf-notice {
+ margin: 0 18px 14px;
+}
+.cf-domain-modal-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ margin-top: 8px;
+}
+.cf-domain-slug-field {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+}
+.cf-domain-slug-field input {
+ min-width: 0;
+}
+.cf-domain-slug-field > span {
+ font-size: 12px;
+ color: var(--muted-foreground);
+ overflow-wrap: anywhere;
+}
+@media (max-width: 480px) {
+ .cf-domain-section-heading {
+ align-items: flex-start;
+ flex-wrap: wrap;
+ gap: 10px;
+ }
+ .cf-domain-card-header {
+ flex-wrap: wrap;
+ padding: 14px 14px 6px;
+ }
+ .cf-domain-card-identity {
+ flex-basis: calc(100% - 32px);
+ }
+ .cf-domain-card-header > .cf-badge {
+ margin-left: 28px;
+ }
+ .cf-domain-card-header > .cf-button {
+ margin-left: auto;
+ }
+ .cf-domain-guidance {
+ padding: 0 14px;
+ }
+ .cf-domain-details {
+ padding: 14px;
+ }
+ .cf-domain-steps {
+ gap: 7px;
+ }
+ .cf-domain-steps li {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 5px;
+ }
+ .cf-domain-technical dl {
+ grid-template-columns: 1fr;
+ gap: 7px;
+ }
+ .cf-domain-verification-status > span:last-child {
+ flex-basis: 100%;
+ margin-left: 0;
+ }
+ .cf-domain-default-row {
+ padding: 12px 16px;
+ flex-wrap: wrap;
+ }
+ .cf-domain-default-row > code {
+ flex: 1;
+ min-width: 0;
+ }
+}
+
+.cf-domain-address {
+ flex: 1;
+ min-width: 0;
+ overflow-wrap: anywhere;
+ font-size: 13px;
+}
+a.cf-domain-address:hover {
+ text-decoration: underline;
+}
+@media (max-width: 480px) {
+ .cf-domain-default-row > .cf-button {
+ width: 28px;
+ height: 28px;
+ padding: 4px;
+ flex-shrink: 0;
+ }
+}
diff --git a/apps/cloud/app/components/CloudDomainCard.vue b/apps/cloud/app/components/CloudDomainCard.vue
new file mode 100644
index 00000000..0c42b646
--- /dev/null
+++ b/apps/cloud/app/components/CloudDomainCard.vue
@@ -0,0 +1,335 @@
+<script setup lang="ts">
+import type { CustomDomain } from '@chronoframe/contracts/domains'
+import {
+ Check,
+ ChevronDown,
+ Copy,
+ ExternalLink,
+ Globe,
+ MoreHorizontal,
+ RefreshCw,
+ ShieldCheck,
+} from 'lucide-vue-next'
+import {
+ DropdownMenuRoot,
+ DropdownMenuTrigger,
+ DropdownMenuPortal,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+} from 'reka-ui'
+const props = defineProps<{
+ domain: CustomDomain
+ admin: boolean
+ enabled: boolean
+ published: boolean
+ busy: boolean
+ retrySeconds: number
+ expanded: boolean
+}>()
+const emit = defineEmits<{
+ action: [domain: CustomDomain, operation: string, value?: boolean]
+ copy: [value: string]
+ remove: [domain: CustomDomain]
+}>()
+const { t, te, locale } = useI18n()
+const open = ref(props.expanded || props.domain.status === 'pending')
+watch(
+ () => props.expanded,
+ (value) => {
+ if (value) open.value = true
+ },
+)
+const dnsReady = computed(() => props.domain.dnsStatus === 'ready')
+const certificateReady = computed(
+ () =>
+ props.domain.hostnameStatus === 'active' &&
+ props.domain.sslStatus === 'active',
+)
+const steps = computed(() => [
+ { label: t('cloud.domainFlow.dnsStep'), complete: dnsReady.value },
+ {
+ label: t('cloud.domainFlow.certificateStep'),
+ complete: dnsReady.value && certificateReady.value,
+ },
+ {
+ label: t('cloud.domainFlow.readyStep'),
+ complete: props.domain.status === 'active',
+ },
+])
+const currentStep = computed(() => steps.value.findIndex((s) => !s.complete))
+const canVerify = computed(
+ () =>
+ props.enabled &&
+ !props.busy &&
+ props.retrySeconds === 0 &&
+ !['deleting', 'paused', 'expired'].includes(props.domain.status),
+)
+const statusLabel = computed(() =>
+ props.domain.status !== 'pending'
+ ? t('cloud.domains.states.' + props.domain.status)
+ : t(
+ !dnsReady.value
+ ? 'cloud.domainFlow.needsDns'
+ : !certificateReady.value
+ ? 'cloud.domainFlow.issuingCertificate'
+ : 'cloud.domainFlow.preparingRoute',
+ ),
+)
+const guidance = computed(() =>
+ t(
+ props.domain.status === 'deleting'
+ ? 'cloud.domainFlow.removingHelp'
+ : props.domain.status === 'expired'
+ ? 'cloud.domainFlow.expiredHelp'
+ : props.domain.status === 'active'
+ ? 'cloud.domainFlow.connectedHelp'
+ : props.domain.status === 'paused'
+ ? 'cloud.domainFlow.pausedHelp'
+ : !dnsReady.value
+ ? 'cloud.domainFlow.dnsHelp'
+ : !certificateReady.value
+ ? 'cloud.domainFlow.certificateHelp'
+ : 'cloud.domainFlow.routeHelp',
+ ),
+)
+</script>
+<template>
+ <article
+ class="cf-domain-card"
+ :id="'domain-' + domain.generation"
+ >
+ <div class="cf-domain-card-header">
+ <Globe
+ :size="18"
+ class="cf-domain-icon"
+ aria-hidden="true"
+ />
+ <div class="cf-domain-card-identity">
+ <h3>{{ domain.hostname }}</h3>
+ <span
+ v-if="domain.primary"
+ class="cf-domain-primary"
+ >{{ t('cloud.domains.primary') }}</span
+ >
+ </div>
+ <CloudBadge :tone="domain.status === 'active' ? 'success' : 'neutral'">{{
+ statusLabel
+ }}</CloudBadge>
+ <DropdownMenuRoot v-if="admin && domain.status !== 'deleting'"
+ ><DropdownMenuTrigger as-child
+ ><CloudButton
+ size="icon"
+ variant="ghost"
+ :aria-label="
+ t('cloud.domainFlow.actions', { hostname: domain.hostname })
+ "
+ :disabled="busy"
+ ><MoreHorizontal :size="17" /></CloudButton
+ ></DropdownMenuTrigger>
+ <DropdownMenuPortal
+ ><DropdownMenuContent
+ class="cf-account-menu"
+ align="end"
+ :side-offset="6"
+ :collision-padding="12"
+ >
+ <template v-if="domain.status === 'active'">
+ <DropdownMenuItem
+ v-if="!domain.primary"
+ @select="emit('action', domain, 'primary')"
+ >{{ t('cloud.domains.makePrimary') }}</DropdownMenuItem
+ >
+ <DropdownMenuItem
+ v-if="domain.primary"
+ @select="emit('action', domain, 'redirects', !domain.redirects)"
+ >{{
+ t(
+ domain.redirects
+ ? 'cloud.domains.disableRedirects'
+ : 'cloud.domains.enableRedirects',
+ )
+ }}</DropdownMenuItem
+ >
+ <DropdownMenuSeparator class="cf-menu-separator" />
+ </template>
+ <DropdownMenuItem
+ v-if="!['deleting', 'expired'].includes(domain.status)"
+ :disabled="domain.status === 'paused' && !enabled"
+ @select="
+ emit(
+ 'action',
+ domain,
+ domain.status === 'paused' ? 'resume' : 'pause',
+ )
+ "
+ >{{
+ t(
+ domain.status === 'paused'
+ ? 'cloud.domains.resume'
+ : 'cloud.domains.pause',
+ )
+ }}</DropdownMenuItem
+ >
+ <DropdownMenuItem
+ :disabled="domain.status === 'deleting'"
+ @select="emit('remove', domain)"
+ >{{ t('cloud.domains.remove') }}</DropdownMenuItem
+ >
+ </DropdownMenuContent></DropdownMenuPortal
+ >
+ </DropdownMenuRoot>
+ </div>
+ <p class="cf-field-hint cf-domain-guidance">{{ guidance }}</p>
+ <div class="cf-domain-card-toolbar">
+ <CloudButton
+ variant="ghost"
+ size="sm"
+ :aria-expanded="open"
+ @click="open = !open"
+ >{{
+ t(open ? 'cloud.domainFlow.hideDetails' : 'cloud.domainFlow.details')
+ }}<ChevronDown
+ :size="14"
+ :class="{ 'rotate-180': open }"
+ /></CloudButton>
+ <div class="cf-domain-inline-actions">
+ <CloudButton
+ v-if="domain.status === 'active' && published"
+ as-child
+ size="sm"
+ variant="ghost"
+ ><a
+ :href="'https://' + domain.hostname"
+ target="_blank"
+ rel="noopener noreferrer"
+ >{{ t('cloud.messages.viewSite') }}<ExternalLink :size="13" /></a
+ ></CloudButton>
+ <CloudButton
+ v-if="
+ admin && !['paused', 'deleting', 'expired'].includes(domain.status)
+ "
+ size="sm"
+ variant="secondary"
+ :disabled="!canVerify"
+ @click="emit('action', domain, 'check')"
+ ><RefreshCw
+ :size="13"
+ :class="{ 'cf-spin': busy }"
+ />{{
+ t(
+ retrySeconds > 0
+ ? 'cloud.domainFlow.retryIn'
+ : 'cloud.domains.check',
+ { seconds: retrySeconds },
+ )
+ }}</CloudButton
+ >
+ </div>
+ </div>
+ <div
+ v-if="open"
+ class="cf-domain-details"
+ >
+ <ol
+ class="cf-domain-steps"
+ :aria-label="t('cloud.domainFlow.progress')"
+ >
+ <li
+ v-for="(step, index) in steps"
+ :key="index"
+ :class="{
+ 'is-complete': step.complete,
+ 'is-current': index === currentStep,
+ }"
+ :aria-current="index === currentStep ? 'step' : undefined"
+ >
+ <span class="cf-domain-step-number"
+ ><Check
+ v-if="step.complete"
+ :size="12"
+ /><template v-else>{{ index + 1 }}</template></span
+ ><span>{{ step.label }}</span>
+ </li>
+ </ol>
+ <div class="cf-domain-dns-record">
+ <div>
+ <span>{{ t('cloud.domainFlow.recordType') }}</span
+ ><strong>CNAME</strong>
+ </div>
+ <div>
+ <span>{{ t('cloud.domainFlow.recordName') }}</span
+ ><code>{{ domain.hostname }}</code>
+ </div>
+ <div class="cf-domain-record-value">
+ <span>{{ t('cloud.domainFlow.recordValue') }}</span
+ ><code>{{ domain.cnameTarget }}</code
+ ><CloudButton
+ size="icon"
+ variant="ghost"
+ :aria-label="t('cloud.domains.copyTarget')"
+ @click="emit('copy', domain.cnameTarget)"
+ ><Copy :size="14"
+ /></CloudButton>
+ </div>
+ </div>
+ <p class="cf-field-hint">{{ t('cloud.domains.dnsOnly') }}</p>
+ <div class="cf-domain-verification-status">
+ <ShieldCheck :size="15" /><span>{{
+ t(
+ domain.status === 'paused' || !enabled
+ ? 'cloud.domainFlow.checksPaused'
+ : 'cloud.domainFlow.automaticChecks',
+ )
+ }}</span
+ ><span v-if="domain.checkedAt"
+ ><ClientOnly
+ >{{
+ t('cloud.domains.checked', {
+ time: new Date(domain.checkedAt).toLocaleString(locale),
+ })
+ }}<template #fallback>{{
+ t('cloud.domains.checked', {
+ time: new Date(domain.checkedAt).toISOString(),
+ })
+ }}</template></ClientOnly
+ ></span
+ >
+ </div>
+ <details class="cf-domain-technical">
+ <summary>{{ t('cloud.domainFlow.technical') }}</summary>
+ <dl>
+ <div>
+ <dt>{{ t('cloud.domains.dns') }}</dt>
+ <dd>{{ t('cloud.domains.dnsStates.' + domain.dnsStatus) }}</dd>
+ </div>
+ <div>
+ <dt>{{ t('cloud.domains.provider') }}</dt>
+ <dd>
+ <code>{{ domain.hostnameStatus }}</code>
+ </dd>
+ </div>
+ <div>
+ <dt>{{ t('cloud.domains.certificate') }}</dt>
+ <dd>
+ <code>{{ domain.sslStatus }}</code>
+ </dd>
+ </div>
+ </dl>
+ </details>
+ </div>
+ <p
+ v-if="domain.error"
+ class="cf-notice cf-notice-error"
+ role="alert"
+ >
+ {{
+ t(
+ te('cloud.domains.errors.' + domain.error)
+ ? 'cloud.domains.errors.' + domain.error
+ : 'cloud.domains.failed',
+ )
+ }}
+ </p>
+ </article>
+</template>
diff --git a/apps/cloud/app/pages/sites/[siteId]/domains.vue b/apps/cloud/app/pages/sites/[siteId]/domains.vue
index 3257e355..93fadfe9 100644
--- a/apps/cloud/app/pages/sites/[siteId]/domains.vue
+++ b/apps/cloud/app/pages/sites/[siteId]/domains.vue
@@ -3,8 +3,8 @@ import type {
CustomDomain,
DomainOverview,
} from '@chronoframe/contracts/domains'
-import { Copy, Globe, RefreshCw, Plus, ExternalLink } from 'lucide-vue-next'
-const { t, te, locale } = useI18n()
+import { Copy, Globe, RefreshCw, Plus, Pencil } from 'lucide-vue-next'
+const { t } = useI18n()
definePageMeta({ layout: 'portal' })
useSeoMeta({
title: () => t('cloud.messages.domainsChronoframeCloud'),
@@ -25,6 +25,10 @@ const data = ref(result.value),
busy = ref(false),
hostname = ref(''),
slug = ref('')
+const addOpen = ref(false),
+ renameOpen = ref(false),
+ removal = shallowRef<CustomDomain | null>(null),
+ expandedHost = ref('')
watch(result, (value) => {
if (value) data.value = value
})
@@ -33,7 +37,7 @@ const { data: settings, refresh: refreshSettings } = await useFetch<{
}>(base + '/settings')
slug.value = settings.value?.site.slug ?? ''
let mounted = true
-const clock = ref(Date.now())
+const clock = useState<number>(base + '/domains/clock', () => Date.now())
let timer: ReturnType<typeof setInterval> | undefined,
poll: ReturnType<typeof setInterval> | undefined
onMounted(() => {
@@ -45,9 +49,8 @@ onMounted(() => {
mounted &&
document.visibilityState === 'visible' &&
data.value?.enabled &&
- data.value.domains.some((d) =>
- ['pending', 'deleting'].includes(d.status),
- ) &&
+ data.value.domains.length > 0 &&
+ status.value !== 'pending' &&
!busy.value
)
void refresh()
@@ -58,21 +61,48 @@ onBeforeUnmount(() => {
if (timer) clearInterval(timer)
if (poll) clearInterval(poll)
})
-const canCheck = (domain: CustomDomain) =>
- domain.nextCheckAt <= clock.value + 30000
+function beginRename() {
+ slug.value = settings.value?.site.slug ?? ''
+ notice.value = ''
+ failure.value = false
+ renameOpen.value = true
+}
+function beginAdd() {
+ notice.value = ''
+ failure.value = false
+ addOpen.value = true
+}
+function beginRemove(domain: CustomDomain) {
+ notice.value = ''
+ failure.value = false
+ removal.value = domain
+}
+async function refreshAll() {
+ await Promise.all([refresh(), refreshSettings()])
+}
async function run(body: Record<string, unknown>) {
if (busy.value || !data.value?.admin) return
busy.value = true
notice.value = ''
failure.value = false
try {
- await $fetch(base + '/domains', { method: 'POST', body })
- if (!mounted) return
+ const response = await $fetch<{ domain?: CustomDomain }>(
+ base + '/domains',
+ { method: 'POST', body },
+ )
+ if (!mounted) return false
await Promise.all([refresh(), refreshSettings()])
notice.value = t('cloud.domains.saved')
- if (body.action === 'add') hostname.value = ''
+ if (body.action === 'add') {
+ expandedHost.value = response.domain?.hostname ?? String(body.hostname)
+ hostname.value = ''
+ addOpen.value = false
+ }
+ if (body.action === 'rename') renameOpen.value = false
+ if (body.action === 'delete') removal.value = null
+ return true
} catch (cause) {
- if (!mounted) return
+ if (!mounted) return false
const code = (cause as { data?: { data?: { code?: string } } }).data?.data
?.code
failure.value = true
@@ -94,6 +124,7 @@ async function run(body: Record<string, unknown>) {
'domain_provider_missing',
'domain_routing_unavailable',
]
+ if (code === 'domain_changed') await refreshAll()
notice.value = t(
code && allowed.includes(code)
? 'cloud.domains.errors.' + code
@@ -104,24 +135,21 @@ async function run(body: Record<string, unknown>) {
}
}
async function action(domain: CustomDomain, operation: string, value = false) {
- if (
- operation === 'delete' &&
- !window.confirm(
- t('cloud.domains.removeConfirm', { hostname: domain.hostname }),
- )
- )
- return
+ const current =
+ data.value?.domains.find(
+ (d) =>
+ d.hostname === domain.hostname && d.generation === domain.generation,
+ ) ?? domain
await run({
action: operation,
hostname: domain.hostname,
generation: domain.generation,
- revision: domain.revision,
+ revision: current.revision,
value,
})
}
async function rename() {
- if (!settings.value || !window.confirm(t('cloud.domains.renameConfirm')))
- return
+ if (!settings.value) return
await run({
action: 'rename',
slug: slug.value,
@@ -140,7 +168,7 @@ async function copy(value: string) {
}
</script>
<template>
- <div class="cf-site-settings-stack">
+ <div class="cf-site-settings-stack cf-domain-page">
<div class="cf-page-heading">
<div>
<h1 class="cf-page-title">{{ t('cloud.messages.domains') }}</h1>
@@ -152,7 +180,7 @@ async function copy(value: string) {
variant="ghost"
size="sm"
:disabled="busy || status === 'pending'"
- @click="refresh()"
+ @click="refreshAll()"
><RefreshCw :size="15" />{{ t('cloud.domains.refresh') }}</CloudButton
>
</div>
@@ -164,12 +192,12 @@ async function copy(value: string) {
{{ t('cloud.domains.loadFailed')
}}<CloudButton
variant="ghost"
- @click="refresh()"
+ @click="refreshAll()"
>{{ t('cloud.messages.retry') }}</CloudButton
>
</p>
<p
- v-if="notice"
+ v-if="notice && !addOpen && !renameOpen && !removal"
:role="failure ? 'alert' : 'status'"
class="cf-notice"
:class="{ 'cf-notice-error': failure }"
@@ -178,326 +206,273 @@ async function copy(value: string) {
</p>
<template v-if="data">
<CloudCard
- ><div class="cf-panel-heading">
- <h2>{{ t('cloud.messages.defaultSubdomain') }}</h2>
- <p>{{ t('cloud.domains.defaultHelp') }}</p>
- </div>
- <div class="cf-panel-body space-y-3">
- <template v-if="data.defaultHostname"
- ><p class="cf-address-preview">
- https://{{ data.defaultHostname }}
- </p>
- <div class="flex flex-wrap gap-2">
- <CloudButton
- variant="secondary"
- size="sm"
- @click="copy('https://' + data.defaultHostname)"
- ><Copy :size="14" />{{
- t('cloud.messages.copyAddress')
- }}</CloudButton
- ><CloudButton
- v-if="site.published && data.defaultReady"
- as-child
- variant="ghost"
- size="sm"
- ><a
- :href="'https://' + data.defaultHostname"
- target="_blank"
- rel="noopener noreferrer"
- ><ExternalLink :size="14" />{{
- t('cloud.messages.viewSite')
- }}</a
- ></CloudButton
- >
- </div></template
+ ><div class="cf-panel-heading cf-domain-section-heading">
+ <div>
+ <h2>{{ t('cloud.messages.defaultSubdomain') }}</h2>
+ <p>{{ t('cloud.domains.defaultHelp') }}</p>
+ </div>
+ <CloudButton
+ v-if="data.admin"
+ variant="ghost"
+ size="sm"
+ :disabled="busy || !data.defaultReady"
+ @click="beginRename"
+ ><Pencil :size="13" />{{
+ t('cloud.domains.changeAddress')
+ }}</CloudButton
>
- <p
- v-else
- class="cf-notice cf-notice-error"
+ </div>
+ <div class="cf-domain-default-row">
+ <Globe :size="18" />
+ <a
+ v-if="data.defaultHostname && data.defaultReady && site.published"
+ class="cf-domain-address"
+ :href="'https://' + data.defaultHostname"
+ target="_blank"
+ rel="noopener noreferrer"
+ ><code>{{ data.defaultHostname }}</code></a
>
- {{ t('cloud.domains.defaultConflict') }}
- </p>
- <form
- v-if="data.admin"
- class="space-y-2"
- @submit.prevent="rename"
+ <code
+ v-else-if="data.defaultHostname"
+ class="cf-domain-address"
+ >{{ data.defaultHostname }}</code
>
- <label
- class="cf-field-label"
- for="site-domain-slug"
- >{{ t('cloud.domains.changeAddress') }}</label
- ><CloudInput
- id="site-domain-slug"
- v-model="slug"
- autocomplete="off"
- :disabled="busy"
- minlength="3"
- maxlength="40"
- required
- />
- <p class="cf-field-hint">
- {{ t('cloud.domains.slugHint', { base: data.baseDomain }) }}
- </p>
- <CloudButton
- type="submit"
- size="sm"
- variant="secondary"
- :disabled="
- busy || !data.defaultReady || slug === settings?.site.slug
- "
- >{{ t('cloud.messages.saveChanges') }}</CloudButton
- >
- </form>
+ <span v-else>{{ t('cloud.domains.defaultConflict') }}</span>
+ <CloudButton
+ v-if="data.defaultHostname"
+ variant="ghost"
+ size="icon"
+ :aria-label="t('cloud.messages.copyAddress')"
+ @click="copy('https://' + data.defaultHostname)"
+ ><Copy :size="14"
+ /></CloudButton>
+ </div>
+ <div
+ v-if="!data.defaultReady || data.domains.some((d) => d.primary)"
+ class="cf-domain-default-footer"
+ >
<p
v-if="!data.defaultReady"
- class="cf-notice"
+ class="cf-field-hint"
>
{{ t('cloud.domains.routingPending') }}
</p>
<CloudButton
v-if="data.admin && data.domains.some((d) => d.primary)"
- variant="secondary"
+ variant="ghost"
size="sm"
:disabled="busy"
@click="run({ action: 'default' })"
>{{ t('cloud.domains.useDefault') }}</CloudButton
>
- <p class="cf-field-hint">{{ t('cloud.domains.aliasPolicy') }}</p>
- <p
- v-if="data.legacyHostname"
- class="cf-field-hint break-all"
- >
- {{ t('cloud.domains.legacy', { hostname: data.legacyHostname }) }}
- </p>
- </div></CloudCard
- >
- <CloudCard
- ><div class="cf-panel-heading">
- <h2>{{ t('cloud.messages.customDomains') }}</h2>
- <p>{{ t('cloud.domains.intro') }}</p>
</div>
- <div class="cf-panel-body space-y-4">
- <p
- v-if="!data.enabled"
- class="cf-notice"
+ </CloudCard>
+ <section class="cf-domain-custom-section">
+ <div class="cf-domain-section-heading">
+ <div>
+ <h2>{{ t('cloud.messages.customDomains') }}</h2>
+ <p class="cf-field-hint">{{ t('cloud.domainFlow.customHelp') }}</p>
+ </div>
+ <CloudButton
+ v-if="data.admin"
+ size="sm"
+ :disabled="busy || !data.enabled"
+ @click="beginAdd"
+ ><Plus :size="14" />{{ t('cloud.domains.add') }}</CloudButton
>
- {{ t('cloud.domains.disabled') }}
- </p>
+ </div>
+ <p
+ v-if="!data.enabled"
+ class="cf-notice"
+ >
+ {{ t('cloud.domains.disabled') }}
+ </p>
+ <p
+ v-else-if="!data.routingReady"
+ class="cf-notice"
+ >
+ {{ t('cloud.domains.routingPending') }}
+ </p>
+ <div
+ v-if="!data.domains.length"
+ class="cf-domain-empty"
+ >
+ <Globe :size="24" />
+ <h3>{{ t('cloud.domains.empty') }}</h3>
+ <p>{{ t('cloud.domainFlow.emptyHelp') }}</p>
+ </div>
+ <CloudDomainCard
+ v-for="domain in data.domains"
+ :key="domain.hostname + domain.generation"
+ :domain="domain"
+ :admin="data.admin"
+ :published="site.published"
+ :enabled="data.enabled"
+ :busy="busy"
+ :retry-seconds="
+ Math.max(0, Math.ceil((domain.nextCheckAt - 30000 - clock) / 1000))
+ "
+ :expanded="expandedHost === domain.hostname"
+ @copy="copy"
+ @action="action"
+ @remove="beginRemove"
+ />
+ <p
+ v-if="!data.admin"
+ class="cf-field-hint"
+ >
+ {{
+ t(
+ 'cloud.messages.onlyWorkspaceAdministratorsCanChangeTheseSettings',
+ )
+ }}
+ </p>
+ </section>
+ <details
+ v-if="data.legacyHostname"
+ class="cf-domain-technical"
+ >
+ <summary>{{ t('cloud.domainFlow.previousAddress') }}</summary>
+ <p class="cf-field-hint">
+ {{ t('cloud.domains.legacy', { hostname: data.legacyHostname }) }}
+ </p>
+ </details>
+ </template>
+ <UModal
+ v-model:open="addOpen"
+ :title="t('cloud.domains.add')"
+ :description="t('cloud.domainFlow.addDescription')"
+ :dismissible="!busy"
+ ><template #body
+ ><form
+ class="cf-form"
+ @submit.prevent="run({ action: 'add', hostname })"
+ >
+ <label
+ class="cf-field-label"
+ for="custom-domain"
+ >{{ t('cloud.domains.hostname') }}</label
+ ><CloudInput
+ id="custom-domain"
+ v-model="hostname"
+ :disabled="busy"
+ placeholder="photos.example.com"
+ autocomplete="off"
+ autocapitalize="none"
+ spellcheck="false"
+ maxlength="253"
+ required
+ />
+ <p class="cf-field-hint">{{ t('cloud.domains.addHint') }}</p>
<p
- v-else-if="!data.routingReady"
- class="cf-notice"
+ v-if="failure"
+ role="alert"
+ class="cf-notice cf-notice-error"
>
- {{ t('cloud.domains.routingPending') }}
+ {{ notice }}
</p>
- <form
- v-if="data.admin"
- class="space-y-2"
- @submit.prevent="run({ action: 'add', hostname })"
- >
- <label
- class="cf-field-label"
- for="custom-domain"
- >{{ t('cloud.domains.hostname') }}</label
- ><CloudInput
- id="custom-domain"
- v-model="hostname"
- :disabled="busy || !data.enabled"
- placeholder="photos.example.com"
- autocomplete="off"
- autocapitalize="none"
- spellcheck="false"
- maxlength="253"
- required
- />
- <p class="cf-field-hint">{{ t('cloud.domains.addHint') }}</p>
+ <div class="cf-domain-modal-actions">
<CloudButton
+ variant="secondary"
+ :disabled="busy"
+ @click="addOpen = false"
+ >{{ t('cloud.messages.cancel') }}</CloudButton
+ ><CloudButton
type="submit"
- size="sm"
- :disabled="busy || !data.enabled || !hostname.trim()"
- ><Plus :size="14" />{{ t('cloud.domains.add') }}</CloudButton
+ :disabled="busy || !hostname.trim()"
+ :loading="busy"
+ >{{ t('cloud.domainFlow.continue') }}</CloudButton
>
- </form>
- <p
- v-if="!data.admin"
- class="cf-field-hint"
+ </div>
+ </form></template
+ ></UModal
+ >
+ <UModal
+ v-model:open="renameOpen"
+ :title="t('cloud.domains.changeAddress')"
+ :description="t('cloud.domains.aliasPolicy')"
+ :dismissible="!busy"
+ ><template #body
+ ><form
+ class="cf-form"
+ @submit.prevent="rename"
+ >
+ <label
+ class="cf-field-label"
+ for="site-domain-slug"
+ >{{ t('cloud.domains.changeAddress') }}</label
>
- {{
- t(
- 'cloud.messages.onlyWorkspaceAdministratorsCanChangeTheseSettings',
- )
- }}
- </p>
+ <div class="cf-domain-slug-field">
+ <CloudInput
+ id="site-domain-slug"
+ v-model="slug"
+ :disabled="busy"
+ minlength="3"
+ maxlength="40"
+ required
+ /><span>.{{ data?.baseDomain }}</span>
+ </div>
<p class="cf-field-hint">
- {{ t('cloud.domains.targetHelp', { target: data.cnameTarget }) }}
+ {{ t('cloud.domains.slugHint', { base: data?.baseDomain }) }}
</p>
<p
- v-if="!data.domains.length"
- class="cf-field-hint"
+ v-if="failure"
+ role="alert"
+ class="cf-notice cf-notice-error"
>
- {{ t('cloud.domains.empty') }}
+ {{ notice }}
</p>
- <article
- v-for="domain in data.domains"
- :key="domain.hostname + domain.generation"
- class="rounded-lg border border-[var(--border)] p-3 space-y-3"
- >
- <div class="flex items-start justify-between gap-2">
- <div class="min-w-0">
- <h3 class="font-semibold text-sm break-all">
- <Globe
- :size="14"
- class="inline-block"
- />
- {{ domain.hostname }}
- </h3>
- <p
- v-if="domain.primary"
- class="cf-field-hint"
- >
- {{ t('cloud.domains.primary') }}
- </p>
- </div>
- <CloudBadge
- :tone="domain.status === 'active' ? 'success' : 'neutral'"
- >{{ t('cloud.domains.states.' + domain.status) }}</CloudBadge
- >
- </div>
- <div class="space-y-2">
- <p class="cf-field-label">{{ t('cloud.domains.cnameRecord') }}</p>
- <code class="block break-all text-sm">{{
- domain.cnameTarget
- }}</code>
- <CloudButton
- variant="ghost"
- size="sm"
- @click="copy(domain.cnameTarget)"
- ><Copy :size="14" />{{
- t('cloud.domains.copyTarget')
- }}</CloudButton
- >
- </div>
- <dl class="grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs">
- <div>
- <dt>{{ t('cloud.domains.dns') }}</dt>
- <dd>{{ t('cloud.domains.dnsStates.' + domain.dnsStatus) }}</dd>
- </div>
- <div>
- <dt>{{ t('cloud.domains.provider') }}</dt>
- <dd class="break-all">
- <code>{{ domain.hostnameStatus }}</code>
- </dd>
- </div>
- <div>
- <dt>{{ t('cloud.domains.certificate') }}</dt>
- <dd class="break-all">
- <code>{{ domain.sslStatus }}</code>
- </dd>
- </div>
- </dl>
- <p
- v-if="
- domain.dnsStatus === 'missing' && domain.status !== 'deleting'
- "
- class="cf-field-hint break-all"
- >
- {{
- t('cloud.domains.setCname', {
- hostname: domain.hostname,
- target: domain.cnameTarget,
- })
- }}
- </p>
- <p
- v-if="domain.error"
- class="cf-notice cf-notice-error"
- role="alert"
- >
- {{
- t(
- te('cloud.domains.errors.' + domain.error)
- ? 'cloud.domains.errors.' + domain.error
- : 'cloud.domains.failed',
- )
- }}
- </p>
- <p
- v-if="domain.checkedAt"
- class="cf-field-hint"
- >
- {{
- t('cloud.domains.checked', {
- time: new Date(domain.checkedAt).toLocaleString(
- locale === 'zh-Hans' ? 'zh-CN' : 'en-US',
- ),
- })
- }}
- </p>
- <div
- v-if="data.admin"
- class="flex flex-wrap gap-2"
+ <div class="cf-domain-modal-actions">
+ <CloudButton
+ variant="secondary"
+ :disabled="busy"
+ @click="renameOpen = false"
+ >{{ t('cloud.messages.cancel') }}</CloudButton
+ ><CloudButton
+ type="submit"
+ :disabled="busy || slug === settings?.site.slug || !slug.trim()"
+ :loading="busy"
+ >{{ t('cloud.messages.saveChanges') }}</CloudButton
>
- <CloudButton
- variant="secondary"
- size="sm"
- :disabled="
- busy ||
- !data.enabled ||
- !canCheck(domain) ||
- ['paused', 'deleting'].includes(domain.status)
- "
- @click="action(domain, 'check')"
- >{{ t('cloud.domains.check') }}</CloudButton
- ><CloudButton
- v-if="domain.status === 'active' && !domain.primary"
- variant="secondary"
- size="sm"
- :disabled="busy"
- @click="action(domain, 'primary')"
- >{{ t('cloud.domains.makePrimary') }}</CloudButton
- ><CloudButton
- v-if="domain.primary"
- variant="secondary"
- size="sm"
- :disabled="busy"
- @click="action(domain, 'redirects', !domain.redirects)"
- >{{
- t(
- domain.redirects
- ? 'cloud.domains.disableRedirects'
- : 'cloud.domains.enableRedirects',
- )
- }}</CloudButton
- ><CloudButton
- v-if="domain.status !== 'deleting'"
- variant="ghost"
- size="sm"
- :disabled="
- busy || (domain.status === 'paused' && !data.enabled)
- "
- @click="
- action(
- domain,
- domain.status === 'paused' ? 'resume' : 'pause',
- )
- "
- >{{
- t(
- domain.status === 'paused'
- ? 'cloud.domains.resume'
- : 'cloud.domains.pause',
- )
- }}</CloudButton
- ><CloudButton
- variant="ghost"
- size="sm"
- :disabled="busy"
- @click="action(domain, 'delete')"
- >{{ t('cloud.domains.remove') }}</CloudButton
- >
- </div>
- </article>
- </div></CloudCard
- >
- </template>
+ </div>
+ </form></template
+ ></UModal
+ >
+ <UModal
+ :open="!!removal"
+ :title="t('cloud.domains.remove')"
+ :description="
+ t('cloud.domains.removeConfirm', { hostname: removal?.hostname ?? '' })
+ "
+ :dismissible="!busy"
+ @update:open="
+ (value) => {
+ if (!value && !busy) removal = null
+ }
+ "
+ ><template #body
+ ><p
+ v-if="failure"
+ role="alert"
+ class="cf-notice cf-notice-error"
+ >
+ {{ notice }}
+ </p>
+ <div class="cf-domain-modal-actions">
+ <CloudButton
+ variant="secondary"
+ :disabled="busy"
+ @click="removal = null"
+ >{{ t('cloud.messages.cancel') }}</CloudButton
+ ><CloudButton
+ variant="destructive"
+ :disabled="busy"
+ :loading="busy"
+ @click="removal && action(removal, 'delete')"
+ >{{ t('cloud.domains.remove') }}</CloudButton
+ >
+ </div></template
+ ></UModal
+ >
</div>
</template>
diff --git a/apps/cloud/i18n/locales/en.json b/apps/cloud/i18n/locales/en.json
index 12b8d991..df699222 100644
--- a/apps/cloud/i18n/locales/en.json
+++ b/apps/cloud/i18n/locales/en.json
@@ -538,6 +538,37 @@
},
"useDefault": "Use default address as primary",
"targetHelp": "Each binding has its own CNAME target below. Traffic enters through {target}; no additional TXT record is required."
+ },
+ "domainFlow": {
+ "dnsStep": "DNS configuration",
+ "certificateStep": "SSL certificate",
+ "readyStep": "Ready",
+ "actions": "Actions for {hostname}",
+ "needsDns": "DNS setup required",
+ "issuingCertificate": "Issuing certificate",
+ "preparingRoute": "Preparing connection",
+ "connectedHelp": "Your domain is connected and secured with HTTPS.",
+ "pausedHelp": "Public access is paused. Resume to verify and reconnect this domain.",
+ "dnsHelp": "Add the record below with your DNS provider, then verify the configuration.",
+ "certificateHelp": "DNS is verified. We are securing your domain automatically; no certificate upload is needed.",
+ "routeHelp": "The certificate is ready. We are preparing the secure connection to your gallery.",
+ "hideDetails": "Hide setup details",
+ "details": "Setup details",
+ "retryIn": "Retry in {seconds}s",
+ "progress": "Domain connection progress",
+ "recordType": "Type",
+ "recordName": "Name",
+ "recordValue": "Value",
+ "automaticChecks": "Status is checked automatically.",
+ "technical": "Technical details",
+ "customHelp": "Connect a domain you own. DNS, certificates and connection status are shown together.",
+ "emptyHelp": "Add your domain to receive its DNS record and follow the connection progress.",
+ "previousAddress": "Previous site address",
+ "addDescription": "Enter your domain. You will receive a unique CNAME record to connect it securely.",
+ "continue": "Continue",
+ "removingHelp": "Public access has stopped. We are removing this connection.",
+ "expiredHelp": "This request expired before verification. Remove it and add the domain again.",
+ "checksPaused": "Checks are paused for this domain."
}
}
}
diff --git a/apps/cloud/i18n/locales/zh-Hans.json b/apps/cloud/i18n/locales/zh-Hans.json
index 7d5ecbc8..2dcf5037 100644
--- a/apps/cloud/i18n/locales/zh-Hans.json
+++ b/apps/cloud/i18n/locales/zh-Hans.json
@@ -538,6 +538,37 @@
},
"useDefault": "使用默认地址作为主域名",
"targetHelp": "请使用下方为各绑定单独生成的 CNAME 目标。流量统一经由 {target} 接入,无需额外配置 TXT 记录。"
+ },
+ "domainFlow": {
+ "dnsStep": "DNS 配置",
+ "certificateStep": "SSL 证书",
+ "readyStep": "连接就绪",
+ "actions": "{hostname} 的操作",
+ "needsDns": "需要配置 DNS",
+ "issuingCertificate": "正在签发证书",
+ "preparingRoute": "正在建立连接",
+ "connectedHelp": "域名已连接,并已启用 HTTPS 安全访问。",
+ "pausedHelp": "已暂停公开访问。恢复后将重新验证并连接此域名。",
+ "dnsHelp": "在你的 DNS 服务商处添加下方记录,然后检查配置。",
+ "certificateHelp": "DNS 已验证,正在自动为域名签发证书,无需手动上传。",
+ "routeHelp": "证书已就绪,正在建立域名与图库之间的安全连接。",
+ "hideDetails": "收起配置详情",
+ "details": "配置详情",
+ "retryIn": "{seconds} 秒后可重试",
+ "progress": "域名连接进度",
+ "recordType": "类型",
+ "recordName": "名称",
+ "recordValue": "记录值",
+ "automaticChecks": "状态会自动检查更新。",
+ "technical": "技术详情",
+ "customHelp": "连接你拥有的域名,在此查看 DNS、证书及连接进度。",
+ "emptyHelp": "添加域名后,即可获取专属 DNS 记录并查看连接进度。",
+ "previousAddress": "之前的站点地址",
+ "addDescription": "输入你的域名,随后获取专属 CNAME 记录以建立安全连接。",
+ "continue": "继续",
+ "removingHelp": "已停止公开访问,正在移除此连接。",
+ "expiredHelp": "此申请在完成验证前已过期,请移除后重新添加域名。",
+ "checksPaused": "已暂停此域名的状态检查。"
}
}
}