From 73c4dd1df328945a5accd5db7ee1172fd0bd3769 Mon Sep 17 00:00:00 2001 From: pjhmizn49 Date: Fri, 13 Dec 2024 09:00:20 +0800 Subject: [PATCH] ADD file via upload --- flower_admin_front/src/plugins/axios.js | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 flower_admin_front/src/plugins/axios.js diff --git a/flower_admin_front/src/plugins/axios.js b/flower_admin_front/src/plugins/axios.js new file mode 100644 index 0000000..dacf195 --- /dev/null +++ b/flower_admin_front/src/plugins/axios.js @@ -0,0 +1,61 @@ +"use strict"; + +import Vue from 'vue'; +import axios from "axios"; + +// Full config: https://github.com/axios/axios#request-config +// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || ''; +// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; +// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + +let config = { + // baseURL: process.env.baseURL || process.env.apiUrl || "" + // timeout: 60 * 1000, // Timeout + // withCredentials: true, // Check cross-site Access-Control +}; + +const _axios = axios.create(config); + +_axios.interceptors.request.use( + function(config) { + // Do something before request is sent + return config; + }, + function(error) { + // Do something with request error + return Promise.reject(error); + } +); + +// Add a response interceptor +_axios.interceptors.response.use( + function(response) { + // Do something with response data + return response; + }, + function(error) { + // Do something with response error + return Promise.reject(error); + } +); + +Plugin.install = function(Vue, options) { + Vue.axios = _axios; + window.axios = _axios; + Object.defineProperties(Vue.prototype, { + axios: { + get() { + return _axios; + } + }, + $axios: { + get() { + return _axios; + } + }, + }); +}; + +Vue.use(Plugin) + +export default Plugin;