Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 934fd0a

Browse files
committed
chore: synchronization master branch code
1 parent 2f299fa commit 934fd0a

File tree

15 files changed

+347
-46
lines changed

15 files changed

+347
-46
lines changed

‎admin/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint": "eslint --ext .js,.vue src",
1313
"build": "vue-cli-service build && npm run move && npm run git",
1414
"move": "rm -rf ../laravel/public/static && cp -r dist/* ../laravel/public",
15-
"git": "git add ../laravel/public/static/* && git add ../laravel/public/index.html && git commit -m \"chore(view): 构建前端\"",
15+
"git": "git add ../laravel/public/static/* && git add ../laravel/public/index.html && git commit -m \"chore(view): Build front end\"",
1616
"test:unit": "jest --clearCache && vue-cli-service test:unit",
1717
"test:ci": "npm run lint && npm run test:unit",
1818
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",

‎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>

‎laravel/app/Helper/functions.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,29 @@ function isName($name)
8383
return preg_match('/^[\x{2E80}-\x{FE4F}]{2,16}$/u', $name);
8484
}
8585
}
86+
87+
/**
88+
* 下划线转驼峰
89+
* @param $str
90+
* @return string|string[]|null
91+
*/
92+
function convertUnderline($str)
93+
{
94+
$str = preg_replace_callback('/([-_]+([a-z]{1}))/i', function($matches) {
95+
return strtoupper($matches[2]);
96+
}, $str);
97+
return $str;
98+
}
99+
100+
/**
101+
* 驼峰转下划线
102+
* @param $str
103+
* @return string|string[]|null
104+
*/
105+
function humpToLine($str)
106+
{
107+
$str = preg_replace_callback('/([A-Z]{1})/', function($matches) {
108+
return '_'.strtolower($matches[0]);
109+
}, $str);
110+
return $str;
111+
}

‎laravel/app/Http/Controllers/Bus/ToolController.php‎

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,31 @@
99
namespace App\Http\Controllers\Bus;
1010

1111

12+
use App\Http\Repository\ToolRepository;
1213
use Illuminate\Http\Request;
1314

1415
class ToolController extends CommonController
1516
{
16-
/**
17-
* 字符串转十六进制函数
18-
*
19-
* @param Request $request
20-
*
21-
* @return string
22-
*/
23-
public function stringToHex(Request $request)
17+
public function tool(Request $request)
2418
{
25-
$str = $request->input('input');
26-
$hex = "";
27-
for ($i = 0; $i < strlen($str); $i++) {
28-
$hex .= dechex(ord($str[$i]));
29-
}
30-
$hex = strtoupper($hex);
19+
$func = $request->input('operation');
20+
$input = $request->input('input');
21+
// 下划线转驼峰
22+
$convert = convertUnderline($func);
3123

32-
return $this->out(200, ['output' => $hex]);
33-
}
24+
$toolRepository = ToolRepository::getInstent();
25+
if ($convert && $input) {
26+
if (is_callable([$toolRepository, $convert])) {
27+
$out = $toolRepository->$convert($input);
28+
if (!$out) {
29+
return $this->out(4009);
30+
}
3431

35-
/**
36-
* 十六进制转字符串函数
37-
*
38-
* @param $request
39-
*
40-
* @return string
41-
*/
42-
public function hexToString(Request $request)
43-
{
44-
$hex = strtoupper($request->input('input'));
45-
$hex = str_replace('\\X', '', $hex);
46-
if (!preg_match("/^[A-Fa-f0-9]+$/", $hex)) {
47-
return $this->out(1006);
32+
return $this->out(200, ['output' => $out]);
33+
}
4834
}
49-
$str = "";
50-
for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
51-
$str .= chr(hexdec($hex[$i].$hex[$i + 1]));
52-
}
53-
if (preg_match('~[\x{4e00}-\x{9fa5}]+~u', $str, $tmp)) {
54-
return $this->out(200, ['output' => (string)$str]);
55-
}
56-
return $this->out(4009);
35+
36+
return $this->out(1006);
5737
}
5838

5939
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /