auth.js 550 B

12345678910111213141516171819202122
  1. const AccessTokenKey = 'ACCESS_TOKEN'
  2. const RefreshTokenKey = 'REFRESH_TOKEN'
  3. // ========== Token 相关 ==========
  4. export function getAccessToken() {
  5. return uni.getStorageSync(AccessTokenKey)
  6. }
  7. export function getRefreshToken() {
  8. return uni.getStorageSync(RefreshTokenKey)
  9. }
  10. export function setToken(token) {
  11. uni.setStorageSync(AccessTokenKey, token.accessToken)
  12. uni.setStorageSync(RefreshTokenKey, token.refreshToken)
  13. }
  14. export function removeToken() {
  15. uni.removeStorageSync(AccessTokenKey)
  16. uni.removeStorageSync(RefreshTokenKey)
  17. }