فهرست منبع

支持本地开发ok

shish 6 سال پیش
والد
کامیت
e0d578cb0d
4فایلهای تغییر یافته به همراه14 افزوده شده و 11 حذف شده
  1. 2 1
      saas/src/config/env.js
  2. 7 1
      saas/src/cool/utils/index.js
  3. 5 3
      saas/vue.config.js
  4. 0 6
      shop/vue.config.js

+ 2 - 1
saas/src/config/env.js

@@ -19,10 +19,11 @@ const baseUrl = (function() {
 	}
 
 	switch (process.env.NODE_ENV) {
+		case 'local':
+			return `/${proxy}`;
 		case 'development':
 			return `/${proxy}`;
 		case 'production':
-			// return `http://api.saas.huaml.com`;
 			return `${window.location.protocol}//api.saas.${getFirstHost()}.com`;
 		default:
 			return '';

+ 7 - 1
saas/src/cool/utils/index.js

@@ -4,7 +4,13 @@ export const getFirstHost = () => {
 	let host = window.location.host;
 	host = host.split('.');
 	host = host.length == 3 ? host[1] : host[0];
-	return process.env.NODE_ENV == 'development' ? 'huaml' : host;
+	if(process.env.NODE_ENV == 'local'){
+		return 'hhb';
+	}
+	if(process.env.NODE_ENV == 'development'){
+		return 'huaml';
+	}
+	return host;
 };
 
 export const revisePath = path => {

+ 5 - 3
saas/vue.config.js

@@ -2,6 +2,8 @@ const path = require('path');
 
 const isProduction = process.env.NODE_ENV === 'production';
 
+const proxyTarget = process.env.NODE_ENV === 'local' ? 'http://api.saas.hhb.com' : 'http://api.saas.huaml.com';
+
 function resolve(dir) {
 	return path.join(__dirname, dir);
 }
@@ -71,17 +73,17 @@ module.exports = {
 
 		proxy: {
 			'/dev': {
-				target: 'http://api.saas.huaml.com',
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/dev': '' }
 			},
 			'/s-dev': {
-				target: 'http://api.saas.huaml.com',
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/s-dev': '' }
 			},
 			'/pro': {
-				target: 'http://api.saas.huaml.com',
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/pro': '/api' }
 			}

+ 0 - 6
shop/vue.config.js

@@ -1,10 +1,4 @@
 const path = require('path');
-// const getFirstHost = () => {
-// 	let host = window.location.host;
-// 	host = host.split('.');
-// 	host = host.length == 3 ? host[1] : host[0];
-// 	return process.env.NODE_ENV == 'development' ? 'huaml' : host;
-// };
 
 const isProduction = process.env.NODE_ENV === 'production';