Skip to content

Commit c9b3ce5

Browse files
committed
feat: add online tools
1 parent 678be5a commit c9b3ce5

File tree

4 files changed

+179
-3
lines changed

4 files changed

+179
-3
lines changed

admin/src/components/common/navBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<el-col :xs="6" :sm="6" :md="4" :lg="4" :xl="4">
1313
<div class="grid-content">
1414
<el-menu-item index="1">
15-
<router-link :to="{name: 'md'}">Markdown</router-link>
15+
<router-link :to="{name: 'tool'}">在线工具</router-link>
1616
</el-menu-item>
1717
</div>
1818
</el-col>

admin/src/permission.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import getPageTitle from '@/utils/get-page-title'
99
NProgress.configure({ showSpinner: false }) // NProgress Configuration
1010

1111
// 不重定向白名单
12-
const whiteList = ['/login', '/index', '/bus', '/line', '/home', '/404', '/', '', '/echarts', '/md', '/out', '/excel', '/upload']
12+
const whiteList = ['/login', '/index', '/bus', '/tool', '/line', '/home', '/404', '/', '', '/echarts', '/md', '/out', '/excel', '/upload']
1313
router.beforeEach(async(to, from, next) => {
1414
// start progress bar
1515
NProgress.start()

admin/src/router/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ export const asyncRoutes = [...routeAdmin, ...routeSuper, ...routeTest]
212212

213213
// 基础路由
214214
const routeBase = [
215-
{ path: '/', name: 'bus', component: () => import('@/views/home/index'), hidden: true },
215+
{ path: '/', name: 'index', component: () => import('@/views/home/index'), hidden: true },
216216
{ path: '/bus', name: 'bus', component: () => import('@/views/home/index'), hidden: true },
217+
{ path: '/tool', name: 'tool', component: () => import('@/views/home/tool'), hidden: true },
217218
{ path: '/line', name: 'line', component: () => import('@/views/home/line'), hidden: true },
218219
{ path: '/home', component: () => import('@/views/home/home'), hidden: true },
219220
{ path: '/md', name: 'md', component: () => import('@/views/markdown/index'), hidden: true },

admin/src/views/home/tool.vue

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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>&nbsp;</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>&nbsp;在线工具输出</span><br><br>&nbsp;
23+
<el-button type="primary" @click="copyInput">复制输入</el-button>
24+
<br><br>&nbsp;
25+
<el-button type="primary" @click="copyOutput">复制输出</el-button>
26+
<br><br>&nbsp;
27+
<el-button type="warning" @click="resetForm('form')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</el-col>
35+
<el-col :span="14">&nbsp;</el-col>
36+
<el-col :span="0">&nbsp;</el-col>
37+
</el-form-item>
38+
</el-form>
39+
<el-row>
40+
<el-col :span="4">&nbsp;</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

Comments
 (0)