【sgCreateCallAPIFunctionParam】自定义小工具:敏捷开发→调用接口方法参数生成工具

html 复制代码
<template>
  <div :class="$options.name" class="sgDevTool">
    <sgHead />
    <div class="sg-container">
      <div class="sg-start">
        <div style="margin-bottom: 10px">
          参数列表[逗号模式]
          <el-tooltip
            :content="`如何获取参数列表[逗号模式]?`"
            :effect="`dark`"
            :enterable="false"
            :placement="`top`"
            :transition="`none`"
          >
            <el-link
              icon="el-icon-info"
              :underline="false"
              @click="$refs.image.showViewer = true"
            />
          </el-tooltip>

          <el-image
            ref="image"
            style="display: none"
            :preview-src-list="[`~@/../static/img/${$options.name}.gif`]"
          />
        </div>

        <el-input
          style="margin-bottom: 10px"
          ref="textareaValue1"
          type="textarea"
          :placeholder="`请粘贴apifox.com网站对应接口-运行-body-[x-www-form-urlencoded]-批量编辑-逗号模式,复制内容`"
          v-model="textareaValue1"
          show-word-limit
        />

        <el-button type="primary" @click="createResult">运行</el-button>
      </div>
      <div class="sg-center">→</div>

      <div class="sg-end">
        <ouputTextarea ref="ouputTextarea" v-model="textareaValue2" />
      </div>
    </div>
  </div>
</template>

<script>
import sgHead from "@/vue/components/sgHead";
import ouputTextarea from "@/vue/components/ouputTextarea";
export default {
  name: "sgCreateCallAPIFunctionParam",
  components: {
    sgHead,
    ouputTextarea,
  },
  data() {
    return {
      textareaValue1: localStorage[`sgDevTool/leftTextArea`],
      textareaValue2: "",
    };
  },
  computed: {},

  watch: {
    textareaValue1(newValue, oldValue) {
      newValue && this.createResult(newValue);
      localStorage[`sgDevTool/leftTextArea`] = newValue;
    },
  },
  created() {},
  methods: {
    createResult(d) {
      if (this.textareaValue1.includes("true,")) {
        let texts = this.$g.getMultiLineTexts(this.textareaValue1);

        let r = [];
        texts.forEach((v) => {
          if (v.includes("true,")) {
            r.push(
              v
                .split("true,")[1]
                .split(",")[0]
                .replace(/\[/g, ``)
                .replace(/\]/g, ``)
                .replace(/\s+/g, "")
            );
          }
        });

        let params1 = r.join(",");
        let params2 = r.join(",\n");
        this.textareaValue2 = `${params1}

${params2},
`;

        this.$refs.ouputTextarea.copyResult(); //自动复制生成结果
      } else {
        return this.$message.error(this.$refs.textareaValue1.$attrs.placeholder);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "~@/css/sgDevTool";
</style>
相关推荐
十一吖i28 分钟前
vue3表格显示隐藏列全屏拖动功能
前端·javascript·vue.js
冰暮流星2 小时前
css之线性渐变
前端·css
徐同保2 小时前
tailwindcss暗色主题切换
开发语言·前端·javascript
mapbar_front2 小时前
大厂精英为何在中小公司水土不服?
前端
生莫甲鲁浪戴2 小时前
Android Studio新手开发第二十七天
前端·javascript·android studio
细节控菜鸡4 小时前
【2025最新】ArcGIS for JS 实现随着时间变化而变化的热力图
开发语言·javascript·arcgis
2501_916008895 小时前
Web 前端开发常用工具推荐与团队实践分享
android·前端·ios·小程序·uni-app·iphone·webview
SkylerHu5 小时前
前端代码规范:husky+ lint-staged+pre-commit
前端·代码规范
菜鸟una5 小时前
【微信小程序 + 消息订阅 + 授权】 微信小程序实现消息订阅流程介绍,代码示例(仅前端)
前端·vue.js·微信小程序·小程序·typescript·taro·1024程序员节
Yeats_Liao5 小时前
Go Web 编程快速入门 05 - 表单处理:urlencoded 与 multipart
前端·golang·iphone