diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f6b6d..a94715f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,4 +14,4 @@ ### [V1.0.0] -- Initial release \ No newline at end of file +插件开源 diff --git a/images/autoCommit.gif b/images/autoCommit.gif new file mode 100644 index 0000000..dbe9970 Binary files /dev/null and b/images/autoCommit.gif differ diff --git a/images/commit-color.png b/images/commit-color.png new file mode 100644 index 0000000..493b6a4 Binary files /dev/null and b/images/commit-color.png differ diff --git a/src/models/commitHandle.ts b/src/models/commitHandle.ts index bddf6d5..173b26d 100644 --- a/src/models/commitHandle.ts +++ b/src/models/commitHandle.ts @@ -2,7 +2,7 @@ * Author : OBKoro1 * Date : 2019-12-30 16:59:30 * LastEditors : OBKoro1 - * LastEditTime : 2020-01-07 22:30:03 + * LastEditTime : 2020-01-08 10:48:40 * FilePath : /autoCommit/src/models/commitHandle.ts * Description : commit 具体操作 * https://github.com/OBKoro1 @@ -13,7 +13,12 @@ import * as moment from 'moment'; import * as fs from 'fs'; import { execSync, exec } from 'child_process'; import { RandomNumber } from '../util/util'; -import { getPanelWebview, outputLog, isProduction } from '../util/vscodeUtil'; +import { + getPanelWebview, + outputLog, + isProduction, + getExtensionContext +} from '../util/vscodeUtil'; import WebView from './WebView'; interface timeElement { @@ -149,7 +154,7 @@ class CommitHandle { if (this.cancelCommit()) { if (totalNum < 1) return; outputLog('回滚中...'); - const res = await new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { let cmd = `cd ${this.paramsObj.itemSrc} && git reset --hard HEAD~${totalNum}`; exec(cmd, (error, stdout, stderr) => { if (error) { @@ -164,6 +169,7 @@ class CommitHandle { }); } else { outputLog('提交中...'); + this.autoCommitView.postMessage('提交中...', '提交中'); const res = await new Promise((resolve, reject) => { let cmd = `cd ${this.paramsObj.itemSrc} && git pull && git push`; exec(cmd, (error, stdout, stderr) => { @@ -182,8 +188,10 @@ class CommitHandle { } commitEnd(totalNum: number) { this.userCancel = false; // 重新打开终止开关 - this.autoCommitView.postMessage('commit 完成', 'commit 完成'); + this.autoCommitView.postMessage('commit 完成', this.paramsObj); + getExtensionContext().globalState.update('commit-params', this.paramsObj); outputLog('自动commit完成', `总commit次数${totalNum}`); + outputLog('保存参数信息'); } cancelCommit() { if (this.userCancel) { diff --git a/src/models/index.ts b/src/models/index.ts index 7ff9635..6eeb610 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,8 +1,8 @@ /* * Author : OBKoro1 * Date : 2019-12-25 17:08:18 - * @LastEditors : OBKoro1 - * @LastEditTime : 2020-01-02 21:49:13 + * LastEditors : OBKoro1 + * LastEditTime : 2020-01-08 10:04:53 * FilePath : /autoCommit/src/models/index.ts * Description : 插件逻辑入口 * https://github.com/OBKoro1 @@ -39,6 +39,9 @@ class ExtensionLogic { }; this.autoCommitView.create(option); this.autoCommitView.postMessage('isProduction', isProduction()); + const formData = this.context.globalState.get('commit-params') + this.autoCommitView.postMessage('init-formData', formData) + } // 处理webview的消息 private messageCallBack(message: webviewMsg) { diff --git a/src/util/vscodeUtil.ts b/src/util/vscodeUtil.ts index 3eb2173..8e40440 100644 --- a/src/util/vscodeUtil.ts +++ b/src/util/vscodeUtil.ts @@ -2,14 +2,14 @@ * Author : OBKoro1 * Date : 2019-12-25 17:13:30 * LastEditors : OBKoro1 - * LastEditTime : 2020-01-02 13:44:30 + * LastEditTime : 2020-01-08 09:59:48 * FilePath : /autoCommit/src/util/vscodeUtil.ts * Description : vscode 相关的公共方法 * https://github.com/OBKoro1 */ import * as vscode from 'vscode'; -let extensionContext = ''; +let extensionContext: vscode.ExtensionContext; let webview: any; // 存储插件上下午文 @@ -18,7 +18,7 @@ function setExtensionContext(context: any) { } // 获取插件上下文 -function getExtensionContext() { +function getExtensionContext(): vscode.ExtensionContext { return extensionContext; } @@ -40,7 +40,7 @@ function outputLog(...arr: any) { // 是否生产环境 function isProduction() { - return process.env.NODE_ENV === 'production' // production时 为打包安装版本 + return process.env.NODE_ENV === 'production'; // production时 为打包安装版本 } // vscode 消息通知 diff --git a/src/views/autoCommit.html b/src/views/autoCommit.html index 106af37..9f4ec02 100644 --- a/src/views/autoCommit.html +++ b/src/views/autoCommit.html @@ -131,7 +131,7 @@