mirror of
https://github.com/nuintun/command-manager.git
synced 2025-10-20 01:27:47 +08:00
update files
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user