wireguard-dashboard-admin/mock/api/user.js

40 lines
798 B
JavaScript
Raw Normal View History

2022-06-26 18:42:07 +08:00
import { resolveToken } from '../utils'
2022-01-08 17:20:46 +08:00
const users = {
admin: {
id: 1,
name: '大脸怪(admin)',
2022-03-26 17:50:29 +08:00
avatar: 'https://assets.qszone.com/images/avatar.jpg',
2022-01-08 17:20:46 +08:00
email: 'Ronnie@123.com',
role: ['admin'],
},
editor: {
id: 2,
name: '大脸怪(editor)',
2022-03-26 17:50:29 +08:00
avatar: 'https://assets.qszone.com/images/avatar.jpg',
2022-01-08 17:20:46 +08:00
email: 'Ronnie@123.com',
role: ['editor'],
},
guest: {
id: 3,
name: '访客(guest)',
2022-03-26 17:50:29 +08:00
avatar: 'https://assets.qszone.com/images/avatar.jpg',
2022-01-08 17:20:46 +08:00
role: [],
},
}
export default [
{
2022-02-09 17:46:25 +08:00
url: '/api/user',
2022-01-08 17:20:46 +08:00
method: 'get',
response: ({ headers }) => {
const token = resolveToken(headers?.authorization)
return {
code: 0,
data: {
...(users[token] || users.guest),
},
}
},
},
]