feat: add interactive React Flow canvas and floating toolbars

This commit is contained in:
2026-11-06 00:52:07 +08:00
parent fec69c6e59
commit d4b45c5051
13 changed files with 778 additions and 36 deletions
+37 -34
View File
@@ -153,6 +153,9 @@ export default function DashboardSidebar() {
srcSet="/brand/png/logo-light/endoleap-16.png 1x, /brand/png/logo-light/endoleap-32.png 2x, /brand/png/logo-light/endoleap-48.png 3x"
width={16} height={16} alt="" />
</Link>
<button type="button" className={styles.floatingAvatarButton} popoverTarget="workspace-account" aria-label="账户和工作空间">
<UserAvatar name={name} url={profile?.avatar_url} />
</button>
{error && <p className={styles.floatingError} role="alert">{error}</p>}
</motion.div>
)}
@@ -187,40 +190,6 @@ export default function DashboardSidebar() {
</nav>
{error && <p className={styles.error} role="alert">{error}</p>}
<div className={styles.accountArea}>
<div ref={accountPopup} id="workspace-account" popover="auto" className={styles.accountPopup}>
<div className={styles.accountHeading}>
<span className={styles.workspaceAvatar} aria-hidden="true">{(currentWorkspace?.name || "啡跃").slice(0, 1)}</span>
<div><strong>{currentWorkspace?.name || "你的工作空间"}</strong><small>{roleLabel}{demo ? " · 本地演示" : ""}</small></div>
</div>
<div className={styles.menuGroup}>
<button type="button" className={styles.menuItem} disabled={!profile} onClick={() => openPanel("settings")}>
<Settings size={16} strokeWidth={1.6} /><span>账户设置</span>
</button>
</div>
<div className={styles.separator} />
<div className={styles.popupIdentity}>
<UserAvatar name={name} url={profile?.avatar_url} />
<div><strong>{name}</strong><small>{profile?.email || profile?.username || "正在读取账户…"}</small></div>
</div>
<div className={styles.workspaceList}>
{workspaces.map((w) => (
<button type="button" key={w.id} className={styles.menuItem} aria-current={w.id === workspace ? "true" : undefined} onClick={() => {
accountPopup.current?.hidePopover();
setQuery("");
setSelectedWorkspace(w.id);
router.push(`/dashboard?workspace=${encodeURIComponent(w.id)}${demo ? "&demo=1" : ""}`);
}}>
<span className={styles.workspaceMini} aria-hidden="true">{w.name.slice(0, 1)}</span>
<span>{w.name}</span>{w.id === workspace && <Check size={15} strokeWidth={1.8} />}
</button>
))}
</div>
<button type="button" className={`${styles.menuItem} ${styles.newWorkspace}`} disabled={status !== "ready"} onClick={() => openPanel("workspace")}>
<Plus size={16} strokeWidth={1.6} /><span>新建工作空间</span>
</button>
<div className={styles.separator} />
<button type="button" className={`${styles.menuItem} ${styles.logout}`} onClick={logout}>退出登录</button>
</div>
<button type="button" className={styles.accountButton} popoverTarget="workspace-account" aria-label="账户和工作空间">
<UserAvatar name={name} url={profile?.avatar_url} />
<span className={styles.accountText}><strong>{name}</strong><small>{currentWorkspace?.name || (demo ? "本地演示" : "个人账户")}</small></span>
@@ -229,6 +198,40 @@ export default function DashboardSidebar() {
</div>
</motion.aside>
</motion.div>
<div ref={accountPopup} id="workspace-account" popover="auto" className={styles.accountPopup} data-floating={collapsed} aria-label="账户和工作空间菜单">
<div className={styles.accountHeading}>
<span className={styles.workspaceAvatar} aria-hidden="true">{(currentWorkspace?.name || "啡跃").slice(0, 1)}</span>
<div><strong>{currentWorkspace?.name || "你的工作空间"}</strong><small>{roleLabel}{demo ? " · 本地演示" : ""}</small></div>
</div>
<div className={styles.menuGroup}>
<button type="button" className={styles.menuItem} disabled={!profile} onClick={() => openPanel("settings")}>
<Settings size={16} strokeWidth={1.6} /><span>账户设置</span>
</button>
</div>
<div className={styles.separator} />
<div className={styles.popupIdentity}>
<UserAvatar name={name} url={profile?.avatar_url} />
<div><strong>{name}</strong><small>{profile?.email || profile?.username || "正在读取账户…"}</small></div>
</div>
<div className={styles.workspaceList}>
{workspaces.map((w) => (
<button type="button" key={w.id} className={styles.menuItem} aria-current={w.id === workspace ? "true" : undefined} onClick={() => {
accountPopup.current?.hidePopover();
setQuery("");
setSelectedWorkspace(w.id);
router.push(`/dashboard?workspace=${encodeURIComponent(w.id)}${demo ? "&demo=1" : ""}`);
}}>
<span className={styles.workspaceMini} aria-hidden="true">{w.name.slice(0, 1)}</span>
<span>{w.name}</span>{w.id === workspace && <Check size={15} strokeWidth={1.8} />}
</button>
))}
</div>
<button type="button" className={`${styles.menuItem} ${styles.newWorkspace}`} disabled={status !== "ready"} onClick={() => openPanel("workspace")}>
<Plus size={16} strokeWidth={1.6} /><span>新建工作空间</span>
</button>
<div className={styles.separator} />
<button type="button" className={`${styles.menuItem} ${styles.logout}`} onClick={logout}>退出登录</button>
</div>
{panel && profile && (
<AccountPanel mode={panel} profile={profile} demo={demo} onClose={() => setPanel(null)} onProfile={setProfile}
onWorkspace={(created) => {
+1
View File
@@ -1,3 +1,4 @@
import "@xyflow/react/dist/style.css";
import { Suspense, type ReactNode } from "react";
import DashboardSidebar from "./dashboard";
import styles from "@/components/workspace/workspace.module.css";