mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-06 10:54:07 +08:00
update files
This commit is contained in:
parent
aeff3080ba
commit
f29bfb70ac
@ -9,7 +9,7 @@
|
||||
</head>
|
||||
<body id="app" class="fn-clear">
|
||||
<header class="fn-clear">
|
||||
<app-configure :configure.sync="configure"></app-configure>
|
||||
<app-configure :configure.sync="configure" :unique-projects.sync="uniqueProjects"></app-configure>
|
||||
<window-control></window-control>
|
||||
</header>
|
||||
<nav class="ui-project-tree fn-left">
|
||||
|
@ -25,7 +25,21 @@ window.addEventListener('DOMContentLoaded', function (){
|
||||
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;
|
||||
},
|
||||
'save-configure': function (){
|
||||
ipc.send('app-configure', 'save', normalize(this.configure));
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ module.exports = Vue.component('app-configure', {
|
||||
type: Object,
|
||||
twoWay: true,
|
||||
required: true
|
||||
},
|
||||
uniqueProjects: {
|
||||
type: Object,
|
||||
twoWay: true,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data: function (){
|
||||
@ -26,17 +31,6 @@ module.exports = Vue.component('app-configure', {
|
||||
popup: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
uniqueCache: function (){
|
||||
var cache = {};
|
||||
|
||||
this.configure.projects.forEach(function (project){
|
||||
cache[project.name] = true;
|
||||
});
|
||||
|
||||
return cache;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
focus: function (event){
|
||||
if (event.target.type === 'text') {
|
||||
@ -59,10 +53,8 @@ module.exports = Vue.component('app-configure', {
|
||||
addProject: function (){
|
||||
this.$broadcast('submit');
|
||||
|
||||
console.log(this.uniqueCache[this.name]);
|
||||
|
||||
if (this.name && this.path) {
|
||||
if (this.uniqueCache[this.name]) {
|
||||
if (this.uniqueProjects[this.name]) {
|
||||
this.submitError = '项目已存在';
|
||||
} else {
|
||||
this.popup = false;
|
||||
@ -73,6 +65,8 @@ module.exports = Vue.component('app-configure', {
|
||||
this.path = '';
|
||||
this.submitError = '';
|
||||
|
||||
// send message
|
||||
this.$dispatch('change-active', this.configure.projects.length - 1);
|
||||
this.$dispatch('save-configure');
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ module.exports = Vue.component('dynamic-item', {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
uniqueCache: function (){
|
||||
uniqueItems: function (){
|
||||
var cache = {};
|
||||
|
||||
this.items.forEach(function (item){
|
||||
@ -57,7 +57,7 @@ module.exports = Vue.component('dynamic-item', {
|
||||
// name error
|
||||
if (!this.name) {
|
||||
this.nameError = '不能为空';
|
||||
} else if (this.uniqueCache[this.name]) {
|
||||
} else if (this.uniqueItems[this.name]) {
|
||||
this.nameError = ' ' + this.name + ' 已存在';
|
||||
} else {
|
||||
this.nameError = '';
|
||||
@ -71,7 +71,7 @@ module.exports = Vue.component('dynamic-item', {
|
||||
}
|
||||
|
||||
// add item
|
||||
if (this.name && this.value && !this.uniqueCache[this.name]) {
|
||||
if (this.name && this.value && !this.uniqueItems[this.name]) {
|
||||
// add item
|
||||
this.items.push({ name: this.name, value: this.value });
|
||||
|
||||
|
@ -1,3 +1,81 @@
|
||||
/**
|
||||
* Created by nuintun on 2015/11/20.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
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(),
|
||||
props: {
|
||||
configure: {
|
||||
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;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
focus: function (event){
|
||||
if (event.target.type === 'text') {
|
||||
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 (){
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user