- mobile-web/:独立的 Vue3 + TS + WeUI 手机网页(开发端口 7303、预览 7304, /api 反代到后端 7300);node_modules/、dist/ 由根 .gitignore 统一覆盖 - tools/scan-web-viewer.ps1:扫局域网 80 端口并按网页标题匹配设备的排查脚本 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
36 lines
831 B
TypeScript
36 lines
831 B
TypeScript
export interface MobileUser {
|
|
id: number;
|
|
username?: string | null;
|
|
nickname?: string | null;
|
|
email?: string | null;
|
|
phone?: string | null;
|
|
avatar?: string | null;
|
|
}
|
|
|
|
export interface LoginResult {
|
|
token: string;
|
|
user: MobileUser;
|
|
}
|
|
|
|
export function readUser(): MobileUser | null {
|
|
try {
|
|
const stored = localStorage.getItem('packs_user');
|
|
return stored ? (JSON.parse(stored) as MobileUser) : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function getToken(): string {
|
|
return localStorage.getItem('packs_token') || '';
|
|
}
|
|
|
|
export function clearSession(): void {
|
|
localStorage.removeItem('packs_token');
|
|
localStorage.removeItem('packs_user');
|
|
}
|
|
|
|
export function getDisplayName(user: MobileUser | null): string {
|
|
return user?.nickname || user?.username || (user ? `用户 ${user.id}` : '访客');
|
|
}
|