perf: 修改接口请求的axios实例别名

This commit is contained in:
zhangchuanlong 2022-03-14 16:36:21 +08:00
parent a44be5aec0
commit 606334ffad
3 changed files with 15 additions and 15 deletions

View File

@ -1,7 +1,7 @@
import { defAxios } from '@/utils/http' import { defAxios as request } from '@/utils/http'
export const login = (data) => { export const login = (data) => {
return defAxios({ return request({
url: '/auth/login', url: '/auth/login',
method: 'post', method: 'post',
data, data,
@ -9,7 +9,7 @@ export const login = (data) => {
} }
export const refreshToken = () => { export const refreshToken = () => {
return defAxios({ return request({
url: '/auth/refreshToken', url: '/auth/refreshToken',
method: 'post', method: 'post',
}) })

View File

@ -1,7 +1,7 @@
import { defAxios } from '@/utils/http' import { defAxios as request } from '@/utils/http'
export function getPosts(data = {}) { export function getPosts(data = {}) {
return defAxios({ return request({
url: '/posts', url: '/posts',
method: 'get', method: 'get',
data, data,
@ -9,7 +9,7 @@ export function getPosts(data = {}) {
} }
export function getPostById({ id }) { export function getPostById({ id }) {
return defAxios({ return request({
url: `/post/${id}`, url: `/post/${id}`,
method: 'get', method: 'get',
}) })
@ -17,14 +17,14 @@ export function getPostById({ id }) {
export function savePost(id, data = {}) { export function savePost(id, data = {}) {
if (id) { if (id) {
return defAxios({ return request({
url: `/post/${id}`, url: `/post/${id}`,
method: 'put', method: 'put',
data, data,
}) })
} }
return defAxios({ return request({
url: '/post', url: '/post',
method: 'post', method: 'post',
data, data,
@ -32,7 +32,7 @@ export function savePost(id, data = {}) {
} }
export function deletePost(id) { export function deletePost(id) {
return defAxios({ return request({
url: `/post/${id}`, url: `/post/${id}`,
method: 'delete', method: 'delete',
}) })

View File

@ -1,7 +1,7 @@
import { defAxios } from '@/utils/http' import { defAxios as request } from '@/utils/http'
export function getUsers(data = {}) { export function getUsers(data = {}) {
return defAxios({ return request({
url: '/users', url: '/users',
method: 'get', method: 'get',
data, data,
@ -10,12 +10,12 @@ export function getUsers(data = {}) {
export function getUser(id) { export function getUser(id) {
if (id) { if (id) {
return defAxios({ return request({
url: `/user/${id}`, url: `/user/${id}`,
method: 'get', method: 'get',
}) })
} }
return defAxios({ return request({
url: '/user', url: '/user',
method: 'get', method: 'get',
}) })
@ -23,14 +23,14 @@ export function getUser(id) {
export function saveUser(data = {}, id) { export function saveUser(data = {}, id) {
if (id) { if (id) {
return defAxios({ return request({
url: '/user', url: '/user',
method: 'put', method: 'put',
data, data,
}) })
} }
return defAxios({ return request({
url: `/user/${id}`, url: `/user/${id}`,
method: 'put', method: 'put',
data, data,