eab91174db
Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
623 B
TypeScript
28 lines
623 B
TypeScript
import type { AuthUser } from '../api/types';
|
|
|
|
const KEY = 'pcm.family.session';
|
|
|
|
export interface Session {
|
|
token: string;
|
|
user: AuthUser;
|
|
/** 绑定的被照护孕妇档案 ID(家属受授权查看) */
|
|
boundPatientId: string | null;
|
|
}
|
|
|
|
export function loadSession(): Session | null {
|
|
try {
|
|
const raw = localStorage.getItem(KEY);
|
|
return raw ? (JSON.parse(raw) as Session) : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function saveSession(session: Session): void {
|
|
localStorage.setItem(KEY, JSON.stringify(session));
|
|
}
|
|
|
|
export function clearSession(): void {
|
|
localStorage.removeItem(KEY);
|
|
}
|