Explorar el Código

本地配置OK,还差服务器nginx配置

龚成明 hace 3 años
padre
commit
5e9002c6cc
Se han modificado 10 ficheros con 55 adiciones y 71 borrados
  1. 3 0
      .env.development
  2. 3 0
      .env.production
  3. 2 0
      .gitignore
  4. 3 7
      src/components/Config.vue
  5. 2 4
      src/components/History.vue
  6. 1 4
      src/components/My.vue
  7. 1 4
      src/components/New.vue
  8. 25 51
      src/plugins/axios.js
  9. 14 0
      upload
  10. 1 1
      vue.config.js

+ 3 - 0
.env.development

@@ -0,0 +1,3 @@
+VUE_APP_ENV = 'dev'
+
+VUE_APP_BASE_URL = '/api'

+ 3 - 0
.env.production

@@ -0,0 +1,3 @@
+VUE_APP_ENV = 'pro'
+
+VUE_APP_BASE_URL = '/api'

+ 2 - 0
.gitignore

@@ -1,4 +1,6 @@
 .DS_Store
+nginx.conf
+server.xml
 /node_modules
 /dist
 

+ 3 - 7
src/components/Config.vue

@@ -247,7 +247,7 @@ export default {
       this.loading = true
 
       if (this.editedIndex > -1) {
-        const { data: rst } = await axios.get(this.url + '/config/update', { params: this.editedItem })
+        const { data: rst } = await axios.get('/config/update', { params: this.editedItem })
 
         if (rst.state) {
           Object.assign(this.tableData[this.editedIndex], rst.data)
@@ -258,7 +258,7 @@ export default {
           this.snackbarFail(rst.msg)
         }
       } else {
-        const { data: rst } = await axios.get(this.url + '/config/add', { params: this.editedItem })
+        const { data: rst } = await axios.get('/config/add', { params: this.editedItem })
 
         if (rst.state) {
           this.tableData.push(rst.data)
@@ -275,7 +275,7 @@ export default {
     // 拉取项目
     async get () {
       this.loading = true
-      const { data: rst } = await axios.get(this.url + '/config/get')
+      const { data: rst } = await this.$http.get('/config/get')
 
       if (rst.state) {
         this.tableData = rst.data.list
@@ -358,10 +358,6 @@ export default {
   },
 
   mounted() {
-    if (process.env.NODE_ENV === 'development') {
-      this.url = '/api'
-    }
-
     this.get()
   }
 }

+ 2 - 4
src/components/History.vue

@@ -259,10 +259,8 @@
         }
       },
       async getRecord () {
-        let url = 'http://410eth.com/data/getRecord'
-        if (process.env.NODE_ENV === 'development') {
-          url = '/api/data/getRecord'
-        }
+        let url = '/data/getRecord'
+
         this.tableData.length = 0
         this.loading = true
         this.query.t1 = this.query.t1_str ? this.dateToTimestamp(this.query.t1_str) : ''

+ 1 - 4
src/components/My.vue

@@ -259,10 +259,7 @@
         }
       },
       async getRecord () {
-        let url = 'http://410eth.com/data/getRecordByMySelf'
-        if (process.env.NODE_ENV === 'development') {
-          url = '/api/data/getRecordByMySelf'
-        }
+        let url = '/data/getRecordByMySelf'
         this.loading = true
         if (this.searched) {
           this.query.t1 = this.query.t1_str ? this.dateToTimestamp(this.query.t1_str) : ''

+ 1 - 4
src/components/New.vue

@@ -161,10 +161,7 @@ export default {
       }
     },
     async getRecord () {
-      let url = 'http://410eth.com/data/getRecord'
-      if (process.env.NODE_ENV === 'development') {
-        url = '/api/data/getRecord'
-      }
+      let url = '/data/getRecord'
       this.loading = true
       const app = this
       const data = await axios.get(url, { params: this.query })

+ 25 - 51
src/plugins/axios.js

@@ -3,59 +3,33 @@
 import Vue from 'vue';
 import axios from "axios";
 
-// Full config:  https://github.com/axios/axios#request-config
-// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
-// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
-// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
+Vue.prototype.$http = axios
 
-let config = {
-  // baseURL: process.env.baseURL || process.env.apiUrl || ""
-  // timeout: 60 * 1000, // Timeout
-  // withCredentials: true, // Check cross-site Access-Control
-};
+axios.defaults.baseURL = process.env.VUE_APP_BASE_URL
 
-const _axios = axios.create(config);
-
-_axios.interceptors.request.use(
-  function(config) {
-    // Do something before request is sent
-    return config;
-  },
-  function(error) {
-    // Do something with request error
-    return Promise.reject(error);
-  }
+axios.interceptors.request.use(
+    config => {
+      return config
+    },
+    err => {
+      return Promise.reject(err)
+    }
 );
 
 // Add a response interceptor
-_axios.interceptors.response.use(
-  function(response) {
-    // Do something with response data
-    return response;
-  },
-  function(error) {
-    // Do something with response error
-    return Promise.reject(error);
-  }
-);
-
-Plugin.install = function(Vue) {
-  Vue.axios = _axios;
-  window.axios = _axios;
-  Object.defineProperties(Vue.prototype, {
-    axios: {
-      get() {
-        return _axios;
-      }
-    },
-    $axios: {
-      get() {
-        return _axios;
-      }
-    },
-  });
-};
-
-Vue.use(Plugin)
-
-export default Plugin;
+// axios.interceptors.response.use((response) => {
+//   const { data: result } = response
+//   if (result.code !== 200) {
+//     if (result.code === 500 && !result.msg) {
+//       Message.error('Server error.')
+//     } else {
+//       Message.error(result.msg)
+//     }
+//   }
+//   return result
+// }, (error) => {
+//   Message.error('Server error.')
+//   return Promise.reject(error)
+// });
+
+export default axios

+ 14 - 0
upload

@@ -0,0 +1,14 @@
+scp -i no1.pem -r /Volumes/Code/Customer/410/ethereum_viewer_webapp/dist centos@44.201.61.85:/eth_node/web/webapps/ethereum_viewer_webapp
+scp -i no1.pem /Volumes/Code/Customer/410/ethereum_viewer_webapp/nginx.conf centos@44.201.61.85:/etc/nginx
+
+start:
+systemctl start nginx
+restart:
+systemctl restart nginx
+status:
+systemctl status nginx
+
+logs:
+tail -f /eth_node/web/apache-tomcat-webapp/logs/catalina.out
+cat /eth_node/web/apache-tomcat-webapp/logs/catalina.out
+rm /eth_node/web/apache-tomcat-webapp/logs/catalina.out

+ 1 - 1
vue.config.js

@@ -5,7 +5,7 @@ module.exports = {
   devServer: {
     proxy: {
       '/api': {
-        target:'http://localhost:8080',
+        target:'http://localhost:8088',
         changeOrigin:true,
         pathRewrite:{
           '^/api': ''