feat: 超过一定天数范围内,随机部分天数不提交

This commit is contained in:
OBKoro1 2020-08-31 11:32:23 +08:00
parent b19b711097
commit de4b93eb85
2 changed files with 70 additions and 7 deletions

View File

@ -1,9 +1,9 @@
/* /*
* Author : OBKoro1 * Author : OBKoro1
* Date : 2019-12-30 16:59:30 * Date : 2019-12-30 16:59:30
* @LastEditors : OBKoro1 * LastEditors : OBKoro1
* @LastEditTime : 2020-01-15 11:46:52 * LastEditTime : 2020-08-29 14:21:47
* FilePath : /autoCommit/src/models/commitHandle.ts * FilePath : \autoCommit\src\models\commitHandle.ts
* Description : commit * Description : commit
* https://github.com/OBKoro1 * https://github.com/OBKoro1
*/ */
@ -34,11 +34,13 @@ interface dayTime {
class CommitHandle { class CommitHandle {
public paramsObj: any; public paramsObj: any;
public moreObj: any;
public timeArr: Array<dayTime>; public timeArr: Array<dayTime>;
public autoCommitView: WebView; public autoCommitView: WebView;
private userCancel: boolean; private userCancel: boolean;
constructor(message: webviewMsg) { constructor(message: webviewMsg) {
this.paramsObj = message.data; this.paramsObj = message.data.form;
this.moreObj = message.data.moreObj;
this.timeArr = []; this.timeArr = [];
console.log('seb',sep) console.log('seb',sep)
this.timeHandle(); this.timeHandle();
@ -88,7 +90,20 @@ class CommitHandle {
} }
} }
); );
this.commitFn(); this.deleteDayArrDay()
this.commitFn()
}
// 随机删除日期数组中的某几天
deleteDayArrDay() {
const noCommitDay = this.moreObj.noCommitDay
const scopeDay = this.moreObj.scopeDay
if(scopeDay < 1 || noCommitDay < 1) return // 必须大于1
if(scopeDay > this.timeArr.length) return // 日期不够
// 删除
for(let i = 0; i < noCommitDay; i++){
let ranDomNum = Math.floor(Math.random() * this.timeArr.length); // 随机数
this.timeArr.splice(ranDomNum, 1);
}
} }
async commitFn() { async commitFn() {
await outputLog('将要commit的日期:', JSON.stringify(this.timeArr)); await outputLog('将要commit的日期:', JSON.stringify(this.timeArr));

View File

@ -43,6 +43,32 @@
<el-input class="input_form" v-model="form.commitMsg" @change="commitMsgChange"></el-input> <el-input class="input_form" v-model="form.commitMsg" @change="commitMsgChange"></el-input>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item class="form_item">
<label slot="label">
<el-tooltip class="item" content="更多细节设置" placement="top-start">
<span>更多设置 :</span>
</el-tooltip>
</label>
<el-switch
@change="switchChange"
v-model="more"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</el-form-item>
<el-form-item class="form_item" v-if="more">
<label slot="label">
<el-tooltip class="item" content="间隔一定时间范围不提交commit几天这样看起来更逼真" placement="top-start">
<span>间隔提交 :</span>
</el-tooltip>
</label>
<span>超出时间范围:</span>
<el-input-number v-model="moreObj.scopeDay" :step="1" :min="0" size="mini"></el-input-number>
<span>超出这个范围随机不提交天数:</span>
<el-input-number v-model="moreObj.noCommitDay" :step="1" :min="0" size="mini"></el-input-number>
</el-form-item>
<el-form-item class="form_item" prop="commitNumber"> <el-form-item class="form_item" prop="commitNumber">
<label slot="label"> <label slot="label">
<el-tooltip class="item" content="时间范围内默认每个日期是否随机commit" placement="top-start"> <el-tooltip class="item" content="时间范围内默认每个日期是否随机commit" placement="top-start">
@ -186,7 +212,7 @@
commitNumber: 0 commitNumber: 0
} }
], ],
commitNumber: 10, commitNumber: 10
}, },
rules: { rules: {
'itemSrc': [ 'itemSrc': [
@ -213,6 +239,12 @@
required: true required: true
} }
] ]
},
// 更多设置
more: false,
moreObj: {
scopeDay: 0, // 多长的时间范围
noCommitDay: 0, // 这段时间不提交几天
} }
}; };
}, },
@ -241,9 +273,25 @@
if(isWeb){ if(isWeb){
this.mockLog() this.mockLog()
}else{ }else{
this.postMessage('commit', this.form); const params = {
form: this.form,
moreObj: this.moreObj
}
this.postMessage('commit', params);
} }
}, },
// 验证表单数据
checkData() {
if(this.moreObj.scopeDay !== 0 && this.moreObj.scopeDay === this.moreObj.noCommitDay){
this.$message({
type: 'error',
showClose: true,
message: `更多设置中日期范围和不提交天数不能相同`,
});
return false
}
return true
},
// 发送消息到插件 // 发送消息到插件
postMessage(command, data) { postMessage(command, data) {
vscode.postMessage({ vscode.postMessage({