Add centralized API client with axios interceptors, remove vue-axios
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,6 @@ import { createApp, markRaw } from "vue";
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import pinia from '@/stores/main.js';
|
||||
import axios from 'axios';
|
||||
import VueAxios from 'vue-axios';
|
||||
import moment from 'moment';
|
||||
import mitt from 'mitt';
|
||||
import ToastPlugin from 'vue-toast-notification';
|
||||
@@ -49,15 +47,9 @@ import ContextMenu from 'primevue/contextmenu';
|
||||
const emitter = mitt();
|
||||
const app = createApp(App);
|
||||
|
||||
// 將 Axios 實例添加到 Vue 的應用實例中
|
||||
app.config.globalProperties.$http = axios;
|
||||
app.$http = axios; // 將 $http 添加到 Vue 實例中
|
||||
// Pinia Set
|
||||
pinia.use(({ store }) => {
|
||||
store.$router = markRaw(router);
|
||||
store.$axios = markRaw(axios);
|
||||
store.$toast = markRaw(ToastPlugin);
|
||||
store.$http = app.$http;
|
||||
});
|
||||
|
||||
// can use `this.$moment` in Vue.js
|
||||
@@ -72,7 +64,6 @@ cytoscape.use( popper((ref) => ref) );
|
||||
|
||||
app.use(pinia);
|
||||
app.use(router);
|
||||
app.use(VueAxios, axios);
|
||||
app.use(VueSweetalert2);
|
||||
app.use(ToastPlugin, { // use `this.$toast` in Vue.js
|
||||
position: 'bottom',
|
||||
|
||||
Reference in New Issue
Block a user