shish před 6 roky
rodič
revize
f0b47756e4

+ 1 - 0
shop/.env.development.example

@@ -0,0 +1 @@
+NODE_ENV=development

+ 1 - 0
shop/.gitignore

@@ -4,6 +4,7 @@ node_modules
 # local env files
 .env.local
 .env.*.local
+.env.development
 
 # Log files
 npm-debug.log*

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

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

+ 7 - 1
shop/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 == 'development'){
+		return 'huaml';
+	}
+	if(process.env.NODE_ENV == 'local'){
+		return 'hhb';
+	}
+	return host;
 };
 
 export const revisePath = path => {

+ 5 - 10
shop/vue.config.js

@@ -8,12 +8,12 @@ const path = require('path');
 
 const isProduction = process.env.NODE_ENV === 'production';
 
+const proxyTarget = process.env.NODE_ENV === 'local' ? 'http://api.shop.hhb.com' : 'http://api.shop.huaml.com';
+
 function resolve(dir) {
 	return path.join(__dirname, dir);
 }
 
-// const hostUrl = `${window.location.protocol}//static.${getFirstHost()}.com`;
-// const hostUrl = `https://static.huaml.com`;
 const hostUrl = ``;
 
 const cdn = {
@@ -40,8 +40,6 @@ const cdn = {
 			`${hostUrl}/cdn/viewerjs/1.3.7/viewer.min.js`,
 			`${hostUrl}/cdn/echarts/4.4.0-rc.1/echarts.min.js`,
 			`${hostUrl}/cdn/npm/vue-echarts@4.0.2.js`
-			// https://cdn.bootcss.com
-			// 'https://cdn.jsdelivr.net/npm/vue-echarts@4.0.2'
 		]
 	}
 };
@@ -79,20 +77,17 @@ module.exports = {
 
 		proxy: {
 			'/dev': {
-				target: 'http://api.shop.huaml.com',
-
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/dev': '' }
 			},
 			'/s-dev': {
-				target: 'http://api.shop.huaml.com',
-
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/s-dev': '' }
 			},
 			'/pro': {
-				target: 'http://api.shop.huaml.com',
-
+				target: proxyTarget,
 				changeOrigin: true,
 				pathRewrite: { '^/pro': '/api' }
 			}