0.3.4 小图标功能增加
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
import Link from "next/link";
|
||||
import { useParams, useSelectedLayoutSegments } from "next/navigation";
|
||||
import { ChevronRight, MoreHorizontal, Star } from "lucide-react";
|
||||
import { useMutation, useQuery } from "convex/react";
|
||||
import type { DocumentRecord } from "@/lib/documents";
|
||||
import { findBreadcrumb } from "@/lib/documents";
|
||||
import { usePageLayoutStore } from "@/store/page-layout";
|
||||
import { api } from "@/lib/convex/api";
|
||||
|
||||
interface BreadcrumbProps {
|
||||
documents: DocumentRecord[];
|
||||
@@ -19,6 +21,8 @@ export function Breadcrumb({ documents }: BreadcrumbProps) {
|
||||
const path = findBreadcrumb(documents, activeId);
|
||||
const showInspector = usePageLayoutStore((state) => state.showInspector);
|
||||
const toggleInspector = usePageLayoutStore((state) => state.toggleInspector);
|
||||
const isStarred = useQuery(api.documentStars.isStarred, activeId ? { documentId: activeId } : "skip");
|
||||
const toggleStar = useMutation(api.documentStars.toggle);
|
||||
|
||||
// 新建页面后,侧边栏数据可能还没同步到 layout(SSR)注入的 documents,导致 findBreadcrumb 暂时为空。
|
||||
// 这里用 activeId 兜底,避免右上角“收藏/更多”按钮消失。
|
||||
@@ -55,8 +59,13 @@ export function Breadcrumb({ documents }: BreadcrumbProps) {
|
||||
<button
|
||||
type="button"
|
||||
className="hover:bg-wolai-bg-hover hover:text-wolai-text-primary rounded-full px-3 py-1 text-sm transition-colors"
|
||||
onClick={() => void toggleStar({ documentId: activeId })}
|
||||
disabled={!activeId}
|
||||
>
|
||||
<Star className="mr-1 inline h-4 w-4" />
|
||||
<Star
|
||||
className={`mr-1 inline h-4 w-4 ${isStarred ? "text-[#f5a623]" : ""}`}
|
||||
fill={isStarred ? "currentColor" : "none"}
|
||||
/>
|
||||
收藏
|
||||
</button>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user