/** * 角色上下文(前端本地保存当前身份,后端以 switchRole 校验权限) */ const ROLE_KEY = 'yjyf_role'; export function getRole() { try { return uni.getStorageSync(ROLE_KEY) || 'user'; } catch (e) { return 'user'; } } export function setRole(role) { uni.setStorageSync(ROLE_KEY, role === 'master' ? 'master' : 'user'); } export function clearRole() { uni.removeStorageSync(ROLE_KEY); }