Browse Source

Merge branch 'develop' into feature/img_url

# Conflicts:
#	.env.development
duanxiaoduan 1 year ago
parent
commit
13162b2157
5 changed files with 78 additions and 48 deletions
  1. 1 1
      .drone.yml
  2. 30 0
      .env.development
  3. 1 7
      .env.production
  4. 2 0
      Dockerfile
  5. 44 40
      src/utils/request.js

+ 1 - 1
.drone.yml

@@ -20,7 +20,7 @@ steps:
         from_secret: aliyun_password
       repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/tmr-admin
       registry: registry.cn-hangzhou.aliyuncs.com
-      tags: [ shengmu25 ]
+      tags: [1.0.0,latest]
 
 trigger:
   branch:

+ 30 - 0
.env.development

@@ -7,8 +7,13 @@ ENV = 'development'
 VUE_APP_BASE_API = 'http://192.168.1.70:8082/'
 
 #许义平本地
+<<<<<<< .mine
 # VUE_APP_BASE_API = 'http://192.168.1.96:8082/'
+=======
+VUE_APP_BASE_API = 'http://192.168.1.70:8088/'
+>>>>>>> .theirs
 
+<<<<<<< .mine
 
 # VUE_APP_BASE_API = 'http://kpttest.kptyun.com/'
 # VUE_APP_BASE_API = 'http://kpttestnt.kptyun.com/'
@@ -32,6 +37,31 @@ VUE_APP_BASE_API = 'http://192.168.1.70:8082/'
 # 白少杰
 # VUE_APP_BASE_API = 'http://192.168.1.77:8081/'
 
+=======
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> .theirs
 # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
 # to control whether the babel-plugin-dynamic-import-node plugin is enabled.
 # It only does one thing by converting all import() to require().

+ 1 - 7
.env.production

@@ -4,10 +4,4 @@ ENV = 'production'
 # base api
 # 正式线
 # VUE_APP_BASE_API = ':8081/'
-# VUE_APP_BASE_API = '/'
-# 测试线
-# VUE_APP_BASE_API = 'http://192.168.1.70:8083/'
-# VUE_APP_BASE_API = 'http://kpt8088.kptyun.com/'
-# VUE_APP_BASE_API = 'http://kpt8089.kptyun.com/'
-# VUE_APP_BASE_API = 'http://kpt8082.kptyun.com/'
-VUE_APP_BASE_API = 'http://kpt8083.kptyun.com/'
+VUE_APP_BASE_API = 'http://192.168.1.70:8088/'

+ 2 - 0
Dockerfile

@@ -14,3 +14,5 @@ FROM nginx:alpine
 COPY --from=builder /app/tmr-admin/dist/ /usr/share/nginx/html/
 COPY --from=builder /app/tmr-admin/default.conf.template /etc/nginx/templates/default.conf.template
 EXPOSE 80
+
+CMD ["/bin/sh", "-c", "sed -i \"s@<html@<html domain=\"$DOMAIN\"@\" /usr/share/nginx/html/index.html; nginx -g \"daemon off;\""]

+ 44 - 40
src/utils/request.js

@@ -2,21 +2,25 @@ import axios from 'axios'
 import { MessageBox, Message } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
-
-//获取当前url
-
-var aa = process.env.VUE_APP_BASE_API
-//获取当前url
-
-if(aa.indexOf('/')==0 && aa.length==1){
-  aa= window.location.protocol + "//"+window.location.host+aa
-}
-  const service = axios.create({
-    baseURL: aa, // url = base url + request url
-    withCredentials: true, // send cookies when cross-domain requests
-    timeout: 60000 ,// request timeout
-  })
-// request interceptor
+
+//获取当前url
+const DoMainString = document.querySelector("html").getAttribute("domain");
+var URL = process.env.VUE_APP_BASE_API
+if (DoMainString) {
+  URL = DoMainString
+}
+console.log(URL,'===========URL')
+
+if(URL.indexOf('/')==0 && URL.length==1){
+  URL= window.location.protocol + "//"+window.location.host+aa
+}
+
+const service = axios.create({
+  baseURL: URL, // url = base url + request url
+  withCredentials: true, // send cookies when cross-domain requests
+  timeout: 60000 ,// request timeout
+})
+// request interceptor
 service.interceptors.request.use(
   config => {
     // do something before request is sent
@@ -35,7 +39,7 @@ service.interceptors.request.use(
       } else {
         config.headers['token'] = getToken()
       }
-    }
+    }
     return config
   },
   error => {
@@ -97,30 +101,30 @@ service.interceptors.response.use(
     }
   },
   error => {
-    console.log('err' + error) // for debug
-    let config = error.config
-    if (!config) {
-      Message({ message: error.message, type: 'error', duration: 5 * 1000 })
-      return Promise.reject(error)
-    }
-    console.log('config==>', config) // for debug
-    console.log('config.__retryCount==>', config.__retryCount) // for debug
-    // 设置请求超时次数
-    config.__retryCount = config.__retryCount || 0
-    if (config.__retryCount >= 3) {
-      // Message({ message:error.message, type: 'error', duration: 5 * 1000 })
-      Message({ message:'请求超时', type: 'error', duration: 5 * 1000 })
-      // Message.error((error && error.data && error.data.msg) || '请求超时')
-      return Promise.reject(error)
-    }
-    config.__retryCount += 1
-    let backoff = new Promise((resolve) => {
-      setTimeout(() => {
-        resolve()
-      }, config.retryDelay || 1000)
-    })
-    return backoff.then(() => {
-      return service(config)
+    console.log('err' + error) // for debug
+    let config = error.config
+    if (!config) {
+      Message({ message: error.message, type: 'error', duration: 5 * 1000 })
+      return Promise.reject(error)
+    }
+    console.log('config==>', config) // for debug
+    console.log('config.__retryCount==>', config.__retryCount) // for debug
+    // 设置请求超时次数
+    config.__retryCount = config.__retryCount || 0
+    if (config.__retryCount >= 3) {
+      // Message({ message:error.message, type: 'error', duration: 5 * 1000 })
+      Message({ message:'请求超时', type: 'error', duration: 5 * 1000 })
+      // Message.error((error && error.data && error.data.msg) || '请求超时')
+      return Promise.reject(error)
+    }
+    config.__retryCount += 1
+    let backoff = new Promise((resolve) => {
+      setTimeout(() => {
+        resolve()
+      }, config.retryDelay || 1000)
+    })
+    return backoff.then(() => {
+      return service(config)
     })
     // Message({
     //   message: error.message,