update files

This commit is contained in:
nuintun
2015-11-23 15:23:34 +08:00
parent 469ebd9744
commit ea69932db8
6 changed files with 105 additions and 49 deletions

View File

@@ -13,43 +13,53 @@ require('../components/app-nav');
require('../components/app-main');
window.addEventListener('DOMContentLoaded', function (){
var app;
function normalize(configure){
return JSON.parse(JSON.stringify(configure));
}
var app = new Vue({
el: '#app',
data: {
activeIndex: 0,
configure: { projects: [] }
},
computed: {
uniqueProjects: function (){
var cache = {};
this.configure.projects.forEach(function (project){
cache[project.name] = true;
});
return cache;
}
},
events: {
'change-active': function (index){
this.activeIndex = index;
function init(configure){
app = new Vue({
el: '#app',
data: {
activeIndex: 0,
configure: configure
},
'save-configure': function (){
ipc.send('app-configure', 'save', normalize(this.configure));
computed: {
uniqueProjects: function (){
var cache = {};
this.configure.projects.forEach(function (project){
cache[project.name] = true;
});
return cache;
}
},
events: {
'change-active': function (index){
this.activeIndex = index;
},
'save-configure': function (){
ipc.send('app-configure', 'save', normalize(this.configure));
}
}
}
});
});
}
ipc.on('app-configure', function (event, command, configure){
switch (command) {
case 'refresh':
app.activeIndex = 0;
configure.projects = configure.projects || [];
app.configure = configure;
if (app) {
app.activeIndex = 0;
configure.projects = configure.projects || [];
app.configure = configure;
app.$broadcast('configure-refresh');
} else {
init(configure);
}
break;
}
});