Initial commit

This commit is contained in:
xggz
2026-03-06 22:56:13 +08:00
commit 54d1097b41
273 changed files with 92457 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
"use client"
const WORKSPACE_MODES = ["conversation", "fusion", "files"] as const
export type PersistedWorkspaceMode = (typeof WORKSPACE_MODES)[number]
interface PersistedWorkspaceState {
mode: PersistedWorkspaceMode
}
function isWorkspaceMode(value: unknown): value is PersistedWorkspaceMode {
return WORKSPACE_MODES.includes(value as PersistedWorkspaceMode)
}
export function loadPersistedWorkspaceMode(
storageKey: string
): PersistedWorkspaceMode | null {
if (typeof window === "undefined") return null
try {
const raw = localStorage.getItem(storageKey)
if (!raw) return null
const parsed = JSON.parse(raw) as Partial<PersistedWorkspaceState>
if (!isWorkspaceMode(parsed.mode)) return null
return parsed.mode
} catch {
return null
}
}
export function savePersistedWorkspaceMode(
storageKey: string,
mode: PersistedWorkspaceMode
) {
if (typeof window === "undefined") return
try {
localStorage.setItem(storageKey, JSON.stringify({ mode }))
} catch {
/* ignore */
}
}