mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
[优化] 更新域名列表输入组件,优化按钮样式并支持自定义容器类型
This commit is contained in:
@@ -14,7 +14,11 @@ export type DomainListRow = {
|
|||||||
certificateId: string;
|
certificateId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const actionButtonClassName = 'h-12 w-[72px] shrink-0 rounded-2xl px-0';
|
const actionButtonBaseClassName = 'h-11 w-11 shrink-0 rounded-2xl px-0';
|
||||||
|
const removeButtonClassName =
|
||||||
|
'border-[var(--border-default)] bg-[var(--surface-elevated)] text-[var(--foreground-secondary)] hover:border-[var(--status-danger-border)] hover:bg-[var(--status-danger-soft)] hover:text-[var(--status-danger-foreground)] disabled:border-[var(--border-default)] disabled:bg-[var(--surface-muted)] disabled:text-[var(--foreground-muted)]';
|
||||||
|
const addButtonClassName =
|
||||||
|
'border-dashed border-[var(--border-default)] bg-[var(--surface-muted)] text-[var(--foreground-secondary)] hover:border-[var(--brand-primary)] hover:bg-[var(--brand-primary-soft)] hover:text-[var(--brand-primary)]';
|
||||||
|
|
||||||
function ensureRows(rows: DomainListRow[]) {
|
function ensureRows(rows: DomainListRow[]) {
|
||||||
return rows.length > 0 ? rows : [{ domain: '', certificateId: '' }];
|
return rows.length > 0 ? rows : [{ domain: '', certificateId: '' }];
|
||||||
@@ -146,11 +150,11 @@ export function DomainListInput({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={`${index}-${safeRows.length}`} className="space-y-2">
|
<div key={`${index}-${safeRows.length}`} className="space-y-2">
|
||||||
<div className="grid gap-3 md:grid-cols-[72px_minmax(0,1fr)_280px] md:items-start">
|
<div className="grid gap-3 md:grid-cols-[44px_minmax(0,1fr)_280px] md:items-start">
|
||||||
<SecondaryButton
|
<SecondaryButton
|
||||||
type="button"
|
type="button"
|
||||||
aria-label={`删除域名输入框 ${index + 1}`}
|
aria-label={`删除域名输入框 ${index + 1}`}
|
||||||
className={actionButtonClassName}
|
className={`${actionButtonBaseClassName} ${removeButtonClassName}`}
|
||||||
disabled={safeRows.length === 1}
|
disabled={safeRows.length === 1}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (safeRows.length === 1) {
|
if (safeRows.length === 1) {
|
||||||
@@ -242,7 +246,7 @@ export function DomainListInput({
|
|||||||
<SecondaryButton
|
<SecondaryButton
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="新增域名输入框"
|
aria-label="新增域名输入框"
|
||||||
className={actionButtonClassName}
|
className={`${actionButtonBaseClassName} ${addButtonClassName}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
updateRows([...safeRows, { domain: '', certificateId: '' }]);
|
updateRows([...safeRows, { domain: '', certificateId: '' }]);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -352,6 +352,7 @@ function DomainSettingsSection({
|
|||||||
label="域名列表"
|
label="域名列表"
|
||||||
hint="每行配置一个域名。可为不同域名选择不同证书,相同证书也可以重复选择。"
|
hint="每行配置一个域名。可为不同域名选择不同证书,相同证书也可以重复选择。"
|
||||||
error={form.formState.errors.domain_rows?.message as string | undefined}
|
error={form.formState.errors.domain_rows?.message as string | undefined}
|
||||||
|
container="div"
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ export function ProxyRouteCreateDrawer({
|
|||||||
label="域名列表"
|
label="域名列表"
|
||||||
hint="每行配置一个域名,可按需为该行选择证书。保存时会自动汇总站点证书集合。"
|
hint="每行配置一个域名,可按需为该行选择证书。保存时会自动汇总站点证书集合。"
|
||||||
error={form.formState.errors.domain_rows?.message as string | undefined}
|
error={form.formState.errors.domain_rows?.message as string | undefined}
|
||||||
|
container="div"
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ interface ResourceFieldProps {
|
|||||||
error?: string;
|
error?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
|
container?: 'label' | 'div';
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,10 +37,13 @@ export function ResourceField({
|
|||||||
error,
|
error,
|
||||||
className,
|
className,
|
||||||
tooltip,
|
tooltip,
|
||||||
|
container = 'label',
|
||||||
children,
|
children,
|
||||||
}: ResourceFieldProps) {
|
}: ResourceFieldProps) {
|
||||||
|
const Container = container;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label className={cn('block space-y-2', className)}>
|
<Container className={cn('block space-y-2', className)}>
|
||||||
<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}
|
||||||
@@ -54,7 +58,7 @@ export function ResourceField({
|
|||||||
{hint}
|
{hint}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</label>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user