Files

22 lines
936 B
TypeScript
Raw Permalink Normal View History

2026-09-14 19:00:48 +08:00
import { USER_TYPE } from "@/lib/roles";
2026-09-14 11:54:20 +08:00
const TOKEN_KEY = "huaxia_token";
2026-09-14 19:00:48 +08:00
/** 前端只负责展示友好名称,取值契约见 lib/roles.ts。 */
2026-09-14 11:54:20 +08:00
export const roleLabels: Record<string, string> = {
2026-09-14 19:00:48 +08:00
管理员: "管理员",
2026-09-14 11:54:20 +08:00
投顾: "投顾专员",
风控专员: "风控专员",
2026-09-14 19:00:48 +08:00
客户经理: "客户经理",
2026-09-14 11:54:20 +08:00
};
2026-09-14 19:00:48 +08:00
export function getToken() { if (typeof window === "undefined") return null; return localStorage.getItem(TOKEN_KEY); }
export function setToken(token: string) { localStorage.setItem(TOKEN_KEY, token); }
export function clearToken() { localStorage.removeItem(TOKEN_KEY); }
export function getRoleLabel(role?: string | null) { return role ? roleLabels[role] ?? "员工" : "员工"; }
2026-09-14 11:54:20 +08:00
2026-09-14 19:00:48 +08:00
/** 客户进入客户端,所有员工统一进入员工工作台。 */
export function getPostLoginPath(user?: { user_type?: string | null }) {
return user?.user_type === USER_TYPE.CUSTOMER ? "/account" : "/admin/common";
2026-09-14 11:54:20 +08:00
}