Merge pull request #119 from lbbniu/master_login_bug

修复首次登陆,节点列表未加载,需要刷新浏览器
pull/125/head
QLeelulu 2018-11-27 10:05:55 +08:00 committed by GitHub
commit a0b66b1d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 11 deletions

View File

@ -46,6 +46,17 @@ var restApi = new Rest('/v1/', (msg) => {
bus.$emit('goLogin')
}
});
var loadNodes = function() {
restApi.GET('nodes').onsucceed(200, (resp) => {
var nodes = {};
for (var i in resp) {
nodes[resp[i].id] = resp[i];
}
store.commit('setNodes', nodes);
resolve();
}).do();
}
Vue.use((Vue, options) => {
Vue.prototype.$rest = restApi;
}, null);
@ -60,6 +71,8 @@ Vue.use((Vue) => {
}
Vue.use(Config);
bus.$emit('conf_loaded', resp);
loadNodes();
}).onfailed((data, xhr) => {
var msg = data ? data : xhr.status + ' ' + xhr.statusText;
bus.$emit('error', msg);
@ -132,17 +145,6 @@ var initConf = new Promise((resolve) => {
restApi.GET('configurations').onsucceed(200, (resp) => {
Vue.use((Vue) => Vue.prototype.$appConfig = resp);
bus.$emit('conf_loaded', resp);
var loadNodes = function() {
restApi.GET('nodes').onsucceed(200, (resp) => {
var nodes = {};
for (var i in resp) {
nodes[resp[i].id] = resp[i];
}
store.commit('setNodes', nodes);
resolve();
}).do();
}
loadNodes();
setInterval(loadNodes, 60*1000);