feat:前端

This commit is contained in:
2026-09-14 11:54:20 +08:00
parent 86b13c6484
commit e2e1d73b3d
46 changed files with 4477 additions and 128 deletions
+40
View File
@@ -0,0 +1,40 @@
const TOKEN_KEY = "huaxia_token";
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 const roleLabels: Record<string, string> = {
投顾: "投顾专员",
投顾专员: "投顾专员",
风控专员: "风控专员",
ADMIN: "员工通用",
EMPLOYEE: "员工通用",
};
export function getRoleLabel(role?: string | null) {
return role ? roleLabels[role] ?? "员工通用" : "员工通用";
}
export function getPostLoginPath(user?: { user_type?: string | null; employee_role?: string | null }) {
if (!user || user.user_type === "CUSTOMER") return "/account";
if (user.user_type === "ADMIN") return "/admin/common";
switch (getRoleLabel(user.employee_role)) {
case "投顾专员":
return "/admin/advisor";
case "风控专员":
return "/admin/risk";
default:
return "/admin/common";
}
}