interface UserInfo { roleName: string; job: string; departmentName: string; createTime: string; email: null | string; id: string; mobile: null | string; updateTime: string; userName: string; status: string; } export enum VersionCodeEnum { 高速 = "highWay", 城市 = "city", 服务区 = "service", } interface UserPermission { admin: number; areaUid?: string; projectAlias: string; remindVoice: string; title: string; versionCode: VersionCodeEnum; iconHashName?: string; ip?: string; userId?: string; } export const USER_INFO = "USER_INFO"; export const USER_PERMISSION = "USER_PERMISSION"; export const TOKEN = "token"; export const DING_LOGIN_URL = "https://its-demo.yucekj.com/api/rest/v2/unsecure/thirdPartyLogin/loginRedirect?thirdPartyType=DINGTALK&callbackUrl="; export const DING_BACKEND_URL = "http://its-demo.yucekj.com/api/user/initUserConfig?callback="; export const getUserInfo = (): UserInfo | null => { const userInfo = localStorage.getItem(USER_INFO); if (userInfo === null) { return null; } else { return JSON.parse(userInfo); } }; export const getUserName = (): string | undefined => { const userPermission = getUserInfo(); if (userPermission) { return userPermission.userName; } }; export const getRoleName = (): string | undefined => { const userPermission = getUserInfo(); if (userPermission) { return userPermission.roleName; } }; export const getUserPermission = (): UserPermission | null => { const userPermission = localStorage.getItem(USER_PERMISSION); if (userPermission === null) { return null; } else { return JSON.parse(userPermission); } }; export const getRemindVoice = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.remindVoice; } }; export const getVersionCode = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.versionCode; } }; export const getServiceVersion = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.projectAlias; } }; export const getTitle = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.title; } }; export const getIconHashName = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.iconHashName; } }; export const getAreaUid = (): string | undefined => { const userPermission = getUserPermission(); if (userPermission) { return userPermission.areaUid; } };