大型前端项目 service 如何定义 All In One
大型前端项目 service 如何定义 All In One
react / typescript
https://github.com/ant-design/ant-design-pro/blob/master/src/services/user.ts
import request from '@/utils/request';
export async function query(): Promise<any> {
return request('/api/users');
}
export async function queryCurrent(): Promise<any> {
return request('/api/currentUser');
}
export async function queryNotices(): Promise<any> {
return request('/api/notices');
}
vue
https://github.com/PanJiaChen/vue-element-admin/blob/master/src/api/user.js
import request from '@/utils/request'
export function login(data) {
return request({
url: '/vue-element-admin/user/login',
method: 'post',
data
})
}
export function getInfo(token) {
return request({
url: '/vue-element-admin/user/info',
method: 'get',
params: { token }
})
}
export function logout() {
return request({
url: '/vue-element-admin/user/logout',
method: 'post'
})
}
refs
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14797025.html
未经授权禁止转载,违者必究!