Browse Source

代理修改

zhangjie 3 năm trước cách đây
mục cha
commit
9e3846b292
6 tập tin đã thay đổi với 52 bổ sung64 xóa
  1. 7 6
      .env
  2. 11 11
      .eslintrc.js
  3. 22 23
      .gitignore
  4. 0 9
      dev-proxy.copy.js
  5. 4 4
      package.json
  6. 8 11
      vue.config.js

+ 7 - 6
.env

@@ -1,6 +1,7 @@
-NODE_ENV=development
-VUE_APP_DOMAIN=
-VUE_APP_TIMEOUT=600000
-VUE_APP_PAGE_SIZE=10
-VUE_APP_AUTH_TIMEOUT=72000000
-VUE_APP_SELF_DEFINE_DOMAIN=true
+NODE_ENV=development
+VUE_APP_DOMAIN=
+VUE_APP_TIMEOUT=600000
+VUE_APP_PAGE_SIZE=10
+VUE_APP_AUTH_TIMEOUT=72000000
+VUE_APP_SELF_DEFINE_DOMAIN=true
+VUE_APP_DEV_PROXY=http://test-school-2.teachcloud-print-test.cn/

+ 11 - 11
.eslintrc.js

@@ -3,23 +3,23 @@ module.exports = {
   env: {
     node: true
   },
-  extends: ['plugin:vue/essential', '@vue/prettier'],
+  extends: ["plugin:vue/essential", "@vue/prettier"],
   rules: {
-    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
-    'no-unused-vars': [
-      'error',
-      { vars: 'all', args: 'none', ignoreRestSiblings: false }
+    "no-console": process.env.NODE_ENV === "production" ? "off" : "off",
+    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
+    "no-unused-vars": [
+      "error",
+      { vars: "all", args: "none", ignoreRestSiblings: false }
     ],
-    'vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }],
-    'vue/no-use-v-if-with-v-for': [
-      'error',
+    "vue/no-parsing-error": [2, { "x-invalid-end-tag": false }],
+    "vue/no-use-v-if-with-v-for": [
+      "error",
       {
         allowUsingIterationVar: true
       }
     ]
   },
   parserOptions: {
-    parser: 'babel-eslint'
+    parser: "babel-eslint"
   }
-}
+};

+ 22 - 23
.gitignore

@@ -1,23 +1,22 @@
-.DS_Store
-node_modules
-/dist
-dev-proxy.js
-modules-old*
-
-# local env files
-.env.local
-.env.*.local
-
-# Log files
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-
-# Editor directories and files
-.idea
-.vscode
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw*
+.DS_Store
+node_modules
+/dist
+modules-old*
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw*

+ 0 - 9
dev-proxy.copy.js

@@ -1,9 +0,0 @@
-module.exports = {
-  "/api/": {
-    target: "http://192.168.10.239:9888",
-    changeOrigin: true,
-    pathRewrite: {
-      "^/api": "/"
-    }
-  }
-};

+ 4 - 4
package.json

@@ -9,6 +9,9 @@
     "test:unit": "vue-cli-service test:unit"
   },
   "dependencies": {
+    "axios": "^0.18.0",
+    "cropperjs": "^1.5.1",
+    "crypto-js": "^4.0.0",
     "core-js": "^3.6.5",
     "deepmerge": "^4.2.2",
     "element-ui": "^2.14.1",
@@ -17,10 +20,7 @@
     "vue": "^2.6.11",
     "vue-ls": "^3.2.2",
     "vue-router": "^3.2.0",
-    "vuex": "^3.4.0",
-    "axios": "^0.18.0",
-    "cropperjs": "^1.5.1",
-    "crypto-js": "^4.0.0"
+    "vuex": "^3.4.0"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "~4.5.0",

+ 8 - 11
vue.config.js

@@ -1,17 +1,18 @@
 var webpack = require("webpack");
 var TerserPlugin = require("terser-webpack-plugin");
-var devProxy = {};
-try {
-  devProxy = require("./dev-proxy");
-} catch (error) {}
-
-var proxy = process.env.NODE_ENV === "production" ? {} : devProxy;
+var devProxy = {
+  "/api/": {
+    target: process.env.VUE_APP_DEV_PROXY,
+    changeOrigin: true
+  }
+};
 
 // 配置手册: https://cli.vuejs.org/zh/config/#vue-config-js
 var config = {
   // publicPath: './',
   devServer: {
-    port: 8056
+    port: 8056,
+    proxy: devProxy
   },
   chainWebpack: config => {
     // webpack-chain配置手册:github.com/neutrinojs/webpack-chain#getting-started
@@ -43,8 +44,4 @@ if (process.env.NODE_ENV === "production") {
   };
 }
 
-if (proxy && Object.keys(proxy).length) {
-  config.devServer.proxy = proxy;
-}
-
 module.exports = config;