diff --git a/src/utils/AxiosDr.js b/src/utils/AxiosDr.js new file mode 100644 index 0000000..71d01e7 --- /dev/null +++ b/src/utils/AxiosDr.js @@ -0,0 +1,51 @@ +/* + 作者: 邓瑞 + 版本: 1.0 + 网站: www.dengruicode.com + 日期: 2024-04-21 +*/ + +import axios from 'axios' + +const axiosInstance = axios.create({ // axios 实例 + //baseURL: "http://127.0.0.1:8008", + baseURL: import.meta.env.VITE_API_URL, + timeout: 5000 +}) + +const get = (url, data = {}) => { + return axiosInstance.get(url, { params: data }).then(response => response.data) +} + +const post = (url, data = null) => { + return axiosInstance.post(url, data).then(response => response.data) +} + +const postForm = (url, data = null) => { + return axiosInstance.post(url, data, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) + .then(response => response.data) +} + +const postFile = (url, data = null) => { + return axiosInstance.post(url, data, { + headers: { + 'Content-Type': 'multipart/form-data' + } + }) + .then(response => response.data) +} + +const postToken = (url, token, data = null) => { + return axiosInstance.post(url, data, { + headers: { + 'Authorization': `Bearer ${token}` + } + }) + .then(response => response.data) +} + +export default { get, post, postForm, postFile, postToken } diff --git a/src/views/admin/administrator/list.vue b/src/views/admin/administrator/list.vue index f26cdcc..6f4bc44 100644 --- a/src/views/admin/administrator/list.vue +++ b/src/views/admin/administrator/list.vue @@ -15,13 +15,37 @@