double.huang 5 лет назад
Родитель
Сommit
f118928b05
5 измененных файлов с 34 добавлено и 9 удалено
  1. 1 0
      .gitignore
  2. 19 0
      Dockerfile
  3. 2 0
      nginx.conf
  4. 2 2
      public/domain.js
  5. 10 7
      src/utils/request.js

+ 1 - 0
.gitignore

@@ -21,3 +21,4 @@ selenium-debug.log
 
 package-lock.json
 yarn.lock
+.drone.yml

+ 19 - 0
Dockerfile

@@ -0,0 +1,19 @@
+FROM nginx:stable-alpine
+
+RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main/" > /etc/apk/repositories
+RUN apk update && apk add tzdata \
+    && rm -f /etc/localtime \
+    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+WORKDIR /usr/share/nginx/html
+RUN mkdir -p /usr/share/nginx/html/admin
+RUN mkdir -p /usr/share/nginx/html/static
+RUN mkdir -p /etc/nginx/conf.d/
+
+COPY nginx.conf /etc/nginx/conf.d/nginx.conf
+COPY dist /usr/share/nginx/html/
+COPY dist /usr/share/nginx/html/admin/
+COPY dist/static /usr/share/nginx/html/static/
+
+EXPOSE 80
+CMD [ "nginx", "-g", "daemon off;" ]

+ 2 - 0
nginx.conf

@@ -0,0 +1,2 @@
+client_max_body_size 1024m;
+underscores_in_headers on;

+ 2 - 2
public/domain.js

@@ -4,8 +4,8 @@ window.Domain = {
     "contact_name": null,
     "contact_email": null,
     "contact_mobile": null,
-    "login_url": "127.0.0.1",
-    "api_url": "http://127.0.0.1:8082",
+    "login_url": "localhost",
+    "api_url": "http://localhost:8082",
     "static_url": null,
     "theme": "default",
     "auth_mode": 1

+ 10 - 7
src/utils/request.js

@@ -50,40 +50,43 @@ service.interceptors.response.use(
     const { msg, code = 'Error' } = response.data
     if (code !== 200) {
       if (code === 403) {
-        Message({
+        return Message({
           message: 'Insufficient permissions, please contact your administrator',
           type: 'error',
           duration: 5 * 1000
+        }).then(() => {
+          return Promise.reject(new Error(msg))
         })
       } else if (code === 401) {
-        MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
+        return MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
           confirmButtonText: 'Re-Login',
           cancelButtonText: 'Cancel',
           type: 'warning'
         }).then(() => {
-          store.dispatch('user/resetToken').then(() => {
+          return store.dispatch('user/resetToken').then(() => {
             location.reload()
           })
         })
       } else {
-        Message({
+        return Message({
           message: msg,
           type: 'error',
           duration: 5 * 1000
+        }).then(() => {
+          return Promise.reject(new Error(msg))
         })
       }
-      return Promise.reject(new Error(msg))
     }
     return response.data
   },
   error => {
-    console.log(error)
     Message({
       message: error.message,
       type: 'error',
       duration: 5 * 1000
+    }).then(() => {
+      return Promise.reject(error)
     })
-    return Promise.reject(error)
   }
 )