Browse Source

所有的请求头里加上groupCode、projectId
其值的来源是vuex里的selectProject的id和groupCode

niuheng 3 years ago
parent
commit
7f87c890e0
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/utils/http/axiosUtils.ts

+ 4 - 0
src/utils/http/axiosUtils.ts

@@ -5,6 +5,7 @@
 
 
 import axios from 'axios'
+import vueStore from '@/store'
 
 var CancelToken = axios.CancelToken
 var cancel
@@ -80,6 +81,9 @@ export class axiosUtils {
      */
     protected async customRequest(url: string, headers: any, data: any, method: string = 'post') {
         try {
+            headers = headers || {};
+            headers.groupCode = headers.groupCode || vueStore.state.selectProject.groupCode;
+            headers.projectId= headers.projectId || vueStore.state.selectProject.id;
             let response = await axiosservice({
                 url,
                 headers: headers || {},