Browse Source

多环境构建,将配置与环境隔离
引入.env.*配置文件,根目录新增4个环境配置文件
Vue CLI打包自动分配环境

ZhangWenQiang 5 years ago
parent
commit
540e9bb283
8 changed files with 55 additions and 20 deletions
  1. 4 0
      .env
  2. 11 0
      .env.development
  3. 11 0
      .env.production
  4. 11 0
      .env.test
  5. 1 0
      package.json
  6. 0 20
      public/index.html
  7. 14 0
      src/config/index.js
  8. 3 0
      src/main.js

+ 4 - 0
.env

@@ -0,0 +1,4 @@
+NODE_ENV=production
+VUE_APP_PLATFORM_NAME=慧盈服务中心
+#SSO单点登录开关
+VUE_APP_SSO=false

+ 11 - 0
.env.development

@@ -0,0 +1,11 @@
+NODE_ENV=development
+#接口地址
+VUE_APP_API_BASE_URL=http://127.0.0.1:9999
+#地址IP
+VUE_APP_API_BASE_IP=http://127.0.0.1
+#OSS地址
+VUE_APP_OSS_URL=https://happyworktest.oss-cn-shanghai.aliyuncs.com
+#单点登录地址
+VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas
+#online地址
+VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview

+ 11 - 0
.env.production

@@ -0,0 +1,11 @@
+NODE_ENV=production
+#接口地址
+VUE_APP_API_BASE_URL=https://hlw.dal-pay.com/admin
+#地址IP
+VUE_APP_API_BASE_IP=http://124.71.173.136
+#OSS地址
+VUE_APP_OSS_URL=https://happywisdom.oss-cn-shanghai.aliyuncs.com
+#单点登录地址
+VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas
+#online地址
+VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview

+ 11 - 0
.env.test

@@ -0,0 +1,11 @@
+NODE_ENV=production
+#接口地址
+VUE_APP_API_BASE_URL=https://dlw.dal-pay.com/admin
+#地址IP
+VUE_APP_API_BASE_IP=http://124.71.158.86
+#OSS地址
+VUE_APP_OSS_URL=https://happyworktest.oss-cn-shanghai.aliyuncs.com
+#单点登录地址
+VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas
+#online地址
+VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview

+ 1 - 0
package.json

@@ -5,6 +5,7 @@
   "scripts": {
     "pre": "cnpm install || yarn --registry https://registry.npm.taobao.org || npm install --registry https://registry.npm.taobao.org ",
     "serve": "vue-cli-service serve",
+    "build:test": "vue-cli-service build --mode test",
     "build": "vue-cli-service build",
     "lint": "vue-cli-service lint"
   },

+ 0 - 20
public/index.html

@@ -242,26 +242,6 @@
   <!-- 全局配置 -->
   <script>
     window._CONFIG = {};
-    //本地
-    window._CONFIG['domianURL'] = 'http://127.0.0.1:9999';
-    //测试
-    // window._CONFIG['domianURL'] = 'https://dlw.dal-pay.com/admin';
-    //正式服
-    // window._CONFIG['domianURL'] = 'https://hlw.dal-pay.com/admin';
-    //ip地址
-    window._CONFIG['domianIp'] = 'http://127.0.0.1';
-    //ip地址-测试
-    // window._CONFIG['domianIp'] = 'http://124.71.158.86';
-    //ip地址-正式服
-    // window._CONFIG['domianIp'] = 'http://124.71.173.136';
-    window._CONFIG['casPrefixUrl'] = 'http://cas.example.org:8443/cas';
-    window._CONFIG['onlinePreviewDomainURL'] = 'http://fileview.jeecg.com/onlinePreview'
-    window._CONFIG['staticDomainURL'] = window._CONFIG['domianURL'] + '/sys/common/static';
-    window._CONFIG['pdfDomainURL'] =  window._CONFIG['domianURL'] + '/sys/common/pdf/pdfPreviewIframe';
-    <!-- oss路径 -->
-    window._CONFIG['imgDomainOssURL'] = 'https://happyworktest.oss-cn-shanghai.aliyuncs.com';
-    <!-- oss路径正式服 -->
-    // window._CONFIG['imgDomainOssURL'] = 'https://happywisdom.oss-cn-shanghai.aliyuncs.com';
   </script>
 </head>
 

+ 14 - 0
src/config/index.js

@@ -0,0 +1,14 @@
+/** init domain config */
+import Vue from 'vue'
+//设置全局API_BASE_URL
+Vue.prototype.API_BASE_URL = process.env.VUE_APP_API_BASE_URL
+window._CONFIG['domianURL'] = Vue.prototype.API_BASE_URL
+//ip地址
+window._CONFIG['domianIp'] = process.env.VUE_APP_API_BASE_IP
+//oss路径
+window._CONFIG['imgDomainOssURL'] = process.env.VUE_APP_OSS_URL
+//单点登录地址
+window._CONFIG['casPrefixUrl'] = process.env.VUE_APP_CAS_BASE_URL
+window._CONFIG['onlinePreviewDomainURL'] =  process.env.VUE_APP_ONLINE_BASE_URL
+window._CONFIG['staticDomainURL'] = Vue.prototype.API_BASE_URL + '/sys/common/static'
+window._CONFIG['pdfDomainURL'] = Vue.prototype.API_BASE_URL+ '/sys/common/pdf/pdfPreviewIframe'

+ 3 - 0
src/main.js

@@ -1,3 +1,6 @@
+/** init domain config */
+import './config'
+
 import Vue from 'vue'
 import App from './App.vue'
 import Storage from 'vue-ls'