mirror of
https://github.com/nuintun/command-manager.git
synced 2025-10-20 18:31:21 +08:00
update files
This commit is contained in:
@@ -9,32 +9,27 @@ var path = require('path');
|
||||
var ipc = require('ipc-renderer');
|
||||
var Vue = require('../../vue/vue');
|
||||
|
||||
module.exports = Vue.component('app-configure', {
|
||||
template: fs.readFileSync(path.join(__dirname, 'app-configure.html')).toString(),
|
||||
module.exports = Vue.component('project-configure', {
|
||||
template: fs.readFileSync(path.join(__dirname, 'project-configure.html')).toString(),
|
||||
props: {
|
||||
configure: {
|
||||
activeIndex: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
projects: {
|
||||
type: Object,
|
||||
twoWay: true,
|
||||
required: true
|
||||
},
|
||||
uniqueProjects: {
|
||||
type: Object,
|
||||
twoWay: true,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data: function (){
|
||||
return {
|
||||
name: '',
|
||||
path: '',
|
||||
submitError: '',
|
||||
popup: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
uniqueCache: function (){
|
||||
var cache = {};
|
||||
|
||||
this.configure.projects.forEach(function (project){
|
||||
cache[project.name] = true;
|
||||
});
|
||||
|
||||
return cache;
|
||||
project: function (){
|
||||
return this.projects[this.activeIndex] || { name: '', path: '', env: [], command: [] };
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -43,39 +38,10 @@ module.exports = Vue.component('app-configure', {
|
||||
this.submitError = '';
|
||||
}
|
||||
},
|
||||
appConfigure: function (command, configure){
|
||||
ipc.send('app-configure', command, configure);
|
||||
},
|
||||
popupToggle: function (){
|
||||
this.popup = !this.popup;
|
||||
|
||||
if (!this.popup) {
|
||||
this.name = '';
|
||||
this.path = '';
|
||||
this.submitError = '';
|
||||
this.$broadcast('clean-error');
|
||||
}
|
||||
},
|
||||
addProject: function (){
|
||||
edit: function (){
|
||||
this.$broadcast('submit');
|
||||
|
||||
if (this.name && this.path) {
|
||||
if (this.uniqueCache[this.name]) {
|
||||
this.submitError = '项目已存在';
|
||||
} else {
|
||||
this.popup = false;
|
||||
this.configure.projects.push({ name: this.name, path: this.path });
|
||||
|
||||
// clean imput
|
||||
this.name = '';
|
||||
this.path = '';
|
||||
this.submitError = '';
|
||||
|
||||
// send message
|
||||
this.$dispatch('change-active', this.configure.projects.length - 1);
|
||||
this.$dispatch('save-configure');
|
||||
}
|
||||
}
|
||||
console.log(this.project);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user