From fe22d6dad861c393c8ade3a2112ddfd054700970 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 2 Jul 2026 11:11:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20tiptap=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E6=9C=89=E5=86=85=E5=AE=B9=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=B0=83=E6=B7=A1=E8=83=8C=E6=99=AF=E5=9B=BE=E9=80=8F=E6=98=8E?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 无内容时背景图保持 60% 透明度;当编辑器内有内容(非纯空白)时, 背景图淡出到 10%,与聚焦时行为一致。content signal 由 onUpdate 回调实时维护,输入即触发重渲染,无需额外状态。 --- src/pages/admin/write.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pages/admin/write.rs b/src/pages/admin/write.rs index 042b3e4..5342c1d 100644 --- a/src/pages/admin/write.rs +++ b/src/pages/admin/write.rs @@ -469,10 +469,21 @@ fn write_editor(post_id: Option) -> Element { div { class: "relative group flex-1 min-h-0 w-full border border-[var(--color-paper-border)] rounded-xl overflow-hidden bg-[var(--color-paper-entry)] shadow-[0_2px_8px_rgba(0,0,0,0.04)] dark:shadow-none", id: "tiptap-editor", - img { - src: "/images/xiantiaoxiaogou_input_bg.webp", - alt: "", - class: "absolute bottom-1.5 right-1.5 opacity-60 group-focus-within:opacity-10 transition-opacity duration-300 pointer-events-none z-0", + { + // 无内容时半透明(60%);有内容或聚焦时淡出(10%)。 + // content 是 onUpdate 回调实时维护的 signal,编辑即触发重渲染。 + let bg_opacity = if content().trim().is_empty() { + "opacity-60" + } else { + "opacity-10" + }; + rsx! { + img { + src: "/images/xiantiaoxiaogou_input_bg.webp", + alt: "", + class: "absolute bottom-1.5 right-1.5 group-focus-within:opacity-10 transition-opacity duration-300 pointer-events-none z-0 {bg_opacity}", + } + } } } }