Browse Source

Merge branch 'feature/url_str' of duanxiaoduan/tmr-admin into develop

xuyiping 1 year ago
parent
commit
4f3c3a418b
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/utils/request.js

+ 8 - 4
src/utils/request.js

@@ -2,18 +2,22 @@ import axios from 'axios'
 import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
-import Cookies from 'js-cookie';
+import Cookies from 'js-cookie';
 
 //获取当前url
 const DoMainString = document.querySelector("html").getAttribute("domain");
 var URL = process.env.VUE_APP_BASE_API
 if (DoMainString) {
   URL = DoMainString
-}
+}
+
+var reg = /http:\/\/.*\.[0-9]{1,4}(:[\w]+)?/g
+var browserUrl = window.location.hostname
 
-if(URL.indexOf('/')==0 && URL.length==1){
-  URL= window.location.protocol + "//"+window.location.host+URL
+if (reg.test(browserUrl)){
+  URL = browserUrl
 }
+
 Cookies.set('url',URL)
 console.log(process.env.VUE_APP_BASE_API,'===========URL1111')
 console.log(URL,'===========URL')