小说后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 lines
1.5 KiB

  1. const tokens = {
  2. '19923693200': {
  3. token: 'admin-token'
  4. },
  5. editor: {
  6. token: 'editor-token'
  7. }
  8. }
  9. const users = {
  10. 'admin-token': {
  11. roles: ['admin'],
  12. introduction: 'I am a super administrator',
  13. avatar:
  14. 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  15. name: 'Super Admin'
  16. },
  17. 'editor-token': {
  18. roles: ['editor'],
  19. introduction: 'I am an editor',
  20. avatar:
  21. 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  22. name: 'Normal Editor'
  23. }
  24. }
  25. module.exports = [
  26. // user login
  27. {
  28. url: '/vue-element-admin/user/login',
  29. type: 'post',
  30. response: config => {
  31. const { phone } = config.body
  32. const token = tokens[phone]
  33. // mock error
  34. if (!token) {
  35. return {
  36. code: 60204,
  37. message: 'Account and password are incorrect.'
  38. }
  39. }
  40. return {
  41. code: 20000,
  42. data: token
  43. }
  44. }
  45. },
  46. // get user info
  47. {
  48. url: '/vue-element-admin/user/info.*',
  49. type: 'get',
  50. response: config => {
  51. const { token } = config.query
  52. const info = users[token]
  53. // mock error
  54. if (!info) {
  55. return {
  56. code: 50008,
  57. message: 'Login failed, unable to get user details.'
  58. }
  59. }
  60. return {
  61. code: 20000,
  62. data: info
  63. }
  64. }
  65. },
  66. // user logout
  67. {
  68. url: '/vue-element-admin/user/logout',
  69. type: 'post',
  70. response: _ => {
  71. return {
  72. code: 20000,
  73. data: 'success'
  74. }
  75. }
  76. }
  77. ]