auth.js 860 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Cookies from 'js-cookie'
  2. export const TokenKey = 'vue_admin_template_token'
  3. export function getToken (name = TokenKey) {
  4. return Cookies.get(name)
  5. }
  6. export function setToken (name = TokenKey, token) {
  7. return Cookies.set(name, token)
  8. }
  9. export function setUserId (id) {
  10. return sessionStorage.setItem("User_Id", id)
  11. }
  12. export function getUserId () {
  13. return sessionStorage.getItem("User_Id")
  14. }
  15. export function removeToken (name = TokenKey) {
  16. return Cookies.remove(name)
  17. }
  18. export function setCodeToken (token) {
  19. return Cookies.set('codeToken', token)
  20. }
  21. export function getCodeToken () {
  22. return Cookies.get('codeToken')
  23. }
  24. export function setLogId(id) {
  25. sessionStorage.setItem('LogId', id)
  26. }
  27. export function getLogId() {
  28. return sessionStorage.getItem('LogId')
  29. }
  30. export function removeLogId() {
  31. sessionStorage.removeItem('LogId')
  32. }