2
2
<div >
3
3
<Row :gutter =" 16" style =" margin-bottom : 10px " class =" page-option-block" >
4
4
<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 >
13
11
</input-block >
14
12
</Col >
15
13
<Col span =" 12" >
16
14
<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" />
20
16
<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 >
22
25
</template >
23
26
</input-block >
24
27
</Col >
27
30
<Row :gutter =" 16" >
28
31
<Col span =" 12" >
29
32
<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')" />
32
34
<template slot="extra">
33
35
<Checkbox v-model =" current.isGlobal" >{{ $t('regex_global') }}</Checkbox >
34
36
<Checkbox v-model =" current.isIgnoreCase" >{{ $t('regex_ignore_case') }}</Checkbox >
35
37
</template >
36
38
</input-block >
37
39
</Col >
38
40
<Col span =" 12" >
39
- <autoHeightTextarea :height =" height" :value =" output"
40
- :placeholder =" $t('regex_output')" />
41
+ <autoHeightTextarea :height =" height" :value =" output" :placeholder =" $t('regex_output')" />
41
42
</Col >
42
43
</Row >
43
44
</heightResize >
44
45
</div >
45
46
</template >
46
47
<script >
47
- import {openUrl } from " ../../helper" ;
48
48
import autoHeightTextarea from " ./components/autoHeightTextarea" ;
49
49
import heightResize from " ./components/heightResize" ;
50
+ import referenceEn from " ./components/regex/referenceEn" ;
51
+ import referenceZh from " ./components/regex/referenceZh" ;
52
+ import {getCurrentLocale } from " ../../i18n" ;
50
53
51
54
export default {
52
55
components: {
53
56
autoHeightTextarea,
54
- heightResize
57
+ heightResize,
58
+ referenceEn,
59
+ referenceZh
55
60
},
56
61
created () {
57
- this .$initToolData (' input ' )
62
+ this .$initToolData ()
58
63
},
59
64
computed: {
65
+ locale () {
66
+ return getCurrentLocale ()
67
+ },
60
68
replaceContent (){
61
69
if (! this .current .isDelete && ! this .current .replace ){
62
70
return false
@@ -98,12 +106,6 @@ export default {
98
106
methods: {
99
107
resize (height ) {
100
108
this .height = height;
101
- },
102
- reference () {
103
- openUrl (this .$t (' regex_reference_url' ).toString ())
104
- },
105
- commonSelect (v ) {
106
- this .current .input = v;
107
109
}
108
110
},
109
111
data () {
@@ -115,35 +117,9 @@ export default {
115
117
replace: " " ,
116
118
isGlobal: true ,
117
119
isIgnoreCase: true ,
118
- isDelete: false
120
+ isDelete: 0 ,
119
121
},
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
147
123
}
148
124
},
149
125
}
0 commit comments