Commit 64855b5b by liyaoting

first

0 parents
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>happy~happy~happy~</title>
<script src="./static/js/jquery-3.6.1.min.js"></script>
<script src="./static/js/vue-2.6.10.min.js"></script>
<script src="./static/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./static/css/bootstrap.min.css">
<link rel="stylesheet" href="./static/css/bootstrap-theme.min.css">
</head>
<style>
</style>
<body>
<h1 style="text-align: center"></h1>
<div id="app" class="main container">
<!-- 导航栏 -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="">happy~happy~happy~</a>
<button type="button" class="btn btn-default navbar-btn" @click="copyNew">复制出来</button>
</div>
</div>
</nav>
<!-- 文本输入框 -->
<div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">把配置贴到这</span>
<textarea v-model="source" class="form-control" rows="2"></textarea>
</div>
</div>
<!--表格-->
<table class="table table-striped" v-if="serviceList.length">
<thead class="thead-dark">
<tr>
<th>No.</th>
<th>服务名</th>
<th>是否需要部署</th>
</tr>
</thead>
<tbody>
<tr v-for="(item,i) in serviceList">
<td>{{i+1}}</td>
<td>
<h3 v-if="!item.isWebService">{{item.serviceName}}</h3>
<h4 v-else>{{item.serviceName}}</h4>
</td>
<td><input class="form-check-input" type="checkbox" v-model="item.isOpen"/></td>
</tr>
</tbody>
</table>
</div>
</body>
<script type="text/javascript">
new Vue({
el: '#app',
//监听source变动
watch: {
source: function (val) {
this.source = val;
this.analyseSource();
},
},
data: {
source: '', //复制过来的
sourceArr: [], //按行分割的
serviceList: [], //服务列表
},
created: function () {
},
mounted() {
//等一会儿再执行
setTimeout(() => {
let sysPayload = window.sysPayload;
if (sysPayload) {
let source = ""
if (sysPayload.indexOf("node") == -1) {
source = "请手动粘贴吧"
}else{
source = sysPayload;
}
this.source = source;
this.analyseSource();
}else{
this.source = "请手动粘贴吧";
}
}, 500);
},
methods: {
//分析source
analyseSource: function () {
let serviceMap = {};
let serviceList = [];
let source = this.source;
console.log(source)
//将source按行分割
let sourceArr = source.split("\n");
//upload的开始行
let uploadStartRow = 0;
//upload的结束行
let uploadEndRow = 0;
//imageBuild的开始行
let imageBuildStart = 0;
//imageBuild的结束行
let imageBuildEnd = 0;
//找出关键行的行号
for (let i = 0; i < sourceArr.length; i++) {
let row = sourceArr[i].trim();
let nextRow = "";
if (i != sourceArr.length - 1) {
nextRow = sourceArr[i + 1].trim();
}
//upload的开始行
if (row == "stage('upload') {") {
console.log("uploadStartRow:" + i)
uploadStartRow = i + 1;
}
//upload的结束行和imageBuild的开始行
if (row == "}" && nextRow == "stage('image build') {") {
uploadEndRow = i;
imageBuildStart = i + 2;
}
//imageBuild的结束行
if (row == "}" && uploadEndRow != 0 && imageBuildEnd == 0 && i != uploadEndRow) {
imageBuildEnd = i;
}
}
let uploadRow = 0;
sourceArr.slice(uploadStartRow, uploadEndRow).forEach((item, index) => {
uploadRow = uploadStartRow + index;
let row = item.trim();
if (!row) {
return;
}
let isOpen = !!(row && !row.startsWith("//"));
let strings = item.split("*.jar")[0].split("/");
let serviceName = strings[strings.length - 1].substring(0, strings[strings.length - 1].length - 1);
let service = {
isOpen: isOpen,
uploadRowNo: uploadRow,
uploadRow: row,
serviceName: serviceName,
isWebService: serviceName.indexOf("web") > -1,
}
serviceMap[service.serviceName] = service;
})
let buildRowNo = 0;
sourceArr.slice(imageBuildStart, imageBuildEnd).forEach((item, index) => {
buildRowNo = imageBuildStart + index;
let trimItem = item.trim();
if (item.indexOf("sleep") === -1 && trimItem) {
let serviceName = item.split(".sh ")[1].split(" ")[0];
let service = serviceMap[serviceName];
if (!service) {
return;
}
service.buildRowNo = buildRowNo;
service.buildRow = trimItem;
if (service.isOpen) {
if (trimItem.startsWith("//")) {
service.buildRow = trimItem.substring(2);
}
} else {
if (!trimItem.startsWith("//")) {
service.buildRow = "//" + trimItem;
}
}
}
})
//serviceMap转为数组
for (let key in serviceMap) {
serviceList.push(serviceMap[key]);
}
this.sourceArr = sourceArr;
this.serviceList = serviceList;
},
//复制出来
copyNew: function () {
let {serviceList, sourceArr} = this;
if (!serviceList.length) {
alert("你输入的内容不对");
} else {
serviceList.forEach((item) => {
let uploadRow = item.uploadRow;
let buildRow = item.buildRow;
sourceArr[item.uploadRowNo] = uploadRow;
sourceArr[item.buildRowNo] = buildRow;
if (item.isOpen) {
if (uploadRow.startsWith("//")) {
uploadRow = uploadRow.split("//")[1];
}
if (buildRow.startsWith("//")) {
buildRow = buildRow.split("//")[1];
}
} else {
//如果是关闭的 还没有注释的话,就注释掉
if (!uploadRow.startsWith("//")) {
uploadRow = "//" + uploadRow;
}
if (!buildRow.startsWith("//")) {
buildRow = "//" + buildRow;
}
}
//格式
sourceArr[item.uploadRowNo] = "\t\t" + uploadRow;
sourceArr[item.buildRowNo] = "\t\t" + buildRow;
});
//组合成原来的字符串
let newSource = "";
sourceArr.forEach(item => {
newSource += item + "\n";
})
//复制到剪切板
let txa = document.createElement('textarea')
txa.value = newSource
document.body.appendChild(txa)
txa.select()
document.execCommand('copy')
document.body.removeChild(txa)
alert("复制成功");
}
}
}
})
</script>
</html>
\ No newline at end of file
logo.png

5.58 KB

{
"main": "index.html",
"logo": "logo.png",
"preload": "preload.js",
"features": [
{
"code": "hello",
"explain": "happy",
"cmds":["jk", "jenkins", {
"type": "regex",
"label": "快速配置脚本",
"match": "/jenkins/i"
}]
}
]
}
\ No newline at end of file
// 开发者可以暴露自定义 API 供后加载脚本使用
utools.onPluginEnter(({code, type, payload}) => {
window.sysPayload = payload;
})
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!