修复了导入bug
This commit is contained in:
+26
-3
@@ -181,8 +181,13 @@
|
||||
|
||||
/* 移动端侧边栏文档树:增大字号和触摸目标 */
|
||||
.sidebar-tree-item {
|
||||
font-size: 0.875rem;
|
||||
min-height: 2.75rem;
|
||||
font-size: 0.9375rem !important;
|
||||
min-height: 2.5rem !important;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.sidebar-tree-item .sidebar-title {
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,4 +384,22 @@ ul[data-type="taskList"],
|
||||
border-radius: 0.5rem;
|
||||
background: linear-gradient(180deg, hsl(var(--accent) / 0.42), hsl(var(--accent) / 0.25));
|
||||
box-shadow: inset 0 0 0 1px hsl(var(--ring) / 0.28);
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.sidebar-title {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
white-space: normal;
|
||||
max-height: calc(1.25em * 2);
|
||||
}
|
||||
}
|
||||
|
||||
+56
-1
@@ -7,6 +7,7 @@ import { Hash, X, Plus, ChevronLeft, ChevronRight, ChevronDown, Sparkles, Lock,
|
||||
import { useSettingsStore } from "@/lib/settings-store";
|
||||
import { exportPageAsMarkdown } from "@/lib/export";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { cn, getTagColor } from "@/lib/utils";
|
||||
import { useSearchStore } from "@/lib/search-store";
|
||||
import { type Editor as TiptapEditor } from "@tiptap/react";
|
||||
@@ -25,11 +26,12 @@ const ICONS = [
|
||||
];
|
||||
|
||||
export default function Home() {
|
||||
const { activePageId, pages, updatePage, setActivePageId, addPage } = useEditorStore();
|
||||
const { activePageId, pages, pageSync, updatePage, setActivePageId, addPage, retryPageSync, retryPendingSyncs, flushPendingSyncs } = useEditorStore();
|
||||
const { openSearchWithTag } = useSearchStore();
|
||||
const { timezone } = useSettingsStore();
|
||||
|
||||
const activePage = pages.find((p) => p.id === activePageId);
|
||||
const activePageSync = activePageId ? pageSync[activePageId] : undefined;
|
||||
const [isChatOpen, setIsChatOpen] = useState(false);
|
||||
const [editor, setEditor] = useState<TiptapEditor | null>(null);
|
||||
const [isAddingTag, setIsAddingTag] = useState(false);
|
||||
@@ -94,6 +96,33 @@ export default function Home() {
|
||||
await addPage(null, "file", { title, content: "" });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const onOnline = () => {
|
||||
retryPendingSyncs();
|
||||
};
|
||||
window.addEventListener("online", onOnline);
|
||||
return () => window.removeEventListener("online", onOnline);
|
||||
}, [retryPendingSyncs]);
|
||||
|
||||
useEffect(() => {
|
||||
const flush = () => flushPendingSyncs();
|
||||
const onVisibilityChange = () => {
|
||||
if (document.visibilityState === "hidden") {
|
||||
flush();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("beforeunload", flush);
|
||||
window.addEventListener("pagehide", flush);
|
||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("beforeunload", flush);
|
||||
window.removeEventListener("pagehide", flush);
|
||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||
};
|
||||
}, [flushPendingSyncs]);
|
||||
|
||||
return (
|
||||
<ImportProvider>
|
||||
<div className="relative flex h-[100dvh] w-full overflow-hidden bg-background">
|
||||
@@ -263,6 +292,32 @@ export default function Home() {
|
||||
{activePage.isLocked ? "已锁定" : "锁定"}
|
||||
</button>
|
||||
|
||||
{activePageSync && (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div
|
||||
className={cn(
|
||||
"rounded border px-2 py-0.5 text-[11px] md:text-xs",
|
||||
activePageSync.status === "saving" && "border-blue-200 bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300",
|
||||
activePageSync.status === "pending" && "border-amber-200 bg-amber-50 text-amber-700 dark:bg-amber-900/20 dark:text-amber-300",
|
||||
activePageSync.status === "error" && "border-red-200 bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-300",
|
||||
activePageSync.status === "saved" && "border-emerald-200 bg-emerald-50 text-emerald-700 dark:bg-emerald-900/20 dark:text-emerald-300"
|
||||
)}
|
||||
title={activePageSync.message}
|
||||
>
|
||||
{activePageSync.message || "已保存"}
|
||||
</div>
|
||||
{(activePageSync.status === "pending" || activePageSync.status === "error") && (
|
||||
<button
|
||||
onClick={() => activePage && retryPageSync(activePage.id)}
|
||||
className="ui-btn-secondary px-2 py-0.5 text-[11px] md:text-xs"
|
||||
title="立即尝试同步到本地数据库"
|
||||
>
|
||||
立即同步
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activePage.updatedAt && (
|
||||
<div className="w-full pt-0.5 text-[11px] text-muted-foreground/60 md:ml-1 md:h-4 md:w-auto md:border-l md:pl-2 md:pt-0 md:text-xs md:text-muted-foreground/50">
|
||||
{new Date(activePage.updatedAt).toLocaleString("zh-CN", {
|
||||
|
||||
Reference in New Issue
Block a user