feat(web): React 19 + Vite + Tailwind v4 + shadcn foundation
- design tokens ported verbatim from the product design, data-theme light/dark - app shell: topbar, sidebar/rail/tabbar responsive nav, lang + theme menus - ui primitives (button/card/badge/dot/chip/tabs/dialog/sheet/toast/kv/seg/progress) - api client, reconnecting ws client, zustand stores, route guard to /connect - full zh/en dictionaries (key parity test), 32 vitest specs, dist committed
This commit is contained in:
1 parent
4e98ef8658
commit
5b55e622ea
63 files changed
+8466
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
import type { WorkspaceInfo } from "@/lib/protocol";
|
||||
|
||||
export type LoadStatus = "idle" | "loading" | "error" | "ready";
|
||||
|
||||
export interface WorkspacesStore {
|
||||
items: WorkspaceInfo[];
|
||||
status: LoadStatus;
|
||||
error: string | null;
|
||||
selectedId: string | null;
|
||||
|
||||
setWorkspaces: (items: WorkspaceInfo[]) => void;
|
||||
upsert: (item: WorkspaceInfo) => void;
|
||||
remove: (workspaceId: string) => void;
|
||||
select: (workspaceId: string | null) => void;
|
||||
setStatus: (status: LoadStatus, error?: string | null) => void;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
const initial = {
|
||||
items: [] as WorkspaceInfo[],
|
||||
status: "idle" as LoadStatus,
|
||||
error: null as string | null,
|
||||
selectedId: null as string | null,
|
||||
};
|
||||
|
||||
export const useWorkspacesStore = create<WorkspacesStore>((set) => ({
|
||||
...initial,
|
||||
|
||||
setWorkspaces: (items) => set({ items, status: "ready", error: null }),
|
||||
|
||||
upsert: (item) =>
|
||||
set((state) => {
|
||||
const index = state.items.findIndex((w) => w.workspaceId === item.workspaceId);
|
||||
if (index === -1) return { items: [...state.items, item] };
|
||||
const items = state.items.slice();
|
||||
items[index] = item;
|
||||
return { items };
|
||||
}),
|
||||
|
||||
remove: (workspaceId) =>
|
||||
set((state) => ({
|
||||
items: state.items.filter((w) => w.workspaceId !== workspaceId),
|
||||
selectedId: state.selectedId === workspaceId ? null : state.selectedId,
|
||||
})),
|
||||
|
||||
select: (selectedId) => set({ selectedId }),
|
||||
|
||||
setStatus: (status, error = null) => set({ status, error }),
|
||||
|
||||
reset: () => set(initial),
|
||||
}));
|
||||
Reference in new issue
Block a user