公开页补齐自引用 Canonical 与按类型的结构化数据,图片补上说明文字。
后台设置和内容编辑改成可导航布局;部署用访客 origin 生成 Canonical,避免落到容器地址。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,6 +15,9 @@ export default function AdminField({
|
||||
disabled,
|
||||
className = "",
|
||||
minHeight,
|
||||
embed,
|
||||
error,
|
||||
describedBy,
|
||||
}: {
|
||||
id: string;
|
||||
label: ReactNode;
|
||||
@@ -29,27 +32,40 @@ export default function AdminField({
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
minHeight?: string;
|
||||
/** 标签由外层设置行提供,本组件只保留计数与输入 */
|
||||
embed?: boolean;
|
||||
error?: string;
|
||||
describedBy?: string;
|
||||
}) {
|
||||
const handle = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>
|
||||
onChange(e.target.value);
|
||||
|
||||
const invalid = Boolean(error);
|
||||
const described = [describedBy, error ? `${id}-error` : null].filter(Boolean).join(" ") || undefined;
|
||||
|
||||
const count =
|
||||
maxLength != null ? (
|
||||
<span className={`admin-field-count${embed ? " is-infield" : ""}`} aria-hidden>
|
||||
{value.length}/{maxLength}
|
||||
</span>
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div className="admin-field-head">
|
||||
<label className="field-label" htmlFor={id}>
|
||||
{label}
|
||||
</label>
|
||||
{maxLength != null && (
|
||||
<span className="admin-field-count" aria-hidden>
|
||||
{value.length}/{maxLength}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{hint != null && hint !== "" && (
|
||||
{embed ? null : (
|
||||
<div className="admin-field-head">
|
||||
<label className="field-label" htmlFor={id}>
|
||||
{label}
|
||||
</label>
|
||||
{count}
|
||||
</div>
|
||||
)}
|
||||
{!embed && hint != null && hint !== "" && (
|
||||
<p className="meta text-[12.5px] mb-2.5 leading-relaxed">{hint}</p>
|
||||
)}
|
||||
{as === "textarea" ? (
|
||||
<div className="admin-field-shell is-area">
|
||||
<div className={`admin-field-shell is-area${embed && count ? " has-count" : ""}${invalid ? " is-invalid" : ""}`}>
|
||||
{embed ? count : null}
|
||||
<textarea
|
||||
id={id}
|
||||
className="admin-field-input"
|
||||
@@ -59,10 +75,12 @@ export default function AdminField({
|
||||
onChange={handle}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
aria-invalid={invalid || undefined}
|
||||
aria-describedby={described}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="admin-field-shell">
|
||||
<div className={`admin-field-shell${embed && count ? " has-count" : ""}${invalid ? " is-invalid" : ""}`}>
|
||||
<input
|
||||
id={id}
|
||||
type={type}
|
||||
@@ -73,9 +91,17 @@ export default function AdminField({
|
||||
placeholder={placeholder}
|
||||
autoComplete={autoComplete}
|
||||
disabled={disabled}
|
||||
aria-invalid={invalid || undefined}
|
||||
aria-describedby={described}
|
||||
/>
|
||||
{embed ? count : null}
|
||||
</div>
|
||||
)}
|
||||
{error ? (
|
||||
<p className="admin-settings-row-error" id={`${id}-error`} role="alert">
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user