|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <nav-bar /> |
| 4 | + |
| 5 | + <el-form ref="form" :model="form" :rules="rules" label-width="120px"> |
| 6 | + <el-form-item label="" prop="description"> |
| 7 | + <el-col :span="10"> |
| 8 | + <span>输入的内容</span> |
| 9 | + </el-col> |
| 10 | + <el-col :span="2"> |
| 11 | + <span> </span> |
| 12 | + </el-col> |
| 13 | + <el-col :span="10"> |
| 14 | + <span>输出的内容</span> |
| 15 | + </el-col> |
| 16 | + </el-form-item> |
| 17 | + <el-form-item label="" prop="input"> |
| 18 | + <el-col :span="10"> |
| 19 | + <el-input v-model="form.input" :rows="20" type="textarea" /> |
| 20 | + </el-col> |
| 21 | + <el-col :span="2"> |
| 22 | + <span> 在线工具输出</span><br><br> |
| 23 | + <el-button type="primary" @click="copyInput">复制输入</el-button> |
| 24 | + <br><br> |
| 25 | + <el-button type="primary" @click="copyOutput">复制输出</el-button> |
| 26 | + <br><br> |
| 27 | + <el-button type="warning" @click="resetForm('form')"> 清 空 </el-button> |
| 28 | + </el-col> |
| 29 | + <el-col :span="11"> |
| 30 | + <el-input v-model="output" :rows="20" type="textarea" /> |
| 31 | + </el-col> |
| 32 | + </el-form-item> |
| 33 | + <el-form-item> |
| 34 | + <el-col :span="10"> </el-col> |
| 35 | + <el-col :span="14"> </el-col> |
| 36 | + <el-col :span="0"> </el-col> |
| 37 | + </el-form-item> |
| 38 | + </el-form> |
| 39 | + <el-row> |
| 40 | + <el-col :span="4"> </el-col> |
| 41 | + <el-col :span="2"> |
| 42 | + <el-button @click="onSubmit('form', 'hex_to_string')">16进制转中文</el-button> |
| 43 | + </el-col> |
| 44 | + <el-col :span="2"> |
| 45 | + <el-button @click="onSubmit('form', 'string_to_hex')">中文转16进制</el-button> |
| 46 | + </el-col> |
| 47 | + <el-col :span="2"> |
| 48 | + <el-button @click="onSubmit('form', 'openid_secret')">OpenId转秘钥</el-button> |
| 49 | + </el-col> |
| 50 | + <el-col :span="2"> |
| 51 | + <el-button @click="onSubmit('form', 'base64_encode')">Base64 Encode</el-button> |
| 52 | + </el-col> |
| 53 | + <el-col :span="2"> |
| 54 | + <el-button @click="onSubmit('form', 'base64_decode')">Base64 Decode</el-button> |
| 55 | + </el-col> |
| 56 | + <el-col :span="2"> |
| 57 | + <el-button @click="onSubmit('form', 'url_encode')">Url Encode</el-button> |
| 58 | + </el-col> |
| 59 | + <el-col :span="2"> |
| 60 | + <el-button @click="onSubmit('form', 'url_decode')">Url Decode</el-button> |
| 61 | + </el-col> |
| 62 | + </el-row> |
| 63 | + <Footer /> |
| 64 | + </div> |
| 65 | +</template> |
| 66 | + |
| 67 | +<script> |
| 68 | +import request from '@/utils/request' |
| 69 | +import { Footer } from '../../layout/components' |
| 70 | +
|
| 71 | +export default { |
| 72 | + name: 'Lines', |
| 73 | + components: { |
| 74 | + Footer |
| 75 | + }, |
| 76 | + data() { |
| 77 | + return { |
| 78 | + form: { |
| 79 | + input: '', |
| 80 | + output: '' |
| 81 | + }, |
| 82 | + convert: '', |
| 83 | + rules: { |
| 84 | + input: [ |
| 85 | + { required: true, message: '请输入内容', trigger: 'blur' } |
| 86 | + ] |
| 87 | + }, |
| 88 | + loading: false, |
| 89 | + isShow: false, |
| 90 | + output: '' |
| 91 | + } |
| 92 | + }, |
| 93 | + created() {}, |
| 94 | + methods: { |
| 95 | + copyInput() { |
| 96 | + const that = this |
| 97 | + that.$copyText(this.form.input).then(function(e) { |
| 98 | + that.$message({ |
| 99 | + message: '输入内容复制成功', |
| 100 | + type: 'success' |
| 101 | + }) |
| 102 | + }, function(e) { |
| 103 | + this.$message({ |
| 104 | + message: '复制失败', |
| 105 | + type: 'error' |
| 106 | + }) |
| 107 | + console.log(e) |
| 108 | + }) |
| 109 | + }, |
| 110 | + copyOutput() { |
| 111 | + const that = this |
| 112 | + this.$copyText(this.output).then(function(e) { |
| 113 | + that.$message({ |
| 114 | + message: '输出内容复制成功', |
| 115 | + type: 'success' |
| 116 | + }) |
| 117 | + // console.log(e) |
| 118 | + }, function(e) { |
| 119 | + this.$message({ |
| 120 | + message: '复制失败', |
| 121 | + type: 'error' |
| 122 | + }) |
| 123 | + console.log(e) |
| 124 | + }) |
| 125 | + }, |
| 126 | + onSubmit(form, func) { |
| 127 | + this.$refs[form].validate((valid) => { |
| 128 | + if (valid) { |
| 129 | + this.loading = true |
| 130 | + const uri = '/api/tool' |
| 131 | + request.post(uri, { operation: func, input: this.form.input }).then(res => { |
| 132 | + // this.loading = false |
| 133 | + // console.log(res.data) |
| 134 | + if (res.data.to) { |
| 135 | + this.to = res.data.to |
| 136 | + } |
| 137 | + this.output = res.data.output |
| 138 | + }).catch(err => { |
| 139 | + return err |
| 140 | + // console.log(err) |
| 141 | + }) |
| 142 | + setTimeout(() => { |
| 143 | + this.loading = false |
| 144 | + }, 500) |
| 145 | + } else { |
| 146 | + // this.$message('error submit!') |
| 147 | + // console.log('error submit!!') |
| 148 | + return false |
| 149 | + } |
| 150 | + }) |
| 151 | + this.convert = '' |
| 152 | + }, |
| 153 | + onCancel() { |
| 154 | + this.$message({ |
| 155 | + message: 'cancel!', |
| 156 | + type: 'warning' |
| 157 | + }) |
| 158 | + }, |
| 159 | + resetForm(formName) { |
| 160 | + this.$refs[formName].resetFields() |
| 161 | + } |
| 162 | + } |
| 163 | +} |
| 164 | +</script> |
| 165 | + |
| 166 | +<style scoped> |
| 167 | + .el-input { |
| 168 | + width: 97%; |
| 169 | + margin-bottom: 3%; |
| 170 | + } |
| 171 | +
|
| 172 | + .input-with-select .el-input-group__prepend { |
| 173 | + background-color: #fff; |
| 174 | + } |
| 175 | +</style> |
0 commit comments