refreshToken.js 666 B

12345678910111213141516171819202122232425
  1. const { Random } = require('mockjs')
  2. module.exports = [
  3. {
  4. url: '/refreshToken',
  5. type: 'get',
  6. response: (config) => {
  7. const authorization =
  8. config.headers.authorization || config.headers.Authorization
  9. let token = ''
  10. if (authorization.includes('admin-token'))
  11. token = `admin-token-${Random.guid()}`
  12. if (authorization.includes('editor-token'))
  13. token = `editor-token-${Random.guid()}`
  14. if (authorization.includes('test-token'))
  15. token = `test-token-${Random.guid()}`
  16. return {
  17. code: 402,
  18. msg: '模拟token无痛刷新成功',
  19. data: { token },
  20. }
  21. },
  22. },
  23. ]