Skip to content

Commit ee4f54f

Browse files
committed
1 parent a7e644e commit ee4f54f

File tree

1 file changed

+29
-53
lines changed

1 file changed

+29
-53
lines changed

src/views/tool/regex.vue

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
<div>
33
<Row :gutter="16" style="margin-bottom: 10px" class="page-option-block">
44
<Col span="12">
5-
<input-block :text="$t('regex_reference')" @on-default-right-bottom-click="reference">
6-
<Input v-model="current.input">
7-
<Select slot="prepend" @on-change="commonSelect" :placeholder="$t('regex_expression')"
8-
style="width:100px">
9-
<Option style="text-align: left" v-for="(v,k) in regex" :value="v.regex" :key="k">{{v.name}}
10-
</Option>
11-
</Select>
12-
</Input>
5+
<input-block>
6+
<Input type="textarea" :rows="3" v-model="current.input" :placeholder="$t('regex_expression')" />
7+
<template slot="extra">
8+
<referenceZh @on-select="(regex)=>current.input=regex" v-if="locale === 'zh_CN'" />
9+
<referenceEn @on-select="(regex)=>current.input=regex" v-else />
10+
</template>
1311
</input-block>
1412
</Col>
1513
<Col span="12">
1614
<input-block>
17-
<Input v-model="current.replace" :disabled="current.isDelete">
18-
<span slot="prepend">{{ $t('regex_replace_content') }}</span>
19-
</Input>
15+
<Input v-model="current.replace" type="textarea" :rows="3" :placeholder="$t('regex_replace_content')" :disabled="current.isDelete === 1" />
2016
<template slot="extra">
21-
<Checkbox v-model="current.isDelete">{{ $t('regex_delete') }}</Checkbox>
17+
<RadioGroup v-model="current.isDelete">
18+
<Radio :label="0">
19+
{{ $t('regex_replace') }}
20+
</Radio>
21+
<Radio :label="1">
22+
{{ $t('regex_delete') }}
23+
</Radio>
24+
</RadioGroup>
2225
</template>
2326
</input-block>
2427
</Col>
@@ -27,36 +30,41 @@
2730
<Row :gutter="16">
2831
<Col span="12">
2932
<input-block>
30-
<autoHeightTextarea :height="height" v-model="current.content"
31-
:placeholder="$t('regex_input')"/>
33+
<autoHeightTextarea :height="height" v-model="current.content" :placeholder="$t('regex_input')"/>
3234
<template slot="extra">
3335
<Checkbox v-model="current.isGlobal">{{ $t('regex_global') }}</Checkbox>
3436
<Checkbox v-model="current.isIgnoreCase">{{ $t('regex_ignore_case') }}</Checkbox>
3537
</template>
3638
</input-block>
3739
</Col>
3840
<Col span="12">
39-
<autoHeightTextarea :height="height" :value="output"
40-
:placeholder="$t('regex_output')"/>
41+
<autoHeightTextarea :height="height" :value="output" :placeholder="$t('regex_output')"/>
4142
</Col>
4243
</Row>
4344
</heightResize>
4445
</div>
4546
</template>
4647
<script>
47-
import {openUrl} from "../../helper";
4848
import autoHeightTextarea from "./components/autoHeightTextarea";
4949
import heightResize from "./components/heightResize";
50+
import referenceEn from "./components/regex/referenceEn";
51+
import referenceZh from "./components/regex/referenceZh";
52+
import {getCurrentLocale} from "../../i18n";
5053
5154
export default {
5255
components: {
5356
autoHeightTextarea,
54-
heightResize
57+
heightResize,
58+
referenceEn,
59+
referenceZh
5560
},
5661
created() {
57-
this.$initToolData('input')
62+
this.$initToolData()
5863
},
5964
computed: {
65+
locale() {
66+
return getCurrentLocale()
67+
},
6068
replaceContent(){
6169
if (!this.current.isDelete && !this.current.replace){
6270
return false
@@ -98,12 +106,6 @@ export default {
98106
methods: {
99107
resize(height) {
100108
this.height = height;
101-
},
102-
reference() {
103-
openUrl(this.$t('regex_reference_url').toString())
104-
},
105-
commonSelect(v) {
106-
this.current.input = v;
107109
}
108110
},
109111
data() {
@@ -115,35 +117,9 @@ export default {
115117
replace: "",
116118
isGlobal: true,
117119
isIgnoreCase: true,
118-
isDelete: false
120+
isDelete: 0,
119121
},
120-
height: 100,
121-
regex: [
122-
{regex: "[\\u4e00-\\u9fa5]", name: this.$t('regex_type_zh')},
123-
{regex: "[^\\x00-\\xff]", name: this.$t('regex_type_complex')},
124-
{regex: "\\n\\s*\\r", name: this.$t('regex_type_blank')},
125-
{
126-
regex: "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?",
127-
name: this.$t('regex_type_email')
128-
},
129-
{regex: "[a-zA-z]+://[^\\s]*", name: this.$t('regex_type_url')},
130-
{regex: "[1][3,4,5,7,8][0-9]{9}", name: this.$t('regex_type_cn_mobile')},
131-
{regex: "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", name: this.$t('regex_type_ip')},
132-
{regex: "\\d{3}-\\d{8}|\\d{4}-\\d{7,8}", name: this.$t('regex_type_cn_tel')},
133-
{regex: "[1-9][0-9]{4,}", name: this.$t('regex_type_tencent_qq')},
134-
{regex: "[1-9]\\d{5}(?!\\d)", name: this.$t('regex_type_cn_postcode')},
135-
{
136-
regex: "([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8])))",
137-
name: this.$t('regex_type_date')
138-
},
139-
{regex: "[1-9]\\d*", name: this.$t('regex_type_positive_integer')},
140-
{regex: "-[1-9]\\d*", name: this.$t('regex_type_negative_integer')},
141-
{regex: "-?[1-9]\\d*", name: this.$t('regex_type_integer')},
142-
{regex: "[1-9]\\d*|0", name: this.$t('regex_type_non_negative_integer')},
143-
{regex: "-[1-9]\\d*|0", name: this.$t('regex_type_non_positive_integer')},
144-
{regex: "[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*", name: this.$t('regex_type_positive_float')},
145-
{regex: "-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*", name: this.$t('regex_type_negative_float')}
146-
]
122+
height: 100
147123
}
148124
},
149125
}

0 commit comments

Comments
 (0)