mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 10:16:37 +08:00
[优化] 界面优化
This commit is contained in:
@@ -762,7 +762,6 @@ export function PerformancePage() {
|
|||||||
</ResourceField>
|
</ResourceField>
|
||||||
<ToggleField
|
<ToggleField
|
||||||
label="multi_accept"
|
label="multi_accept"
|
||||||
description=""
|
|
||||||
tooltip={performanceFieldTooltips.multi_accept}
|
tooltip={performanceFieldTooltips.multi_accept}
|
||||||
checked={performanceFields.OpenRestyEventsMultiAcceptEnabled}
|
checked={performanceFields.OpenRestyEventsMultiAcceptEnabled}
|
||||||
onChange={(checked) =>
|
onChange={(checked) =>
|
||||||
|
|||||||
@@ -180,13 +180,13 @@ export function ToggleField({
|
|||||||
onChange={(event) => onChange(event.target.checked)}
|
onChange={(event) => onChange(event.target.checked)}
|
||||||
className="mt-1 h-4 w-4 rounded border-[var(--border-default)] accent-[var(--brand-primary)]"
|
className="mt-1 h-4 w-4 rounded border-[var(--border-default)] accent-[var(--brand-primary)]"
|
||||||
/>
|
/>
|
||||||
<span className="space-y-1">
|
<span className="flex flex-col">
|
||||||
<span className="flex items-center gap-2 text-sm font-medium text-[var(--foreground-primary)]">
|
<span className="flex items-center gap-2 text-sm font-medium text-[var(--foreground-primary)]">
|
||||||
<span>{label}</span>
|
<span>{label}</span>
|
||||||
{tooltip ? <FieldTooltip content={tooltip} /> : null}
|
{tooltip ? <FieldTooltip content={tooltip} /> : null}
|
||||||
</span>
|
</span>
|
||||||
{description ? (
|
{description ? (
|
||||||
<span className="block text-xs leading-5 text-[var(--foreground-secondary)]">
|
<span className="mt-1 block text-xs leading-5 text-[var(--foreground-secondary)]">
|
||||||
{description}
|
{description}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -1,32 +1,24 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useRouter } from 'next/navigation';
|
import {useRouter} from 'next/navigation';
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query';
|
||||||
import { useMemo, useState } from 'react';
|
import {useMemo, useState} from 'react';
|
||||||
|
|
||||||
import { EmptyState } from '@/components/feedback/empty-state';
|
import {EmptyState} from '@/components/feedback/empty-state';
|
||||||
import { ErrorState } from '@/components/feedback/error-state';
|
import {ErrorState} from '@/components/feedback/error-state';
|
||||||
import { InlineMessage } from '@/components/feedback/inline-message';
|
import {InlineMessage} from '@/components/feedback/inline-message';
|
||||||
import { LoadingState } from '@/components/feedback/loading-state';
|
import {LoadingState} from '@/components/feedback/loading-state';
|
||||||
import { PageHeader } from '@/components/layout/page-header';
|
import {PageHeader} from '@/components/layout/page-header';
|
||||||
import { AppCard } from '@/components/ui/app-card';
|
import {AppCard} from '@/components/ui/app-card';
|
||||||
import { StatusBadge } from '@/components/ui/status-badge';
|
import {StatusBadge} from '@/components/ui/status-badge';
|
||||||
import {
|
import {deleteManagedDomain, getManagedDomains,} from '@/features/managed-domains/api/managed-domains';
|
||||||
deleteManagedDomain,
|
import {getProxyRoutes,} from '@/features/proxy-routes/api/proxy-routes';
|
||||||
getManagedDomains,
|
import {deleteTlsCertificate, getTlsCertificates,} from '@/features/tls-certificates/api/tls-certificates';
|
||||||
} from '@/features/managed-domains/api/managed-domains';
|
import {CertificateDetailModal} from '@/features/websites/components/certificate-detail-modal';
|
||||||
import {
|
import {CertificateEditorModal} from '@/features/websites/components/certificate-editor-modal';
|
||||||
getProxyRoutes,
|
import {CertificateImportModal} from '@/features/websites/components/certificate-import-modal';
|
||||||
} from '@/features/proxy-routes/api/proxy-routes';
|
import {WebsiteEditorModal} from '@/features/websites/components/website-editor-modal';
|
||||||
import {
|
|
||||||
deleteTlsCertificate,
|
|
||||||
getTlsCertificates,
|
|
||||||
} from '@/features/tls-certificates/api/tls-certificates';
|
|
||||||
import { CertificateDetailModal } from '@/features/websites/components/certificate-detail-modal';
|
|
||||||
import { CertificateEditorModal } from '@/features/websites/components/certificate-editor-modal';
|
|
||||||
import { CertificateImportModal } from '@/features/websites/components/certificate-import-modal';
|
|
||||||
import { WebsiteEditorModal } from '@/features/websites/components/website-editor-modal';
|
|
||||||
import {
|
import {
|
||||||
buildCertificateLabel,
|
buildCertificateLabel,
|
||||||
getCertificateStatus,
|
getCertificateStatus,
|
||||||
@@ -34,19 +26,15 @@ import {
|
|||||||
getMatchTypeMeta,
|
getMatchTypeMeta,
|
||||||
isRouteRelatedToManagedDomain,
|
isRouteRelatedToManagedDomain,
|
||||||
} from '@/features/websites/utils';
|
} from '@/features/websites/utils';
|
||||||
import {
|
import {DangerButton, PrimaryButton, SecondaryButton,} from '@/features/shared/components/resource-primitives';
|
||||||
DangerButton,
|
import {formatDateTime} from '@/lib/utils/date';
|
||||||
PrimaryButton,
|
|
||||||
SecondaryButton,
|
|
||||||
} from '@/features/shared/components/resource-primitives';
|
|
||||||
import { formatDateTime } from '@/lib/utils/date';
|
|
||||||
|
|
||||||
type FeedbackState = {
|
type FeedbackState = {
|
||||||
tone: 'success' | 'danger';
|
tone: 'success' | 'danger';
|
||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
export function WebsiteDetailPage({websiteId}: { websiteId: string }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [feedback, setFeedback] = useState<FeedbackState | null>(null);
|
const [feedback, setFeedback] = useState<FeedbackState | null>(null);
|
||||||
@@ -74,25 +62,25 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
const deleteDomainMutation = useMutation({
|
const deleteDomainMutation = useMutation({
|
||||||
mutationFn: deleteManagedDomain,
|
mutationFn: deleteManagedDomain,
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
await queryClient.invalidateQueries({ queryKey: ['managed-domains'] });
|
await queryClient.invalidateQueries({queryKey: ['managed-domains']});
|
||||||
router.push('/website');
|
router.push('/website');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setFeedback({ tone: 'danger', message: getErrorMessage(error) });
|
setFeedback({tone: 'danger', message: getErrorMessage(error)});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteCertificateMutation = useMutation({
|
const deleteCertificateMutation = useMutation({
|
||||||
mutationFn: deleteTlsCertificate,
|
mutationFn: deleteTlsCertificate,
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
setFeedback({ tone: 'success', message: '证书已删除。' });
|
setFeedback({tone: 'success', message: '证书已删除。'});
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
queryClient.invalidateQueries({ queryKey: ['tls-certificates'] }),
|
queryClient.invalidateQueries({queryKey: ['tls-certificates']}),
|
||||||
queryClient.invalidateQueries({ queryKey: ['managed-domains'] }),
|
queryClient.invalidateQueries({queryKey: ['managed-domains']}),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
setFeedback({ tone: 'danger', message: getErrorMessage(error) });
|
setFeedback({tone: 'danger', message: getErrorMessage(error)});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,7 +146,7 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
certificatesQuery.isLoading ||
|
certificatesQuery.isLoading ||
|
||||||
proxyRoutesQuery.isLoading
|
proxyRoutesQuery.isLoading
|
||||||
) {
|
) {
|
||||||
return <LoadingState />;
|
return <LoadingState/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (managedDomainsQuery.isError) {
|
if (managedDomainsQuery.isError) {
|
||||||
@@ -238,13 +226,13 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{feedback ? (
|
{feedback ? (
|
||||||
<InlineMessage tone={feedback.tone} message={feedback.message} />
|
<InlineMessage tone={feedback.tone} message={feedback.message}/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="grid gap-4 xl:grid-cols-4">
|
<div className="grid gap-4 xl:grid-cols-4">
|
||||||
<AppCard title="匹配类型">
|
<AppCard title="匹配类型">
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<StatusBadge label={matchType.label} variant={matchType.variant} />
|
<StatusBadge label={matchType.label} variant={matchType.variant}/>
|
||||||
<p className="text-sm text-[var(--foreground-secondary)]">
|
<p className="text-sm text-[var(--foreground-secondary)]">
|
||||||
{website.domain.startsWith('*.')
|
{website.domain.startsWith('*.')
|
||||||
? '当前网站会覆盖该后缀下的子域名规则。'
|
? '当前网站会覆盖该后缀下的子域名规则。'
|
||||||
@@ -290,7 +278,8 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
<div className="grid gap-6 xl:grid-cols-[1.05fr_0.95fr]">
|
<div className="grid gap-6 xl:grid-cols-[1.05fr_0.95fr]">
|
||||||
<AppCard title="网站信息" description="当前网站的基础配置与托管信息。">
|
<AppCard title="网站信息" description="当前网站的基础配置与托管信息。">
|
||||||
<div className="grid gap-4 md:grid-cols-2">
|
<div className="grid gap-4 md:grid-cols-2">
|
||||||
<div className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4">
|
<div
|
||||||
|
className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4">
|
||||||
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
||||||
域名
|
域名
|
||||||
</p>
|
</p>
|
||||||
@@ -298,7 +287,8 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
{website.domain}
|
{website.domain}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4">
|
<div
|
||||||
|
className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4">
|
||||||
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
||||||
创建时间
|
创建时间
|
||||||
</p>
|
</p>
|
||||||
@@ -306,7 +296,8 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
{formatDateTime(website.created_at)}
|
{formatDateTime(website.created_at)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4 md:col-span-2">
|
<div
|
||||||
|
className="rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-4 py-4 md:col-span-2">
|
||||||
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
<p className="text-xs uppercase tracking-[0.18em] text-[var(--foreground-muted)]">
|
||||||
备注
|
备注
|
||||||
</p>
|
</p>
|
||||||
@@ -316,18 +307,9 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AppCard>
|
</AppCard>
|
||||||
|
|
||||||
<AppCard
|
<AppCard
|
||||||
title="证书信息"
|
title="证书信息"
|
||||||
description="当前网站绑定的默认证书信息。若还没有证书,可直接添加后回填。"
|
description="当前网站绑定的默认证书信息。若还没有证书,可直接添加后回填。"
|
||||||
action={
|
|
||||||
<PrimaryButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => setIsCertificateImportOpen(true)}
|
|
||||||
>
|
|
||||||
添加
|
|
||||||
</PrimaryButton>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{certificate ? (
|
{certificate ? (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
@@ -343,20 +325,13 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
<p>到期时间:{formatDateTime(certificate.not_after)}</p>
|
<p>到期时间:{formatDateTime(certificate.not_after)}</p>
|
||||||
<p>备注:{certificate.remark || '暂无备注'}</p>
|
<p>备注:{certificate.remark || '暂无备注'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-3">
|
||||||
<SecondaryButton
|
<SecondaryButton
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setIsCertificateDetailOpen(true)}
|
onClick={() => setIsCertificateDetailOpen(true)}
|
||||||
>
|
>
|
||||||
查看
|
查看
|
||||||
</SecondaryButton>
|
</SecondaryButton>
|
||||||
<SecondaryButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => setIsCertificateEditorOpen(true)}
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</SecondaryButton>
|
|
||||||
</div>
|
|
||||||
<DangerButton
|
<DangerButton
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleDeleteCertificate}
|
onClick={handleDeleteCertificate}
|
||||||
@@ -365,6 +340,7 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
删除
|
删除
|
||||||
</DangerButton>
|
</DangerButton>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
title="未绑定证书"
|
title="未绑定证书"
|
||||||
@@ -430,7 +406,7 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
variant={route.enable_https ? 'success' : 'warning'}
|
variant={route.enable_https ? 'success' : 'warning'}
|
||||||
/>
|
/>
|
||||||
{route.redirect_http ? (
|
{route.redirect_http ? (
|
||||||
<StatusBadge label="HTTP 跳转" variant="info" />
|
<StatusBadge label="HTTP 跳转" variant="info"/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -471,7 +447,7 @@ export function WebsiteDetailPage({ websiteId }: { websiteId: string }) {
|
|||||||
onRequestImportCertificate={() => setIsCertificateImportOpen(true)}
|
onRequestImportCertificate={() => setIsCertificateImportOpen(true)}
|
||||||
onSaved={() => {
|
onSaved={() => {
|
||||||
setPreferredCertificateId(null);
|
setPreferredCertificateId(null);
|
||||||
setFeedback({ tone: 'success', message: '网站已更新。' });
|
setFeedback({tone: 'success', message: '网站已更新。'});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export function WebsitesPage() {
|
|||||||
|
|
||||||
<AppCard
|
<AppCard
|
||||||
title="网站列表"
|
title="网站列表"
|
||||||
description="查看网站绑定的证书、启用状态和更新时间。进入详情页可继续查看关联规则并编辑网站。"
|
description="查看网站绑定的证书、启用状态和更新时间。"
|
||||||
>
|
>
|
||||||
{managedDomainsQuery.isLoading ? (
|
{managedDomainsQuery.isLoading ? (
|
||||||
<LoadingState />
|
<LoadingState />
|
||||||
@@ -181,7 +181,7 @@ export function WebsitesPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-row gap-2">
|
||||||
<Link
|
<Link
|
||||||
href={`/website/detail?id=${domain.id}`}
|
href={`/website/detail?id=${domain.id}`}
|
||||||
className="inline-flex items-center justify-center rounded-2xl border border-[var(--border-default)] bg-[var(--control-background)] px-4 py-3 text-sm font-medium text-[var(--foreground-primary)] transition hover:bg-[var(--control-background-hover)]"
|
className="inline-flex items-center justify-center rounded-2xl border border-[var(--border-default)] bg-[var(--control-background)] px-4 py-3 text-sm font-medium text-[var(--foreground-primary)] transition hover:bg-[var(--control-background-hover)]"
|
||||||
|
|||||||
Reference in New Issue
Block a user