zhengkaixin 2 年之前
父節點
當前提交
57b9a46611
共有 10 個文件被更改,包括 245 次插入4 次删除
  1. 2 0
      .gitignore
  2. 5 2
      App.vue
  3. 25 0
      config/.env.dev.js
  4. 35 0
      config/.env.js
  5. 14 0
      config/.env.prod.js
  6. 28 0
      config/.env.test.js
  7. 3 1
      main.js
  8. 39 0
      package.json
  9. 1 1
      pages/index/index.vue
  10. 93 0
      vue.config.js

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+*.lock
+/node_modules/

+ 5 - 2
App.vue

@@ -1,9 +1,12 @@
 <script>
 	export default {
 		onLaunch: function() {
-			console.log('App Launch')
+			console.log('App Launch')
+			document.title="11"
+			
 		},
-		onShow: function() {
+		onShow: function() {
+			
 			console.log('App Show')
 		},
 		onHide: function() {

+ 25 - 0
config/.env.dev.js

@@ -0,0 +1,25 @@
+const UNI_APP = {  
+	ProjectName :"51充电联盟",
+	BASE_URL: 'https://51team.xiaoxinda.com/charging-station-server/',
+	//BASE_URL: 'https://charging.xiaoxinda.com/charging-station-test/',
+	//BASE_URL: 'http://192.168.77.162:8080/charging-station/' ,
+	PARK_URL: 'https://51team.xiaoxinda.com/charging-parking/' ,
+	NODE_ENV :"dev",
+	SIMPLE_RUN:true,// 无视权限控制跳转页面   , 用于样式人员快速访问各种功能 ,快速测试等
+
+	//openId:"oK9Wr57rAcNzihDN2PEdptprT0As", 
+	openId:"oK9Wr54VbEh3xvWYmD_zT5NbH4AY",//zkx
+	//openId:"oK9Wr59rru-i3bm7dtTtxnkR-i4s",//杨所
+	//openId:"oK9Wr5zv8lvirni3txbxRkmpg8d0",//
+	
+	
+	//openId:"oK9Wr58zNwDernF0TL6o3mdUxk2A",
+	//		openId:"oK9Wr5xRUoP9EygZqBec0xkJMVTs",
+	//openId:"oK9Wr55J1J1eL6BqI2tW749NTxNU",//zq
+	//小鹏管家appid
+	//VUE_APP_WXAPPID:"wx7e70eb62a8459869",
+	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
+	VUE_APP_ALIAPPID:"2021003131641247",
+}  
+
+module.exports = UNI_APP;

+ 35 - 0
config/.env.js

@@ -0,0 +1,35 @@
+(function() {  
+    const NODE_ENV = 'dev'; // dev:开发环境 | test:测试环境  
+    let ENV_VAR = null;  
+	 
+	var NODE_NAME=  process.env['NODE_NAME']
+	console.log(NODE_NAME)
+    if (process.env.NODE_ENV === "development") {  
+
+        if (NODE_ENV === 'dev') {  
+            ENV_VAR = require('.env.dev.js');  
+        } else if (NODE_ENV === 'test') {  
+			ENV_VAR = require('.env.test.js'); 
+        } else{
+			 ENV_VAR = require('.env.dev.js');  
+		}
+		
+    } else if (process.env.NODE_ENV === "production") {  
+		
+		if(NODE_NAME=="test"){
+			ENV_VAR = require('.env.test.js'); 
+		}else if(NODE_NAME=="production"){
+			ENV_VAR = require('.env.prod.js');
+		} else  {  
+			ENV_VAR = require('.env.prod.js');  
+		} 
+      
+    }  
+
+    if (ENV_VAR) {  
+		process.car = {};  
+        for (let key in ENV_VAR) {  
+			process.car[key] = ENV_VAR[key];			
+        }  
+    }  
+})();

+ 14 - 0
config/.env.prod.js

@@ -0,0 +1,14 @@
+const UNI_APP = {  	
+		ProjectName :"51充电联盟",
+    BASE_URL: 'https://51team.xiaoxinda.com/charging-station-server/',
+	PARK_URL: 'https://51team.xiaoxinda.com/charging-parking/' ,
+	
+	NODE_ENV :"prod",
+	SIMPLE_RUN:false,
+	openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",//测试用openId
+	//小鹏管家appid
+	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
+	VUE_APP_ALIAPPID:"2021003131641247",
+}  
+
+module.exports = UNI_APP;

+ 28 - 0
config/.env.test.js

@@ -0,0 +1,28 @@
+const UNI_APP = {  
+	ProjectName :"51充电联盟",
+   // BASE_URL: 'http://192.168.77.162:8080/charging-station/' ,
+	BASE_URL: 'https://charging.xiaoxinda.com/charging-station-test/',
+	PARK_URL: 'https://51team.xiaoxinda.com/charging-parking/' ,
+	
+    //BASE_URL: 'https://charging.xiaoxinda.com/charging-station-server/',
+   
+
+	NODE_ENV :"test",
+	SIMPLE_RUN:false,
+	//openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",//测试用openId
+	//openId:"oHjCawmHqG44pqUW54iBlenaHYB8",D
+	//小鹏管家appid
+	VUE_APP_WXAPPID:"wx3afdb1b60188c1e5",
+	VUE_APP_ALIAPPID:"2021003131641247",
+	//zkx的测试openId
+	// openId:"oHjCawsJ5blME36lHaSpSVfEhleU",
+	// openId:"oHjCawigqi8SEAwutwkQ-VEgdp3k",
+	// openId:"oK9Wr55J1J1eL6BqI2tW749NTxNU",
+	//zq的测试openId
+	//openId:"oK9Wr55J1J1eL6BqI2tW749NTxNU"
+	//openId:"test004",
+	openId:"oK9Wr54VbEh3xvWYmD_zT5NbH4AY",
+	
+}  
+
+module.exports = UNI_APP;

+ 3 - 1
main.js

@@ -1,5 +1,6 @@
 import App from './App'
 
+
 // #ifndef VUE3
 import Vue from 'vue'
 Vue.config.productionTip = false
@@ -18,4 +19,5 @@ export function createApp() {
     app
   }
 }
-// #endif
+// #endif
+//alert(process.env.NODE_ENV)

+ 39 - 0
package.json

@@ -0,0 +1,39 @@
+{
+
+	"dependencies": {
+		"compression-webpack-plugin": "^8.0.1",
+		"echarts": "^5.3.2",
+		"hls.js": "^0.14.11",
+		"uview-ui": "^1.8.4",
+		"vconsole": "^3.4.0",
+		"vue-cropper": "^0.5.6",
+		"weixin-js-sdk": "^1.6.0"
+	},
+	"uni-app": {
+		"scripts": {
+			"test-student-platform": {
+				"title": "test",
+				"BROWSER": "Chrome",
+				"env": {
+					"UNI_PLATFORM": "h5",
+					"NODE_NAME": "test-student"
+				},
+				"define": {
+					"CUSTOM-CONST": true
+				}
+			},
+			"production-student-platform": {
+				"title": "production",
+				"BROWSER": "Chrome",
+				"env": {
+					"UNI_PLATFORM": "h5",
+					"NODE_NAME": "production-student"
+					
+				},
+				"define": {
+					"CUSTOM-CONST": true
+				}
+			}
+		}
+	}
+}

+ 1 - 1
pages/index/index.vue

@@ -2,7 +2,7 @@
 	<view class="content">
 		<image class="logo" src="/static/logo.png"></image>
 		<view class="text-area">
-			<text class="title">{{title}}</text>
+			<text class="title">11{{title}}</text>
 		</view>
 	</view>
 </template>

+ 93 - 0
vue.config.js

@@ -0,0 +1,93 @@
+if(process.env.NODE_ENV === "production"){
+	
+	const path = require('path');
+	const webpack = require('webpack')
+	
+	const CompressionWebpackPlugin = require("compression-webpack-plugin")
+	const productionGzipExtensions = ['js', 'css']
+	
+	function resolve(dir) {
+		return path.join(__dirname, dir)
+	}
+	
+	const Timestamp = new Date().getTime();
+	module.exports = {
+		publicPath: './',
+		outputDir: 'dist/' ,
+		assetsDir: 'static',
+		lintOnSave: false,
+		devServer: {
+			host: 'xpgj.xiaoxinda.com',
+			port: 80,
+			//解析缓存
+			disableHostCheck: true,
+			//支持gzip
+			compress: true,
+		},
+		//不输出map
+		productionSourceMap: false,
+		chainWebpack: (config) => {
+			config.entry.app = ['babel-polyfill', './src/main.js']
+			config.resolve.alias
+				.set('@', resolve('./static/'))
+	
+			config.plugins.delete('preload-index');
+			config.plugins.delete('prefetch-index');
+			
+			config.module.rule('images')
+			           .test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
+			           .use('url-loader')
+			           .loader('file-loader')
+			           .options({
+			               name: 'static/img/[name].[hash:8].[ext]'
+			           })
+					
+			config.optimization.minimize(true);
+		},
+		configureWebpack: config => {
+			/* //开启gzip压缩,需要配置Nginx服务器gzip选项开启
+			config.plugins.push(
+				new CompressionWebpackPlugin({
+					filename: '[path].gz[query]',
+					algorithm: 'gzip',
+					test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
+					threshold: 10240,
+					minRatio: 0.8
+				})
+			); */
+	
+				config.plugins.push(new webpack.ProgressPlugin(percentage => {
+					percentage === 1 ? console.log('编译完成:100.00%') : console.log(`编译进度:${(percentage * 100).toFixed(2)}%,提示!构建请点击‘发行’-‘自定义发行’`)
+				}));
+			config.output.filename = `./static/js/[name].${Timestamp}.js`
+			config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
+	
+			config.performance = {
+				hints: 'warning',
+				//入口起点的最大体积 整数类型(以字节为单位)
+				maxEntrypointSize: 50000000,
+				//生成文件的最大体积 整数类型(以字节为单位 300k)
+				maxAssetSize: 30000000,
+				//只给出 js 文件的性能提示
+				assetFilter: function(assetFilename) {
+					return assetFilename.endsWith('.js');
+				}
+			}
+		},
+		css: {
+			extract: {
+				filename: `./static/css/[name].${Timestamp}.css`,
+				chunkFilename: `./static/css/[name].${Timestamp}.css`
+			},
+			sourceMap: false,
+			loaderOptions: {
+				// 给 sass-loader 传递选项
+				sass: {
+					// @/ 是 src/ 的别名
+					// prependData: `@import "@/assets/scss/base.scss";`
+				}
+			}
+		}
+	};
+	
+}