Przeglądaj źródła

配置生产环境和开发环境及打包参数

ming 3 lat temu
rodzic
commit
064698f2a9
5 zmienionych plików z 92 dodań i 89 usunięć
  1. 4 1
      .env.development
  2. 4 1
      .env.production
  3. 77 72
      package.json
  4. 2 14
      src/main.js
  5. 5 1
      src/utils/request.js

+ 4 - 1
.env.development

@@ -1,4 +1,7 @@
 	// development 开发环境
 	NODE_ENV='development'
+	VUE_APP_ENV = development
 	// 下面的为接口地址。此处/api是我经过webpack设置跨域代理之后的地址
-	VUE_APP_BASE_URL='https://qhome.usky.cn/'
+	VUE_APP_BASE_URL='https://qhome.usky.cn/uskypower/'
+	VUE_APP_IMAGES='https://qhome.usky.cn/uskyfile/'
+	VUE_APP_FILE_URL='https://qhome.usky.cn/uskyfile/'

+ 4 - 1
.env.production

@@ -1,4 +1,7 @@
 // production 生产环境
 NODE_ENV = 'production'
+VUE_APP_ENV = production
 // 下方链接为生产环境接口地址
-VUE_APP_BASE_URL='http://我是生产环境接口地址'
+VUE_APP_BASE_URL='https://qhome-pro.usky.cn/uskypower/'
+VUE_APP_IMAGES='https://qhome-pro.usky.cn/uskyfile/'
+VUE_APP_FILE_URL='https://qhome-pro.usky.cn/uskyfile/'

+ 77 - 72
package.json

@@ -1,73 +1,78 @@
 {
-  "name": "vue-admin-beautiful-antdv",
-  "version": "1.0.0",
-  "private": true,
-  "scripts": {
-    "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build",
-    "lint": "vue-cli-service lint",
-    "clear": "rimraf node_modules&&npm install --registry=https://registry.npm.taobao.org",
-    "use:npm": "nrm use npm",
-    "use:taobao": "nrm use taobao",
-    "update": "ncu -u --target greatest&&npm install --registry=https://registry.npm.taobao.org",
-    "deploy": "start ./deploy.sh"
-  },
-  "dependencies": {
-    "ant-design-vue": "2.0.0-rc.9",
-    "axios": "^0.21.1",
-    "clipboard": "^2.0.6",
-    "core-js": "^3.8.3",
-    "dayjs": "^1.10.4",
-    "default-passive-events": "^2.0.0",
-    "echarts": "^5.2.1",
-    "element-plus": "^1.1.0-beta.20",
-    "js-cookie": "^3.0.0-rc.1",
-    "mockjs": "^1.1.0",
-    "remixicon": "^2.5.0",
-    "video.js": "^7.17.0",
-    "videojs-contrib-hls": "^5.15.0",
-    "vue": "^3.2.18",
-    "vue-amap": "^0.5.10",
-    "vue-router": "^4.0.3",
-    "vuex": "^4.0.0"
-  },
-  "devDependencies": {
-    "@vue/cli-plugin-babel": "^4.5.9",
-    "@vue/cli-plugin-eslint": "^4.5.9",
-    "@vue/cli-service": "^4.5.9",
-    "@vue/compiler-sfc": "^3.0.5",
-    "@vue/eslint-config-prettier": "^6.0.0",
-    "babel-eslint": "^11.0.0-beta.2",
-    "body-parser": "^1.19.0",
-    "chalk": "^4.1.0",
-    "chokidar": "^3.5.1",
-    "eslint": "^7.19.0",
-    "eslint-plugin-prettier": "^3.3.1",
-    "eslint-plugin-vue": "^7.5.0",
-    "filemanager-webpack-plugin": "^3.1.0",
-    "image-webpack-loader": "^8.1.0",
-    "imagemin-gifsicle": "^2.0.0",
-    "less": "^4.1.1",
-    "less-loader": "^7.3.0",
-    "lint-staged": "^10.5.3",
-    "node-sass": "^4.14.1",
-    "prettier": "^2.2.1",
-    "sass": "^1.42.1",
-    "sass-loader": "^8.0.2",
-    "stylelint": "^13.9.0",
-    "stylelint-config-prettier": "^8.0.2",
-    "stylelint-config-recess-order": "^2.3.0",
-    "svg-sprite-loader": "^5.2.1",
-    "vab-config": "0.0.8",
-    "webpackbar": "^5.0.0-3"
-  },
-  "gitHooks": {
-    "pre-commit": "lint-staged"
-  },
-  "lint-staged": {
-    "*.{js,jsx,vue}": [
-      "vue-cli-service lint",
-      "git add"
-    ]
-  }
-}
+    "name": "vue-admin-beautiful-antdv",
+    "version": "1.0.0",
+    "private": true,
+    "scripts": {
+        "serve": "vue-cli-service serve",
+        "build": "vue-cli-service build",
+
+        "build:development": "vue-cli-service build --mode development",
+        "build:production": "vue-cli-service build --mode production",
+
+
+        "lint": "vue-cli-service lint",
+        "clear": "rimraf node_modules&&npm install --registry=https://registry.npm.taobao.org",
+        "use:npm": "nrm use npm",
+        "use:taobao": "nrm use taobao",
+        "update": "ncu -u --target greatest&&npm install --registry=https://registry.npm.taobao.org",
+        "deploy": "start ./deploy.sh"
+    },
+    "dependencies": {
+        "ant-design-vue": "2.0.0-rc.9",
+        "axios": "^0.21.1",
+        "clipboard": "^2.0.6",
+        "core-js": "^3.8.3",
+        "dayjs": "^1.10.4",
+        "default-passive-events": "^2.0.0",
+        "echarts": "^5.2.1",
+        "element-plus": "^1.1.0-beta.20",
+        "js-cookie": "^3.0.0-rc.1",
+        "mockjs": "^1.1.0",
+        "remixicon": "^2.5.0",
+        "video.js": "^7.17.0",
+        "videojs-contrib-hls": "^5.15.0",
+        "vue": "^3.2.18",
+        "vue-amap": "^0.5.10",
+        "vue-router": "^4.0.3",
+        "vuex": "^4.0.0"
+    },
+    "devDependencies": {
+        "@vue/cli-plugin-babel": "^4.5.9",
+        "@vue/cli-plugin-eslint": "^4.5.9",
+        "@vue/cli-service": "^4.5.9",
+        "@vue/compiler-sfc": "^3.0.5",
+        "@vue/eslint-config-prettier": "^6.0.0",
+        "babel-eslint": "^11.0.0-beta.2",
+        "body-parser": "^1.19.0",
+        "chalk": "^4.1.0",
+        "chokidar": "^3.5.1",
+        "eslint": "^7.19.0",
+        "eslint-plugin-prettier": "^3.3.1",
+        "eslint-plugin-vue": "^7.5.0",
+        "filemanager-webpack-plugin": "^3.1.0",
+        "image-webpack-loader": "^8.1.0",
+        "imagemin-gifsicle": "^2.0.0",
+        "less": "^4.1.1",
+        "less-loader": "^7.3.0",
+        "lint-staged": "^10.5.3",
+        "node-sass": "^4.14.1",
+        "prettier": "^2.2.1",
+        "sass": "^1.42.1",
+        "sass-loader": "^8.0.2",
+        "stylelint": "^13.9.0",
+        "stylelint-config-prettier": "^8.0.2",
+        "stylelint-config-recess-order": "^2.3.0",
+        "svg-sprite-loader": "^5.2.1",
+        "vab-config": "0.0.8",
+        "webpackbar": "^5.0.0-3"
+    },
+    "gitHooks": {
+        "pre-commit": "lint-staged"
+    },
+    "lint-staged": {
+        "*.{js,jsx,vue}": [
+            "vue-cli-service lint",
+            "git add"
+        ]
+    }
+}

