【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>
相关推荐
2501_915373882 小时前
Vue 3零基础入门:从环境搭建到第一个组件
前端·javascript·vue.js
沙振宇4 小时前
【Web】使用Vue3开发鸿蒙的HelloWorld!
前端·华为·harmonyos
运维@小兵5 小时前
vue开发用户注册功能
前端·javascript·vue.js
蓝婷儿5 小时前
前端面试每日三题 - Day 30
前端·面试·职场和发展
oMMh5 小时前
使用C# ASP.NET创建一个可以由服务端推送信息至客户端的WEB应用(2)
前端·c#·asp.net
一口一个橘子6 小时前
[ctfshow web入门] web69
前端·web安全·网络安全
读心悦7 小时前
CSS:盒子阴影与渐变完全解析:从基础语法到创意应用
前端·css
m0_616188497 小时前
使用vue3-seamless-scroll实现列表自动滚动播放
开发语言·javascript·ecmascript
香蕉可乐荷包蛋7 小时前
vue数据可视化开发echarts等组件、插件的使用及建议-浅看一下就行
vue.js·信息可视化·echarts
老马啸西风7 小时前
sensitive-word-admin v2.0.0 全新 ui 版本发布!vue+前后端分离
vue.js·ui·ai·nlp·github·word