user.ts 699 B

12345678910111213141516171819202122
  1. import { IUser } from './user.d';
  2. // #ifdef DEV
  3. import dictionary from './user.store';
  4. console.groupCollapsed('user');
  5. console.log('port : ', location.port);
  6. console.log(`dictionary[${location.port}] : `, dictionary[location.port]);
  7. console.groupEnd();
  8. localStorage.setItem(
  9. "userInfo",
  10. JSON.stringify(
  11. dictionary[location.port]
  12. )
  13. )
  14. // #endif
  15. let user = reactive<IUser>(JSON.parse(localStorage.getItem('userInfo') as string))
  16. console.log('user :>> ', user);
  17. export default user
  18. const ROLE_MAP: { [key: string]: 'teacher' | 'student' } = { '72': 'teacher', '75': 'teacher', '76': 'student' }
  19. export const UserRole: 'teacher' | 'student' | 'other' = ROLE_MAP[user.user_role_id] ?? 'other'