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

添加变量名转换工具 #44

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