auth.uts 413 B

123456789101112131415161718
  1. export const TOKEN_KEY : string = 'token'
  2. export const USER_INFO_KEY : string = 'userInfo'
  3. export function isLogin() : boolean {
  4. const token = uni.getStorageSync(TOKEN_KEY)
  5. if (token == null) {
  6. return false
  7. }
  8. return (token as string).length > 0
  9. }
  10. export function getToken() : string {
  11. const token = uni.getStorageSync(TOKEN_KEY)
  12. if (token == null) {
  13. return ''
  14. }
  15. return token as string
  16. }