提交 44394c7e 编写于 作者: B baiy 提交者: ninecents

#101

上级 f3a5a77b
...@@ -2,23 +2,26 @@ ...@@ -2,23 +2,26 @@
<div> <div>
<Row :gutter="16" style="margin-bottom: 10px" class="page-option-block"> <Row :gutter="16" style="margin-bottom: 10px" class="page-option-block">
<Col span="12"> <Col span="12">
<input-block :text="$t('regex_reference')" @on-default-right-bottom-click="reference"> <input-block>
<Input v-model="current.input"> <Input type="textarea" :rows="3" v-model="current.input" :placeholder="$t('regex_expression')" />
<Select slot="prepend" @on-change="commonSelect" :placeholder="$t('regex_expression')" <template slot="extra">
style="width:100px"> <referenceZh @on-select="(regex)=>current.input=regex" v-if="locale === 'zh_CN'" />
<Option style="text-align: left" v-for="(v,k) in regex" :value="v.regex" :key="k">{{v.name}} <referenceEn @on-select="(regex)=>current.input=regex" v-else />
</Option> </template>
</Select>
</Input>
</input-block> </input-block>
</Col> </Col>
<Col span="12"> <Col span="12">
<input-block> <input-block>
<Input v-model="current.replace" :disabled="current.isDelete"> <Input v-model="current.replace" type="textarea" :rows="3" :placeholder="$t('regex_replace_content')" :disabled="current.isDelete === 1" />
<span slot="prepend">{{ $t('regex_replace_content') }}</span>
</Input>
<template slot="extra"> <template slot="extra">
<Checkbox v-model="current.isDelete">{{ $t('regex_delete') }}</Checkbox> <RadioGroup v-model="current.isDelete">
<Radio :label="0">
{{ $t('regex_replace') }}
</Radio>
<Radio :label="1">
{{ $t('regex_delete') }}
</Radio>
</RadioGroup>
</template> </template>
</input-block> </input-block>
</Col> </Col>
...@@ -27,8 +30,7 @@ ...@@ -27,8 +30,7 @@
<Row :gutter="16"> <Row :gutter="16">
<Col span="12"> <Col span="12">
<input-block> <input-block>
<autoHeightTextarea :height="height" v-model="current.content" <autoHeightTextarea :height="height" v-model="current.content" :placeholder="$t('regex_input')"/>
:placeholder="$t('regex_input')"/>
<template slot="extra"> <template slot="extra">
<Checkbox v-model="current.isGlobal">{{ $t('regex_global') }}</Checkbox> <Checkbox v-model="current.isGlobal">{{ $t('regex_global') }}</Checkbox>
<Checkbox v-model="current.isIgnoreCase">{{ $t('regex_ignore_case') }}</Checkbox> <Checkbox v-model="current.isIgnoreCase">{{ $t('regex_ignore_case') }}</Checkbox>
...@@ -36,27 +38,33 @@ ...@@ -36,27 +38,33 @@
</input-block> </input-block>
</Col> </Col>
<Col span="12"> <Col span="12">
<autoHeightTextarea :height="height" :value="output" <autoHeightTextarea :height="height" :value="output" :placeholder="$t('regex_output')"/>
:placeholder="$t('regex_output')"/>
</Col> </Col>
</Row> </Row>
</heightResize> </heightResize>
</div> </div>
</template> </template>
<script> <script>
import {openUrl} from "../../helper";
import autoHeightTextarea from "./components/autoHeightTextarea"; import autoHeightTextarea from "./components/autoHeightTextarea";
import heightResize from "./components/heightResize"; import heightResize from "./components/heightResize";
import referenceEn from "./components/regex/referenceEn";
import referenceZh from "./components/regex/referenceZh";
import {getCurrentLocale} from "../../i18n";
export default { export default {
components: { components: {
autoHeightTextarea, autoHeightTextarea,
heightResize heightResize,
referenceEn,
referenceZh
}, },
created() { created() {
this.$initToolData('input') this.$initToolData()
}, },
computed: { computed: {
locale() {
return getCurrentLocale()
},
replaceContent(){ replaceContent(){
if (!this.current.isDelete && !this.current.replace){ if (!this.current.isDelete && !this.current.replace){
return false return false
...@@ -98,12 +106,6 @@ export default { ...@@ -98,12 +106,6 @@ export default {
methods: { methods: {
resize(height) { resize(height) {
this.height = height; this.height = height;
},
reference() {
openUrl(this.$t('regex_reference_url').toString())
},
commonSelect(v) {
this.current.input = v;
} }
}, },
data() { data() {
...@@ -115,35 +117,9 @@ export default { ...@@ -115,35 +117,9 @@ export default {
replace: "", replace: "",
isGlobal: true, isGlobal: true,
isIgnoreCase: true, isIgnoreCase: true,
isDelete: false isDelete: 0,
}, },
height: 100, height: 100
regex: [
{regex: "[\\u4e00-\\u9fa5]", name: this.$t('regex_type_zh')},
{regex: "[^\\x00-\\xff]", name: this.$t('regex_type_complex')},
{regex: "\\n\\s*\\r", name: this.$t('regex_type_blank')},
{
regex: "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?",
name: this.$t('regex_type_email')
},
{regex: "[a-zA-z]+://[^\\s]*", name: this.$t('regex_type_url')},
{regex: "[1][3,4,5,7,8][0-9]{9}", name: this.$t('regex_type_cn_mobile')},
{regex: "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}", name: this.$t('regex_type_ip')},
{regex: "\\d{3}-\\d{8}|\\d{4}-\\d{7,8}", name: this.$t('regex_type_cn_tel')},
{regex: "[1-9][0-9]{4,}", name: this.$t('regex_type_tencent_qq')},
{regex: "[1-9]\\d{5}(?!\\d)", name: this.$t('regex_type_cn_postcode')},
{
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])))",
name: this.$t('regex_type_date')
},
{regex: "[1-9]\\d*", name: this.$t('regex_type_positive_integer')},
{regex: "-[1-9]\\d*", name: this.$t('regex_type_negative_integer')},
{regex: "-?[1-9]\\d*", name: this.$t('regex_type_integer')},
{regex: "[1-9]\\d*|0", name: this.$t('regex_type_non_negative_integer')},
{regex: "-[1-9]\\d*|0", name: this.$t('regex_type_non_positive_integer')},
{regex: "[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*", name: this.$t('regex_type_positive_float')},
{regex: "-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*", name: this.$t('regex_type_negative_float')}
]
} }
}, },
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册