AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
Improve mobile app experience
tianmaaa5be0ae68a8
diff --git a/README.md b/README.mdindex 181c0978..494e0f0c 100644--- a/README.md+++ b/README.md@@ -24,17 +24,18 @@ EdgeEver 是一个开源、自托管、Cloudflare-native 的现代笔记工作- 个人使用几乎可以零成本托管:基于 Cloudflare D1 + R2 免费额度,短笔记可达 10 万条量级,200KB 图片约可存放 5 万张。- AI Agent 友好:原生支持 MCP,可让 Codex、Claude Code、Antigravity 等工具读取、整理和维护笔记。-- 同时适配 PC 与移动端,桌面管理和手机随手记录都顺手。+- 同时适配 PC 与移动端,支持网页访问与 PWA 安装,桌面管理和手机随手记录都顺手。- 三栏布局:笔记本树、笔记列表、主编辑区。- 无限级嵌套笔记本。-- 支持富文本编辑+- 支持富文本编辑。- 笔记内图片可自动压缩,典型场景可节省约 80% 图片体积。- 多选合并笔记。- 多选移动笔记,笔记本支持拖拽排序和调整层级。-- PWA 可安装,支持静态应用壳离线打开和自动更新。- 已有笔记支持离线编辑草稿和本地同步队列。- 单用户登录,密码使用 PBKDF2-SHA256 hash。+> 移动端安装 PWA 时建议使用 Chrome 浏览器,部分移动端浏览器可能无法正常完成安装。+diff --git a/apps/web/src/components/MemoListPane.tsx b/apps/web/src/components/MemoListPane.tsxindex c0f9ea47..e9eb82b9 100644--- a/apps/web/src/components/MemoListPane.tsx+++ b/apps/web/src/components/MemoListPane.tsx@@ -34,7 +34,6 @@ import {Layers,Settings,MoreVertical,- RefreshCw,CheckCircle2,TagX,} from "lucide-react";@@ -50,7 +49,7 @@ import {import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select";import { MemoCard } from "./MemoCard";import { cn } from "@/lib/utils";-import type { Notebook, AuthUser, MemoSummary } from "@edgeever/shared";+import type { Notebook, MemoSummary } from "@edgeever/shared";import type {MemoFilterMode,MemoSortMode,@@ -179,40 +178,7 @@ const CheckCircleCheck = ({ className }: { className?: string }) => (</svg>);-const MobileHomeHeader = ({- user,- isOnline,- isSyncingQueuedChanges,- onSyncQueuedChanges,-}: {- user: AuthUser | null;- isOnline: boolean;- isSyncingQueuedChanges: boolean;- onSyncQueuedChanges: () => void;-}) => (- <div className="mb-2 flex h-7 items-center justify-between lg:hidden">- <div className="flex items-center gap-1.5">- <span className="flex h-6 w-6 items-center justify-center rounded-full bg-emerald-600 text-xs font-semibold text-white">- {user?.username?.[0]?.toUpperCase() ?? "E"}- </span>- <span className="text-sm font-semibold text-slate-900">EdgeEver</span>- </div>- <div className="flex items-center gap-1">- <button- className="flex h-7 w-7 items-center justify-center rounded-full text-slate-600 hover:bg-slate-100 hover:text-slate-900 disabled:opacity-50"- type="button"- title="立即同步"- disabled={!isOnline || isSyncingQueuedChanges}- onClick={onSyncQueuedChanges}- >- <RefreshCw className={cn("h-4 w-4", isSyncingQueuedChanges && "animate-spin")} />- </button>- </div>- </div>-);-export const MemoListPane = ({- user,notebooks,notebook,memos,@@ -229,8 +195,6 @@ export const MemoListPane = ({search,searchFocusToken,mobileSearchActive,- isOnline,- isSyncingQueuedChanges,onOpenMemo,onDeleteMemo,onRestoreMemo,@@ -253,7 +217,6 @@ export const MemoListPane = ({onOpenTrash,onOpenSettings,onCreateMemo,- onSyncQueuedChanges,mobileListActionsOpen,setMobileListActionsOpen,mobileMoveOpen,@@ -271,7 +234,6 @@ export const MemoListPane = ({}: {isLoading: boolean;multiSelectKeyDown: boolean;- user: AuthUser | null;notebooks: Notebook[];notebook: Notebook | null;memos: MemoSummary[];@@ -288,8 +250,6 @@ export const MemoListPane = ({search: string;searchFocusToken: number;mobileSearchActive: boolean;- isOnline: boolean;- isSyncingQueuedChanges: boolean;onOpenMemo: (memoId: string) => void;onDeleteMemo: (memoId: string) => void;onRestoreMemo: (memoId: string) => void;@@ -312,7 +272,6 @@ export const MemoListPane = ({onOpenTrash: () => void;onOpenSettings: () => void;onCreateMemo: () => void;- onSyncQueuedChanges: () => void;mobileListActionsOpen: boolean;setMobileListActionsOpen: (open: boolean) => void;mobileMoveOpen: boolean;@@ -831,14 +790,7 @@ export const MemoListPane = ({取消</button></div>- ) : (- <MobileHomeHeader- isOnline={isOnline}- isSyncingQueuedChanges={isSyncingQueuedChanges}- user={user}- onSyncQueuedChanges={onSyncQueuedChanges}- />- )}+ ) : null}{!mobileSearchActive && (<div className="mb-3 flex items-center justify-between gap-3 lg:hidden">diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsxindex 07d3351a..a6fce9c8 100644--- a/apps/web/src/components/WorkspaceApp.tsx+++ b/apps/web/src/components/WorkspaceApp.tsx@@ -13,7 +13,7 @@ import {type PointerEvent as ReactPointerEvent,} from "react";import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";-import { Home, Search, UserRound, Plus, ChevronDown, ChevronRight, X } from "lucide-react";+import { Home, Search, UserRound, Plus, ChevronDown, ChevronRight, RefreshCw, X } from "lucide-react";import { Button } from "@/components/ui/button";import {Drawer,@@ -63,6 +63,30 @@ import { useBrowserBackLayer } from "@/lib/app-hooks";import type { SyncQueueSummary } from "@/lib/sync-queue";const isDesktopViewport = () => window.matchMedia("(min-width: 1024px)").matches;+const PULL_TO_REFRESH_TRIGGER_PX = 72;+const PULL_TO_REFRESH_MAX_PX = 96;++const isStandaloneApp = () =>+ window.matchMedia("(display-mode: standalone)").matches ||+ window.matchMedia("(display-mode: fullscreen)").matches ||+ Boolean((navigator as Navigator & { standalone?: boolean }).standalone);++const getVerticalScrollContainer = (target: EventTarget | null) => {+ let element = target instanceof HTMLElement ? target : null;++ while (element && element !== document.body) {+ const style = window.getComputedStyle(element);+ const canScroll = /(auto|scroll)/.test(style.overflowY) && element.scrollHeight > element.clientHeight;++ if (canScroll) {+ return element;+ }++ element = element.parentElement;+ }++ return null;+};const EditorPane = lazy(() => import("./EditorPane").then((module) => ({ default: module.EditorPane })));const AssetsPane = lazy(() => import("./AssetsPane").then((module) => ({ default: module.AssetsPane })));@@ -454,6 +478,9 @@ export const WorkspaceApp = ({const [isOnline, setIsOnline] = useState(() => (typeof navigator === "undefined" ? true : navigator.onLine));const [isDesktop, setIsDesktop] = useState(isDesktopViewport);const [isSyncingQueuedChanges, setIsSyncingQueuedChanges] = useState(false);+ const [pullToRefreshDistance, setPullToRefreshDistance] = useState(0);+ const [isPullRefreshing, setIsPullRefreshing] = useState(false);+ const isPullRefreshingRef = useRef(false);const [mobileListActionsOpen, setMobileListActionsOpen] = useState(false);const [mobileMoveOpen, setMobileMoveOpen] = useState(false);@@ -486,6 +513,27 @@ export const WorkspaceApp = ({}}, [queryClient]);+ const refreshLatestMemos = useCallback(async () => {+ if (typeof navigator !== "undefined" && !navigator.onLine) {+ setIsOnline(false);+ setPullToRefreshDistance(0);+ return;+ }++ setIsPullRefreshing(true);++ try {+ await Promise.all([+ queryClient.invalidateQueries({ queryKey: ["memos"] }),+ queryClient.invalidateQueries({ queryKey: ["memo"] }),+ queryClient.invalidateQueries({ queryKey: ["notebooks"] }),+ ]);+ } finally {+ setIsPullRefreshing(false);+ setPullToRefreshDistance(0);+ }+ }, [queryClient]);+const notebooksQuery = useQuery({queryKey: ["notebooks"],queryFn: () => api.listNotebooks(),@@ -515,6 +563,21 @@ export const WorkspaceApp = ({activePane === "editor" ||activePane === "notebooks");+ const mobilePullToRefreshActive = Boolean(+ !isDesktop &&+ activePane === "memos" &&+ !appNoticeDialog &&+ !notebookDeleteConfirmation &&+ !notebookNameDialog &&+ !memoDeleteConfirmation &&+ !emptyTrashConfirmationOpen &&+ !mobileNotebookPickerOpen &&+ !mobileListActionsOpen &&+ !mobileMoveOpen &&+ !mobileMoreOpen &&+ !tagsOpen &&+ !templatesOpen+ );const clearMemoSelection = useCallback(() => {setSelectedMemoIds(new Set());@@ -600,6 +663,102 @@ export const WorkspaceApp = ({return () => mediaQuery.removeEventListener("change", updateDesktopState);}, []);+ useEffect(() => {+ isPullRefreshingRef.current = isPullRefreshing;+ }, [isPullRefreshing]);++ useEffect(() => {+ if (!mobilePullToRefreshActive || !isStandaloneApp()) {+ setPullToRefreshDistance(0);+ return;+ }++ let tracking = false;+ let startX = 0;+ let startY = 0;+ let currentDistance = 0;+ let scrollContainer: HTMLElement | null = null;++ const reset = () => {+ tracking = false;+ startX = 0;+ startY = 0;+ currentDistance = 0;+ scrollContainer = null;+ setPullToRefreshDistance(0);+ };++ const handleTouchStart = (event: TouchEvent) => {+ if (event.touches.length !== 1 || isPullRefreshingRef.current || isTextEntryTarget(event.target)) {+ return;+ }++ scrollContainer = getVerticalScrollContainer(event.target);++ if ((scrollContainer && scrollContainer.scrollTop > 0) || (!scrollContainer && window.scrollY > 0)) {+ return;+ }++ const touch = event.touches[0];+ tracking = true;+ startX = touch.clientX;+ startY = touch.clientY;+ };++ const handleTouchMove = (event: TouchEvent) => {+ if (!tracking || event.touches.length !== 1) {+ return;+ }++ if ((scrollContainer && scrollContainer.scrollTop > 0) || (!scrollContainer && window.scrollY > 0)) {+ reset();+ return;+ }++ const touch = event.touches[0];+ const deltaY = touch.clientY - startY;+ const deltaX = Math.abs(touch.clientX - startX);++ if (deltaY <= 0 || deltaX > deltaY) {+ reset();+ return;+ }++ currentDistance = Math.min(PULL_TO_REFRESH_MAX_PX, deltaY * 0.55);++ if (currentDistance > 8) {+ event.preventDefault();+ setPullToRefreshDistance(currentDistance);+ }+ };++ const handleTouchEnd = () => {+ if (!tracking) {+ return;+ }++ const shouldRefresh = currentDistance >= PULL_TO_REFRESH_TRIGGER_PX;+ reset();++ if (shouldRefresh) {+ setPullToRefreshDistance(PULL_TO_REFRESH_TRIGGER_PX);+ void refreshLatestMemos();+ }+ };++ document.addEventListener("touchstart", handleTouchStart, { passive: true });+ document.addEventListener("touchmove", handleTouchMove, { passive: false });+ document.addEventListener("touchend", handleTouchEnd, { passive: true });+ document.addEventListener("touchcancel", reset, { passive: true });++ return () => {+ document.removeEventListener("touchstart", handleTouchStart);+ document.removeEventListener("touchmove", handleTouchMove);+ document.removeEventListener("touchend", handleTouchEnd);+ document.removeEventListener("touchcancel", reset);+ };+ }, [mobilePullToRefreshActive, refreshLatestMemos]);+useEffect(() => {const updateOnlineState = () => {const online = navigator.onLine;@@ -1497,9 +1656,24 @@ export const WorkspaceApp = ({const shouldRenderRightPane = isDesktop || activePane === "editor";const rightPaneLoadingLabel =rightView === "settings" ? "正在加载个人中心" : rightView === "assets" ? "正在加载资源库" : "正在加载编辑器";+ const pullToRefreshVisible = pullToRefreshDistance > 0 || isPullRefreshing;+ const pullToRefreshReady = pullToRefreshDistance >= PULL_TO_REFRESH_TRIGGER_PX;+ const pullToRefreshLabel = isPullRefreshing ? "正在拉取最新笔记" : pullToRefreshReady ? "松开刷新" : "下拉刷新";return (<div className="flex h-[100dvh] overflow-hidden bg-emerald-50 text-slate-950">+ {pullToRefreshVisible && (+ <div+ className="pointer-events-none fixed inset-x-0 top-[max(0.75rem,env(safe-area-inset-top))] z-50 flex justify-center lg:hidden"+ style={{ transform: `translateY(${Math.max(0, pullToRefreshDistance - 24)}px)` }}+ aria-hidden="true"+ >+ <div className="inline-flex h-9 items-center gap-2 rounded-full border border-emerald-100 bg-white/95 px-3 text-xs font-semibold text-slate-600 shadow-[0_10px_28px_rgba(15,23,42,0.12)] backdrop-blur">+ <RefreshCw className={cn("h-4 w-4 text-emerald-600", (isPullRefreshing || pullToRefreshReady) && "animate-spin")} />+ <span>{pullToRefreshLabel}</span>+ </div>+ </div>+ )}<div className="min-w-0 flex-1"><mainclassName={cn(