mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 11:34:05 +08:00
update files
This commit is contained in:
parent
b31cda4eab
commit
37587ea685
@ -186,9 +186,7 @@ AppConfigure.prototype = {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'save':
|
case 'save':
|
||||||
context.save(configure, function (){
|
context.save(configure, null, function (){
|
||||||
this.showMessageBox('保存成功!', { type: 'info' });
|
|
||||||
}, function (){
|
|
||||||
this.showMessageBox('保存失败!');
|
this.showMessageBox('保存失败!');
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -15,15 +15,19 @@ require('../components/project-base');
|
|||||||
require('../components/dynamic-item');
|
require('../components/dynamic-item');
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', function (){
|
window.addEventListener('DOMContentLoaded', function (){
|
||||||
|
function normalize(configure){
|
||||||
|
return JSON.parse(JSON.stringify(configure));
|
||||||
|
}
|
||||||
|
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
configure: { projects: [] }
|
configure: {}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'save-configure': function (){
|
'save-configure': function (){
|
||||||
|
ipc.send('app-configure', 'save', normalize(this.configure));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,9 +27,22 @@ module.exports = Vue.component('app-configure', {
|
|||||||
popup: false
|
popup: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
uniqueCache: function (){
|
||||||
|
var cache = {};
|
||||||
|
|
||||||
|
this.configure.projects && this.configure.projects.forEach(function (project){
|
||||||
|
cache[project.name] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
focus: function (){
|
focus: function (event){
|
||||||
this.submitError = '';
|
if (event.target.type === 'text') {
|
||||||
|
this.submitError = '';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
appConfigure: function (command, configure){
|
appConfigure: function (command, configure){
|
||||||
ipc.send('app-configure', command, configure);
|
ipc.send('app-configure', command, configure);
|
||||||
@ -45,25 +58,23 @@ module.exports = Vue.component('app-configure', {
|
|||||||
addProject: function (){
|
addProject: function (){
|
||||||
this.$broadcast('submit');
|
this.$broadcast('submit');
|
||||||
|
|
||||||
|
console.log(this.uniqueCache[this.name]);
|
||||||
|
|
||||||
if (this.name && this.path) {
|
if (this.name && this.path) {
|
||||||
if (this.$data._cached[this.name]) {
|
if (this.uniqueCache[this.name]) {
|
||||||
this.submitError = '项目已存在';
|
this.submitError = '项目已存在';
|
||||||
} else {
|
} else {
|
||||||
this.popup = false;
|
this.popup = false;
|
||||||
this.configure.projects.push({ name: this.name, path: this.path });
|
this.configure.projects.push({ name: this.name, path: this.path });
|
||||||
this.$data._cached[this.name] = true;
|
|
||||||
|
|
||||||
// clean imput
|
// clean imput
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.path = '';
|
this.path = '';
|
||||||
this.submitError = '';
|
this.submitError = '';
|
||||||
|
|
||||||
|
this.$dispatch('save-configure');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
created: function (){
|
|
||||||
this.configure.projects.forEach(function (project){
|
|
||||||
this.$data._cached[project.name] = true;
|
|
||||||
}, this);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,8 +29,10 @@ module.exports = Vue.component('project-base', {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
focus: function (key){
|
focus: function (key, event){
|
||||||
this[key] = '';
|
if (event.target.type === 'text') {
|
||||||
|
this[key] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<li>
|
<li>
|
||||||
<label>项目名称:</label>
|
<label>项目名称:</label>
|
||||||
<input type="text" v-model="name" placeholder="项目名称" lazy @focus="focus('nameError')"/>
|
<input type="text" v-model="name" placeholder="项目名称" lazy @focus="focus('nameError', $event)"/>
|
||||||
</li>
|
</li>
|
||||||
<li v-show="nameError" class="ui-item-error">
|
<li v-show="nameError" class="ui-item-error">
|
||||||
<label class="fn-invisible">     </label>
|
<label class="fn-invisible">     </label>
|
||||||
<span><i class="icon-expand"></i>{{ nameError }}</span>
|
<span><i class="icon-expand"></i>{{ nameError }}</span>
|
||||||
</li>
|
</li>
|
||||||
<li @focusin="focus('pathError')">
|
<li @focusin="focus('pathError', $event)">
|
||||||
<directory label="项目路径" :path.sync="path"></directory>
|
<directory label="项目路径" :path.sync="path"></directory>
|
||||||
</li>
|
</li>
|
||||||
<li v-show="pathError" class="ui-item-error">
|
<li v-show="pathError" class="ui-item-error">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user