diff --git a/src/assets/styles/autoCommit.css b/src/assets/styles/autoCommit.css index 8de36b4..4a52ae3 100644 --- a/src/assets/styles/autoCommit.css +++ b/src/assets/styles/autoCommit.css @@ -1,30 +1,34 @@ #app{ - background: #272822; - height: 100vh; - color: #fff; - } - - .el-main { - background-color: #272822; - } - - .form_item { - font-size: 16px; - } - .form_item .el-form-item__label{ - font-size: 16px; - color: #fff; - } - - .form-title { - padding-top: 20px; - font-weight: bold; - font-size: 30px; - text-align: center; - } - - body > .el-container { - margin-bottom: 40px; - } - - \ No newline at end of file + background: #272822; + height: 100vh; + color: #fff; +} + +.el-main { + background-color: #272822; +} + +body > .el-container { + margin-bottom: 40px; +} + +.form_item { + font-size: 16px; +} + +.el-form-item__label{ + font-size: 16px; + color: #fff; +} + +.form-title { + padding-top: 20px; + font-weight: bold; + font-size: 30px; + text-align: center; +} + +.input_form{ + width: 200px; +} + diff --git a/src/models/WebView.ts b/src/models/WebView.ts index 6d8fa6f..4756fa4 100644 --- a/src/models/WebView.ts +++ b/src/models/WebView.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-26 13:49:02 * LastEditors : OBKoro1 - * LastEditTime : 2019-12-26 20:04:51 + * LastEditTime : 2019-12-29 19:01:20 * FilePath : /autoCommit/src/models/WebView.ts * Description : 创建webview * https://github.com/OBKoro1 @@ -101,7 +101,7 @@ class WebView { // webview消息回调 public handleMessage(message: webviewMsg) { const { command, data } = message; - if (command === 'event') { + if (command !== 'msg') { this.MessageCallBack(message); return; } diff --git a/src/views/autoCommit.html b/src/views/autoCommit.html index 29c494d..cf6560e 100644 --- a/src/views/autoCommit.html +++ b/src/views/autoCommit.html @@ -1,106 +1,216 @@ - - - - Github自动提交commit工具 - - - - - -
-
Github自动提交commit工具
- + + + + Github自动提交commit工具 + + + + + + +
+
Github自动提交commit工具
+ + + + + + {{ form.itemSrc }} + + + + + + + + + + + + + + + + + + + + + 删除 + + + 开始commit + 新增时间范围 + 取消commit + + - - - -
{{ form.itemSrc }}
-
-
- - - - - + + +
-
-
-
- - - - + + - + return { + paramsStr: '', // commit参数 + runNow: false, // 运行中 + form: { + // itemSrc: '/Users/koro/work/web_my/testCommit', + itemSrc: '点击选择要commit的项目文件夹', + fileName: 'commit.md', + commitMsg: 'autoCommit', + timeArr: [ + { + value: '' + } + ], + commitNumber: 1, + }, + rules: { + 'itemSrc': [ + { + validator: itemSrcCheck, // 项目地址 + required: true, + message: '请选择要commit的项目文件夹' + } + ], + 'fileName': [ + { + required: true, + message: '请选择要写入内容的文件' + } + ], + 'commitMsg': [ + { + required: true, + message: '请填入要commit的内容' + } + ], + 'commitNumber': [ + { + required: true + } + ] + } + }; + }, + mounted() { + // this.initListener(); + }, + methods: { + submitForm(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + this.runCommit() + } else { + return false; + } + }); + }, + // 开始commit + runCommit() { + let params = this.form + params.format = this.mapTimeData() + this.runNow = true + this.paramsStr = JSON.stringify(params) + this.postMessage(params, 'commit'); + }, + // 发送消息到插件 + postMessage(data, command) { + vscode.postMessage({ + command, + data + }); + }, + // 注册 + initListener() { + window.addEventListener('message', event => { + console.log('event', event); + const { command, data } = event.data; + console.log('登录成功 addEventListener', event); + if (command === 'success') { + // 登录成功 + } + }); + }, + // 重置: commit成功和中断commit + reset() { + this.runNow = false; + this.paramsStr = '' + + }, + // 删除时间 + removeTime(index) { + this.form.timeArr.splice(index, 1) + }, + // format 一下时间 少嵌套一层 + mapTimeData() { + return this.form.timeArr.map(item => { + return item.value + }) + }, + // 增加时间范围选择 + addTimeRange() { + this.form.timeArr.push({ + value: '' + }); + }, + fileNameChange(value) { + if (value === '') { + this.form.fileName = 'commit.md' + } + }, + commitMsgChange(value) { + if (value === '') { + this.form.commitMsg = 'autoCommit' + } + }, + } + }).$mount('#xpLogin'); + + + \ No newline at end of file