multica/apps/web/features/navigation/store.ts
Naiyuan Qing 459d9745b9 feat(ui): route persistence, sidebar active fix, header spacing
- Persist last visited path via Zustand persist, restore on login/root
- Sidebar: exact match for active state (issue detail no longer highlights Issues)
- Sidebar header: increase vertical padding
- Inbox unread count: simplified to text-xs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 10:57:32 +08:00

29 lines
644 B
TypeScript

"use client";
import { create } from "zustand";
import { persist } from "zustand/middleware";
const EXCLUDED_PREFIXES = ["/login", "/pair/"];
interface NavigationState {
lastPath: string;
onPathChange: (path: string) => void;
}
export const useNavigationStore = create<NavigationState>()(
persist(
(set) => ({
lastPath: "/issues",
onPathChange: (path: string) => {
if (!EXCLUDED_PREFIXES.some((prefix) => path.startsWith(prefix))) {
set({ lastPath: path });
}
},
}),
{
name: "multica_navigation",
partialize: (state) => ({ lastPath: state.lastPath }),
}
)
);