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

添加 jwt 解码功能 #52

上级 e0ac5582
...@@ -24,3 +24,4 @@ yarn-error.log* ...@@ -24,3 +24,4 @@ yarn-error.log*
*.njsproj *.njsproj
*.sln *.sln
*.sw* *.sw*
test.js
...@@ -62,6 +62,7 @@ npm run serve -adapter=utools ...@@ -62,6 +62,7 @@ npm run serve -adapter=utools
|JSON转实体类|`Java`, `C#`, `Go`, `Dart`|√| |JSON转实体类|`Java`, `C#`, `Go`, `Dart`|√|
|ascii编码转换|`十进制`, `十六进制`, `八进制`, `二进制`, `字符串`|√| |ascii编码转换|`十进制`, `十六进制`, `八进制`, `二进制`, `字符串`|√|
|变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√| |变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√|
|jwt解码|`header`, `payload`|√|
## 第三方开源库 ## 第三方开源库
项目诞生离不开这些优秀的开源程序 项目诞生离不开这些优秀的开源程序
...@@ -96,6 +97,7 @@ npm run serve -adapter=utools ...@@ -96,6 +97,7 @@ npm run serve -adapter=utools
- [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) - [camelcaseplugin](https://github.com/netnexus/camelcaseplugin)
- [jwt-decode](https://www.npmjs.com/package/jwt-decode)
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢 > 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
......
{ {
"name": "c-tool", "name": "c-tool",
"version": "1.6.1", "version": "1.6.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -6852,6 +6852,11 @@ ...@@ -6852,6 +6852,11 @@
"resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.3.1.tgz", "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.3.1.tgz",
"integrity": "sha512-zCTP6Qd/WwjrpuHFkJuXc5opRdKprUr7eI7+JCCtcetThJt45qptu82MWQ+eET+FtDrMo7+BYjo3iD0XIq1L9Q==" "integrity": "sha512-zCTP6Qd/WwjrpuHFkJuXc5opRdKprUr7eI7+JCCtcetThJt45qptu82MWQ+eET+FtDrMo7+BYjo3iD0XIq1L9Q=="
}, },
"jwt-decode": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
"integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
},
"killable": { "killable": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
......
...@@ -39,6 +39,7 @@ const tool = [ ...@@ -39,6 +39,7 @@ const tool = [
{'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']}, {'name': 'variableConversion', 'title': '变量名转换', 'cat': ['conversion']},
{'name': 'jwt', 'title': 'jwt解码', 'cat': ['conversion']},
] ]
// 工具类功能配置 // 工具类功能配置
...@@ -52,7 +53,8 @@ const feature = { ...@@ -52,7 +53,8 @@ const feature = {
const utools = { const utools = {
keyword: { keyword: {
hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'], hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'],
encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'] encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'],
jwt: ['jwtDecode']
}, },
cmds: { cmds: {
timestamp: [ timestamp: [
......
...@@ -101,6 +101,10 @@ const routes = [ ...@@ -101,6 +101,10 @@ const routes = [
{ {
path: '/tool/variableConversion', path: '/tool/variableConversion',
component: r => require(['./views/tool/variableConversion.vue'], r) component: r => require(['./views/tool/variableConversion.vue'], r)
},
{
path: '/tool/jwt',
component: r => require(['./views/tool/jwt.vue'], r)
} }
] ]
......
<template>
<div>
<Input v-model="current.input" :rows="7" type="textarea" placeholder="内容"></Input>
<option-block>
<FormItem>
<ButtonGroup>
<Button type="primary" @click="handle('decode')">解码</Button>
</ButtonGroup>
</FormItem>
<FormItem>
<Checkbox v-model="current.header">header</Checkbox>
<Checkbox v-model="current.payload">payload</Checkbox>
</FormItem>
</option-block>
<Input v-model="current.output" :rows="7" type="textarea" placeholder="结果"></Input>
</div>
</template>
<script>
import jwtDecode from "jwt-decode"
export default {
created() {
this.current = Object.assign(this.current, this.$getToolData("input"))
},
methods: {
handle(v) {
if (this.current.input) {
try {
let data = {};
if (this.current.header) {
data.header = jwtDecode(this.current.input, {header: true})
}
if (this.current.payload) {
data.payload = jwtDecode(this.current.input)
}
this.current.output = JSON.stringify(
Object.keys(data).length === 1 ? data[Object.keys(data)[0]] : data,
null,4
);
this.current.operation = v;
this.$clipboardCopy(this.current.output);
this.$saveToolData(this.current);
} catch (e) {
this.$Message.error("解码失败")
console.log(e)
}
}
}
},
data() {
return {
current: {
input: "",
output: "",
header: false,
payload: true,
operation: ""
}
}
},
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册