Step F1:前端工程骨架 & 登录鉴权

This commit is contained in:
Cheng Zhou
2025-12-16 20:21:30 +08:00
parent 5eab324c50
commit 78d13d077c
25 changed files with 523 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
const TOKEN_KEY = "ctms_token";
export const getToken = (): string | null => localStorage.getItem(TOKEN_KEY);
export const setToken = (token: string): void => {
localStorage.setItem(TOKEN_KEY, token);
};
export const clearToken = (): void => {
localStorage.removeItem(TOKEN_KEY);
};
+6
View File
@@ -0,0 +1,6 @@
// 预留权限工具,可在后续基于 role 与项目内角色实现细粒度控制
export const hasPermission = (requiredRoles: string[], userRole?: string): boolean => {
if (!requiredRoles.length) return true;
if (!userRole) return false;
return requiredRoles.includes(userRole);
};