提交 d78551a0 编写于 作者: B baiy 提交者: ninecents

添加变量名转换工具 #44

上级 7468a820
......@@ -89,6 +89,7 @@ npm run serve -adapter=utools
- [moment](https://momentjs.com/)
- [vue-codemirror](https://www.npmjs.com/package/vue-codemirror)
- [sm-crypto](https://github.com/JuneAndGreen/sm-crypto)
- [camelcaseplugin](https://github.com/netnexus/camelcaseplugin)
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
......
......@@ -10,14 +10,12 @@ const tool = [
{
'name': 'hash',
'title': '哈希(hash)',
'cat': ['encryption'],
'keyword': ['md5', 'sha1', 'sha256', 'sha512', 'sm3']
'cat': ['encryption']
},
{
'name': 'encrypt',
'title': '加密/解密',
'cat': ['encryption'],
'keyword': ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2']
'cat': ['encryption']
},
{'name': 'base64', 'title': 'BASE64编码', 'cat': ['encryption']},
{'name': 'json', 'title': 'JSON工具', 'cat': ['conversion', 'serialize']},
......@@ -40,9 +38,18 @@ const tool = [
{'name': 'uuid', 'title': 'UUID生成', 'cat': ['other']},
{'name': 'jsonToObject', 'title': 'JSON转实体类', 'cat': ['conversion', 'serialize']},
{'name': 'ascii', 'title': 'ascii转换', 'cat': ['conversion']},
{'name': 'variableConversion', 'title': '变量名转换', 'cat': ['conversion']},
]
const utools = {
keyword: {
hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'],
encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2']
}
}
module.exports = {
category,
tool
tool,
utools
}
\ No newline at end of file
......@@ -97,6 +97,10 @@ const routes = [
{
path: '/tool/ascii',
component: r => require(['./views/tool/ascii.vue'], r)
},
{
path: '/tool/variableConversion',
component: r => require(['./views/tool/variableConversion.vue'], r)
}
]
......
......@@ -193,7 +193,7 @@ export default {
return h('Input', {
props: {
type:"textarea",
rows:"10",
rows:10,
value: JSON.stringify(historyFactory(this.currentTool).get(index), null, "\t"),
}
})
......
......@@ -47,7 +47,7 @@ const utoolsConfigWrite = () => {
"cmds": ['ctool', '程序开发常用工具']
},
...toolConfig.tool.map((item) => {
let keyword = item.hasOwnProperty("keyword") ? item['keyword'] : [];
let keyword = toolConfig['keyword'].hasOwnProperty(item.name) ? toolConfig['keyword'][item.name] : [];
return {
"code": "ctool-" + item.name,
"explain": item.title,
......
<template>
<heightResize ignore @resize="resize">
<div>
<Row :gutter="10">
<Col span="6">
<input-block top="4px" :text="$t('variableConversion_input')">
<autoHeightTextarea :height="height1" v-model="current.input" :placeholder="$t('variableConversion_input_placeholder')" />
</input-block>
<Col span="6" style="margin-top: 10px">
<Card :padding="0">
<p slot="title">输入变量名</p>
<template slot="extra">
<Button size="small" type="primary" @click="handle()">转换
</Button>
</template>
<Input v-model="current.input" :rows="4" type="textarea" placeholder="变量名 一行一个"></Input>
</Card>
</Col>
<Col span="6" v-for="(item,key) in resultColumns" :key="key" :style="`margin-top: ${key > 2 ? '10px' : '0'}`">
<input-block top="4px" type="default" :text="item.title" @on-default-right-bottom-click="()=>copy(item.key)">
<autoHeightTextarea :height="key > 2 ? height2 : height1" :value="output[item.key]" :placeholder="item.title" />
</input-block>
<Col span="6" v-for="(item,key) in resultColumns" :key="key" style="margin-top: 10px">
<Card :padding="0">
<p slot="title">{{ item.title }}</p>
<Input v-model="current.output[item.key]" :rows="4" type="textarea"></Input>
</Card>
</Col>
</Row>
</heightResize>
</div>
</template>
<script>
import varCamelCase from "./library/varCamelCase"
import heightResize from "./components/heightResize";
import autoHeightTextarea from "./components/autoHeightTextarea";
export default {
components: {
heightResize,
autoHeightTextarea
},
computed: {
resultColumns() {
return varCamelCase.resultKey.map((item) => {
......@@ -33,32 +33,26 @@ export default {
}
});
},
output() {
let result = varCamelCase.convent(this.current.input)
this.$saveToolData(this.current);
return result;
}
},
created() {
this.$initToolData('input')
this.current = Object.assign(this.current, this.$getToolData("input"))
},
methods: {
copy(type) {
this.$clipboardCopy(this.output[type], true);
},
resize(height) {
this.height1 = Math.ceil(height/2);
this.height2 = height - this.height1 - 10;
handle() {
if (!this.current.input) {
return;
}
this.current.output = varCamelCase.convent(this.current.input)
this.$saveToolData(this.current);
}
},
data() {
return {
current: {
input: ""
},
height1: 100,
height2: 100
input: "",
output: [],
}
}
},
}
</script>
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册