+ 2 - 14
src/main.js

@@ -47,18 +47,9 @@ if (process.env.NODE_ENV === 'production') {
     // const { mockXHR } = require('@/utils/static')
     // mockXHR()
 
-    console.log("process.env.NODE_ENV111 正式环境域名" + process.env.VUE_APP_BASE_URL)
-
-
+    // console.log("process.env.NODE_ENV111 正式环境域名" + process.env.VUE_APP_BASE_URL)
 } else {
-
-    console.log("process.env.NODE_ENV111 测试环境域名" + process.env.VUE_APP_BASE_URL)
-        // PLATFROM_CONFIG.baseUrl = process.env.VUE_APP_BASE_URL + "uskypower/"
-        // PLATFROM_CONFIG.images = process.env.VUE_APP_BASE_URL + "uskyfile/"
-        // PLATFROM_CONFIG.fileUrl = process.env.VUE_APP_BASE_URL + "uskyfile/"
-
-
-
+    // console.log("process.env.NODE_ENV111 测试环境域名" + process.env.VUE_APP_BASE_URL)
 }
 
 
@@ -68,9 +59,6 @@ if (process.env.NODE_ENV === 'production') {
 
 
 router.beforeEach((to) => {
-
-
-
     if (to.path != '/login') {
         store.commit("publicSiteList");
         store.commit('publicDeviceList')

+ 5 - 1
src/utils/request.js

@@ -52,8 +52,12 @@ const handleCode = (code, msg) => {
  * @author chuzhixin 1204505056@qq.com
  * @description axios初始化
  */
-const baseURL = window.PLATFROM_CONFIG.baseUrl
+// const baseURL = window.PLATFROM_CONFIG.baseUrl
+const baseURL = process.env.VUE_APP_BASE_URL
+    // alert(baseURL)
+    // alert(process.env.VUE_APP_BASE_URL)
     // console.log(baseURL)
+    // const baseURL = process.env.VUE_APP_BASE_URL
 const instance = axios.create({
     baseURL,
     timeout: requestTimeout,