Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
959d9b39
authored
Dec 13, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
u
parent
70752c4d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
utils/index.ts
utils/index.ts
View file @
959d9b39
/* eslint-disable */
/* eslint-disable */
export
function
throttle
(
time
:
number
=
100
)
{
export
function
throttle
(
time
:
number
=
100
)
{
let
pending
=
false
let
pending
=
false
return
function
(
target
:
any
,
name
:
string
):
any
{
return
function
(
target
:
any
,
name
:
string
):
any
{
const
originFunc
=
target
[
name
]
const
originFunc
=
target
[
name
]
const
newFunc
=
function
(
this
:
Vue
,
...
params
:
any
[])
{
const
newFunc
=
function
(
this
:
Vue
,
...
params
:
any
[])
{
if
(
pending
)
{
if
(
pending
)
{
return
return
}
}
...
@@ -22,7 +22,7 @@ export function throttle(time: number = 100) {
...
@@ -22,7 +22,7 @@ export function throttle(time: number = 100) {
}
}
export
function
unique
<
T
>
(
arr
:
T
[],
existed
:
(
item
:
T
,
all
:
T
[])
=>
number
)
{
export
function
unique
<
T
>
(
arr
:
T
[],
existed
:
(
item
:
T
,
all
:
T
[])
=>
number
)
{
return
arr
.
filter
(
function
(
item
,
index
,
arr
)
{
return
arr
.
filter
(
function
(
item
,
index
,
arr
)
{
return
index
===
existed
(
item
,
arr
)
return
index
===
existed
(
item
,
arr
)
})
})
}
}
...
@@ -62,10 +62,20 @@ const URL_REGEX =
...
@@ -62,10 +62,20 @@ const URL_REGEX =
const
LINE_URL_REGEX
=
const
LINE_URL_REGEX
=
/
((?:(?:
https
?
|ftp|file
)
:
\/\/
|www
\.
|ftp
\.)(?:\([
-A-Z0-9+&@#
\/
%=~_|$?!:,.
]
*
\)
|
[
-A-Z0-9+&@#
\/
%=~_|$?!:,.
])
*
(?:\([
-A-Z0-9+&@#
\/
%=~_|$?!:,.
]
*
\)
|
[
A-Z0-9+&@#
\/
%=~_|$
]))
/i
/
((?:(?:
https
?
|ftp|file
)
:
\/\/
|www
\.
|ftp
\.)(?:\([
-A-Z0-9+&@#
\/
%=~_|$?!:,.
]
*
\)
|
[
-A-Z0-9+&@#
\/
%=~_|$?!:,.
])
*
(?:\([
-A-Z0-9+&@#
\/
%=~_|$?!:,.
]
*
\)
|
[
A-Z0-9+&@#
\/
%=~_|$
]))
/i
const
mobile_reg
=
/
(
1
[
0-9_
]{8,14})
/ig
export
function
replaceText2Link
(
text
:
string
)
{
export
function
replaceText2Link
(
text
:
string
)
{
return
text
.
replace
(
URL_REGEX
,
'<a href="$1" target="_blank">$1</a>'
)
return
text
.
replace
(
URL_REGEX
,
'<a href="$1" target="_blank">$1</a>'
)
}
}
export
function
replaceText2Dom
(
text
:
string
,
className
:
string
)
{
return
text
.
replace
(
URL_REGEX
,
`<span class="
${
className
}
">$1</span>`
)
}
export
function
replacePhone2Dom
(
text
:
string
,
className
:
string
)
{
return
text
.
replace
(
mobile_reg
,
`<a href="tel:$1" class="
${
className
}
">$1</a>`
)
}
export
function
isUrl
(
text
:
string
)
{
export
function
isUrl
(
text
:
string
)
{
return
LINE_URL_REGEX
.
test
(
text
)
return
LINE_URL_REGEX
.
test
(
text
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment