浏览代码

Fixed issues with lofig, added recaptcha to lofig

theflametrooper 8 年之前
父节点
当前提交
4a9b0161ed
共有 5 个文件被更改,包括 21 次插入9 次删除
  1. 0 1
      backend/logic/utils.js
  2. 6 5
      frontend/App.vue
  3. 3 0
      frontend/build/config/template.json
  4. 1 1
      frontend/build/index.html
  5. 11 2
      frontend/components/pages/Home.vue

+ 0 - 1
backend/logic/utils.js

@@ -52,7 +52,6 @@ class Timer {
 }
 
 function convertTime (duration) {
-
 	let a = duration.match(/\d+/g);
 
 	if (duration.indexOf('M') >= 0 && duration.indexOf('H') == -1 && duration.indexOf('S') == -1) {

+ 6 - 5
frontend/App.vue

@@ -34,14 +34,15 @@
 				location.reload();
 			}
 		},
-		ready: function () {
+		ready() {
+			let _this = this;
 			lofig.get('socket.url', function(res) {
-				let socket = this.socket = io(window.location.protocol + '//' + res);
-				socket.on("ready", status => this.loggedIn = status);
+				let socket = _this.socket = io(window.location.protocol + '//' + res);
+				socket.on("ready", status => _this.loggedIn = status);
 				socket.emit("stations.index", data => {
 					if (data.status === "success")  data.stations.forEach(station => {
-						if (station.type == 'official') this.stations.official.push(station);
-						else this.stations.community.push(station);
+						if (station.type == 'official') _this.stations.official.push(station);
+						else _this.stations.community.push(station);
 					});
 				});
 			});

+ 3 - 0
frontend/build/config/template.json

@@ -1,5 +1,8 @@
 {
 	"socket": {
 		"url": ""
+	},
+	"recaptcha": {
+		"key": ""
 	}
 }

+ 1 - 1
frontend/build/index.html

@@ -13,10 +13,10 @@
 	<script src="/vendor/jquery.min.js"></script>
 	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.0/moment.min.js"></script>
 	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.8/socket.io.min.js"></script>
-	<script src='https://www.google.com/recaptcha/api.js'></script>
 	<script src='https://cdn.rawgit.com/atjonathan/lofig/master/lofig.js'></script>
 </head>
 <body>
 	<script src="/bundle.js"></script>
+	<script src='https://www.google.com/recaptcha/api.js'></script>
 </body>
 </html>

+ 11 - 2
frontend/components/pages/Home.vue

@@ -22,7 +22,7 @@
 					<p class="control">
 						<input class="input" type="password" placeholder="Password..." v-model="$parent.register.password">
 					</p>
-					<div class="g-recaptcha" data-sitekey="6LdNCQcUAAAAANj_w5leQSrxnAmDp2ioh4alkUHg"></div>
+					<div class="g-recaptcha" :data-sitekey="recaptcha.key"></div>
 				</section>
 				<footer class="modal-card-foot">
 					<a class="button is-primary" @click="submitModal('register')">Submit</a>
@@ -98,9 +98,18 @@
 		data() {
 			return {
 				isRegisterActive: false,
-				isLoginActive: false
+				isLoginActive: false,
+				recaptcha: {
+					key: ''
+				}
 			}
 		},
+		ready() {
+			let _this = this;
+			lofig.get('recaptcha.key', function(key) {
+				_this.recaptcha.key = key;
+			});
+		},
 		methods: {
 			toggleModal: function(type) {
 				switch(type) {