当前位置: 首页 > news >正文

【sgCreateAPI】自定义小工具:敏捷开发→自动化生成API接口脚本(接口代码生成工具)

 

<template><div :class="$options.name"><div class="sg-head">接口代码生成工具</div><div class="sg-container"><div class="sg-start "><div style="margin-bottom: 10px;">接口地址列表</div><el-input style="margin-bottom: 10px;" type="textarea" :placeholder="`请粘贴apifox.com网站的内容`"v-model="textareaValue1" :rows="30" show-word-limit /><el-button type="primary" @click="createAPI">生成接口列表</el-button></div><div class="sg-center ">→</div><div class="sg-end "><div style="margin-bottom: 10px;">直接复制</div><el-input style="margin-bottom: 10px;" type="textarea" :placeholder="`请复制代码`" v-model="textareaValue2":rows="30" show-word-limit /><el-button type="primary" @click="copyAPI">复制</el-button></div></div></div>
</template><script>
export default {name: 'sgCreateAPI',data() {return {textareaValue1: '',textareaValue2: '',}},watch: {textareaValue1(newValue, oldValue) {newValue && this.createAPI(newValue)},},methods: {createAPI(d) {let texts = this.textareaValue1.split('\n').map(v => v.split('\t').join(''));let r = []texts.forEach((v, i, arr) => {if (i % 3 === 0 && v) {r.push([arr[i], arr[i + 2].split('/rp/')[1]])}});let apis = [];r.forEach(v => apis.push(`/* ${v[0]} */${v[1].split('/').slice(1).join('_')}({ data, doing }) { this.__sd("post", \`\${API_ROOT_URL}/${v[1]}\`, data, doing); },`));this.textareaValue2 = apis.join('\n');this.copyAPI(apis);},copyAPI(d) {this.$g.copy(this.textareaValue2, true);},},
};
</script><style lang="scss" scoped>
.sgCreateAPI {width: 100%;height: 100%;position: absolute;box-sizing: border-box;padding: 20px;.sg-head {display: flex;justify-content: center;align-items: center;font-size: 24px;font-weight: bold;color: #409EFF;margin-bottom: 10px;}.sg-container {display: flex;flex-wrap: nowrap;&>.sg-start {width: 50%;flex-grow: 1;}&>.sg-center {display: flex;justify-content: center;align-items: center;flex-grow: 1;margin: 0 10px;font-size: 24px;color: #409EFF;font-weight: bold;}&>.sg-end {width: 50%;flex-shrink: 0;}>>>textarea {max-height: revert;height: calc(100vh - 200px);word-wrap: break-word;word-break: break-all;white-space: break-spaces;}}
}
</style>

生成的接口请求代码是基于【Vue.js最新版】【基于jQuery Ajax】[sd.js]最新原生完整版for凯哥API版本_你挚爱的强哥的博客-CSDN博客【代码】【最新版】【基于jQuery Ajax】[sd.js]最新原生完整版for凯哥API版本。https://blog.csdn.net/qq_37860634/article/details/129976375

http://www.lryc.cn/news/160969.html

相关文章:

  • 数据库相关基础知识
  • LeetCode刷题笔记【23】:贪心算法专题-1(分发饼干、摆动序列、最大子序和)
  • C++算法 —— 分治(2)归并
  • Hadoop YARN HA 集群安装部署详细图文教程
  • BBS+商城项目的数据库表设计
  • 如何使用Savitzky-Golay滤波器进行轨迹平滑
  • Nomad系列-Nomad网络模式
  • OpenCV项目开发实战--实现面部情绪识别对情绪进行识别和分类及详细讲解及完整代码实现
  • Validate表单组件的封装
  • 企业架构LNMP学习笔记32
  • 基于Jetty9的Geoserver配置https证书
  • 企业互联网暴露面未知资产梳理
  • 【动态规划刷题 12】等差数列划分 最长湍流子数组
  • react-redux 的使用
  • 77 # koa 中间件的应用
  • 【css】z-index与层叠上下文
  • 系统架构设计师(第二版)学习笔记----多媒体技术
  • 【面试经典150 | 数组】合并两个有序数组
  • 系统架构设计专业技能 ·操作系统
  • CSP 202209-1 如此编码
  • windows安装向量数据库milvus
  • Qt中,QScript对JavaScript的内置接口支持情况
  • C语言基础-typedef的用法
  • Linux中安装MySQL5.7.42
  • 网络基础--1.网络纵横
  • Django TypeError: Abstract models cannot be instantiated.错误解决方案
  • vscode使用delve调试golang程序
  • 如何从任何苹果、Windows或安卓设备访问iCloud照片
  • 关于“找不到mfc140u.dll,无法继续执行代码”问题的分析处理方法
  • 用 TripletLoss 优化bert ranking