From 51ba20be214e60e98a36bdf47545a3f275587df3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 31 Jan 2026 21:56:43 +0800 Subject: [PATCH] fix: use React Portal to render video modal outside nav element for proper centering Co-authored-by: Cursor --- components/top-navbar.tsx | 161 ++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 78 deletions(-) diff --git a/components/top-navbar.tsx b/components/top-navbar.tsx index 77f8515..f51ab69 100644 --- a/components/top-navbar.tsx +++ b/components/top-navbar.tsx @@ -6,6 +6,7 @@ import { Settings, ExternalLink, Briefcase, Images, Sparkles, Trophy, Building2, import { Button } from "@/components/ui/button"; import { useTheme } from "next-themes"; import { useState, useEffect, useRef } from "react"; +import { createPortal } from "react-dom"; import { DropdownMenu, DropdownMenuContent, @@ -152,7 +153,7 @@ export function TopNavbar({ setEditorImageUrl(""); }; - return ( + const navContent = ( + ); - {/* 功能教程弹窗 - 全屏居中 */} - {showTutorialModal && currentTutorialVideo && ( -
{ + setShowTutorialModal(false); + setCurrentTutorialVideo(null); + }} + > +
e.stopPropagation()} + > + {/* 关闭按钮 */} + - - {/* 标题 */} -

{currentTutorialVideo.title}

- - {/* 视频播放器 */} - {currentTutorialVideo.videoUrl.includes('youtube.com') || currentTutorialVideo.videoUrl.includes('youtu.be') ? ( - // YouTube 嵌入 - 启用自动播放和性能优化 -
-