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
aeff3080ba
commit
f29bfb70ac
@ -9,7 +9,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body id="app" class="fn-clear">
|
<body id="app" class="fn-clear">
|
||||||
<header 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>
|
<window-control></window-control>
|
||||||
</header>
|
</header>
|
||||||
<nav class="ui-project-tree fn-left">
|
<nav class="ui-project-tree fn-left">
|
||||||
|
@ -25,7 +25,21 @@ window.addEventListener('DOMContentLoaded', function (){
|
|||||||
activeIndex: 0,
|
activeIndex: 0,
|
||||||
configure: { projects: [] }
|
configure: { projects: [] }
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
uniqueProjects: function (){
|
||||||
|
var cache = {};
|
||||||
|
|
||||||
|
this.configure.projects.forEach(function (project){
|
||||||
|
cache[project.name] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
},
|
||||||
events: {
|
events: {
|
||||||
|
'change-active': function (index){
|
||||||
|
this.activeIndex = index;
|
||||||
|
},
|
||||||
'save-configure': function (){
|
'save-configure': function (){
|
||||||
ipc.send('app-configure', 'save', normalize(this.configure));
|
ipc.send('app-configure', 'save', normalize(this.configure));
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@ module.exports = Vue.component('app-configure', {
|
|||||||
type: Object,
|
type: Object,
|
||||||
twoWay: true,
|
twoWay: true,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
uniqueProjects: {
|
||||||
|
type: Object,
|
||||||
|
twoWay: true,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function (){
|
data: function (){
|
||||||
@ -26,17 +31,6 @@ module.exports = Vue.component('app-configure', {
|
|||||||
popup: false
|
popup: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
uniqueCache: function (){
|
|
||||||
var cache = {};
|
|
||||||
|
|
||||||
this.configure.projects.forEach(function (project){
|
|
||||||
cache[project.name] = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
focus: function (event){
|
focus: function (event){
|
||||||
if (event.target.type === 'text') {
|
if (event.target.type === 'text') {
|
||||||
@ -59,10 +53,8 @@ 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.uniqueCache[this.name]) {
|
if (this.uniqueProjects[this.name]) {
|
||||||
this.submitError = '项目已存在';
|
this.submitError = '项目已存在';
|
||||||
} else {
|
} else {
|
||||||
this.popup = false;
|
this.popup = false;
|
||||||
@ -73,6 +65,8 @@ module.exports = Vue.component('app-configure', {
|
|||||||
this.path = '';
|
this.path = '';
|
||||||
this.submitError = '';
|
this.submitError = '';
|
||||||
|
|
||||||
|
// send message
|
||||||
|
this.$dispatch('change-active', this.configure.projects.length - 1);
|
||||||
this.$dispatch('save-configure');
|
this.$dispatch('save-configure');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
uniqueCache: function (){
|
uniqueItems: function (){
|
||||||
var cache = {};
|
var cache = {};
|
||||||
|
|
||||||
this.items.forEach(function (item){
|
this.items.forEach(function (item){
|
||||||
@ -57,7 +57,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
// name error
|
// name error
|
||||||
if (!this.name) {
|
if (!this.name) {
|
||||||
this.nameError = '不能为空';
|
this.nameError = '不能为空';
|
||||||
} else if (this.uniqueCache[this.name]) {
|
} else if (this.uniqueItems[this.name]) {
|
||||||
this.nameError = ' ' + this.name + ' 已存在';
|
this.nameError = ' ' + this.name + ' 已存在';
|
||||||
} else {
|
} else {
|
||||||
this.nameError = '';
|
this.nameError = '';
|
||||||
@ -71,7 +71,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add item
|
// add item
|
||||||
if (this.name && this.value && !this.uniqueCache[this.name]) {
|
if (this.name && this.value && !this.uniqueItems[this.name]) {
|
||||||
// add item
|
// add item
|
||||||
this.items.push({ name: this.name, value: this.value });
|
this.items.push({ name: this.name, value: this.value });
|
||||||
|
|
||||||
|
@ -1,3 +1,81 @@
|
|||||||
/**
|
/**
|
||||||
* Created by nuintun on 2015/11/20.
|
* 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