• wanli's avatar
    update · cbb728ad
    wanli authored
    cbb728ad
opqcp.vue 2.55 KB
<template>
  <div class="app-container">
    <el-alert title="代码混淆工具" type="success"></el-alert>
    <div style="margin: 10px 0px">
      <el-form>
        <el-form-item>
          <el-upload
            class="upload-demo"
            action="/api/v1/evm_store/upload"
            name="binfile"
            :on-success="handleUploaded"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">
              上传C源文件,转换完成后会自动下载
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="getConvertString">转换</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { actionOpqcp } from "@/api/app-store";

export default {
  name: "Opqcp",
  data() {
    return {
      fileList: [],
      inputString: null,
      outputString: null,
      filename: "app.js",
    };
  },
  methods: {
    createFile(content, filename) {
      const a = document.createElement("a");
      const blob = new Blob([content]);
      const url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = filename;
      a.click();
      window.URL.revokeObjectURL(url);
    },
    handleUploaded(response) {
      if (response.code == 200) {
        this.filename = response.data.filename
        actionOpqcp({ filename: response.data.filepath })
          .then((res) => {
            this.$message.success(res.message);
            // const a = document.createElement("a");
            // a.href = url;
            // a.download = filename;
            // a.click();
          })
          .catch((err) => {
            this.$message.error(err.message);
          });
      }
      console.log(response)
    },
    downloadFile() {
      this.$prompt("请输入文件名", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputValue: this.filename,
        inputErrorMessage: "文件名格式不正确",
      })
        .then(({ value }) => {
          if (value) this.filename = value;
          this.createFile(this.outputString, this.filename);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    getConvertString() {

    },
  },
  mounted() {},
  created() {},
};
</script>
<style lang="scss" scoped>
.app-container {
  & > div.page-wrapper {
    margin: 10px 0px;
  }
}
</style>