From 2727398d3abde3fdb2f2e05d78240f01b60f4557 Mon Sep 17 00:00:00 2001 From: nuintun Date: Mon, 23 Nov 2015 11:57:33 +0800 Subject: [PATCH] update files --- index.html | 39 +---------- static/js/app/index.js | 1 + .../app-configure/app-configure.html | 2 +- static/js/components/app-configure/index.js | 2 +- static/js/components/app-main/app-main.html | 25 +++++++ static/js/components/dynamic-item/index.js | 1 + .../js/components/project-configure/index.js | 66 +++++-------------- .../project-configure/project-configure.html | 24 ++----- 8 files changed, 51 insertions(+), 109 deletions(-) diff --git a/index.html b/index.html index 1efce3d..01c9594 100644 --- a/index.html +++ b/index.html @@ -40,44 +40,7 @@
-
-
-
-
- - -
-
-
-
项目已经存在
-
    -
  • - - -
  • -
  • - - 项目名称不能为空 -
  • -
  • - -
  • -
  • - - 项目路径不能为空 -
  • -
  • - - -
  • -
  • - - -
  • -
-
-
-
+ diff --git a/static/js/app/index.js b/static/js/app/index.js index 9cd54c4..5fba6b2 100644 --- a/static/js/app/index.js +++ b/static/js/app/index.js @@ -13,6 +13,7 @@ require('../components/app-nav'); require('../components/directory'); require('../components/project-base'); require('../components/dynamic-item'); +require('../components/project-configure'); window.addEventListener('DOMContentLoaded', function (){ function normalize(configure){ diff --git a/static/js/components/app-configure/app-configure.html b/static/js/components/app-configure/app-configure.html index d3336cd..59873b1 100644 --- a/static/js/components/app-configure/app-configure.html +++ b/static/js/components/app-configure/app-configure.html @@ -17,7 +17,7 @@
{{ submitError }}
-
+
  • diff --git a/static/js/components/app-configure/index.js b/static/js/components/app-configure/index.js index 1a6e32f..f24728f 100644 --- a/static/js/components/app-configure/index.js +++ b/static/js/components/app-configure/index.js @@ -50,7 +50,7 @@ module.exports = Vue.component('app-configure', { this.$broadcast('clean-error'); } }, - addProject: function (){ + add: function (){ this.$broadcast('submit'); if (this.name && this.path) { diff --git a/static/js/components/app-main/app-main.html b/static/js/components/app-main/app-main.html index e69de29..11b399e 100644 --- a/static/js/components/app-main/app-main.html +++ b/static/js/components/app-main/app-main.html @@ -0,0 +1,25 @@ + +
    +
    +
    + + +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/static/js/components/dynamic-item/index.js b/static/js/components/dynamic-item/index.js index cefea32..35940f0 100644 --- a/static/js/components/dynamic-item/index.js +++ b/static/js/components/dynamic-item/index.js @@ -23,6 +23,7 @@ module.exports = Vue.component('dynamic-item', { }, items: { type: Array, + twoWay: true, default: function (){ return []; } diff --git a/static/js/components/project-configure/index.js b/static/js/components/project-configure/index.js index f50816b..2f786b3 100644 --- a/static/js/components/project-configure/index.js +++ b/static/js/components/project-configure/index.js @@ -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); } } }); diff --git a/static/js/components/project-configure/project-configure.html b/static/js/components/project-configure/project-configure.html index d32b70d..c9f7629 100644 --- a/static/js/components/project-configure/project-configure.html +++ b/static/js/components/project-configure/project-configure.html @@ -1,5 +1,5 @@
    - +
    @@ -8,28 +8,14 @@
      -
    • - - -
    • -
    • - - 项目名称不能为空 -
    • -
    • - -
    • -
    • - - 项目路径不能为空 -
    • -
    • +
    • +
    • - +
    • - +