Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lihuizhen
ec-report-refactor
Commits
7b4fb3e7
Commit
7b4fb3e7
authored
May 04, 2023
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix error js reg in ios device
parent
206f8396
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
common.js
utils/common.js
+28
-14
No files found.
utils/common.js
View file @
7b4fb3e7
...
@@ -144,21 +144,35 @@ const install = (Vue, vm) => {
...
@@ -144,21 +144,35 @@ const install = (Vue, vm) => {
paramStr
=
paramStr
.
replace
(
/@yesterday/g
,
yesterday
())
paramStr
=
paramStr
.
replace
(
/@yesterday/g
,
yesterday
())
}
}
// 匹配以@开头,空格 或者 " 结尾的的字符串
// 匹配以@开头,空格 或者 " 结尾的的字符串
const
pattern
=
/
((?<
=@
)
.*
?(?=\s))
|
((?<
=@
)
.*
?(?=
"
))
/g
// const pattern = /((@).*?(\s))|((@).*?("))/g
const
match
=
paramStr
.
match
(
pattern
)
// const match = paramStr.matchAll(pattern)
if
(
match
?.
length
)
{
// if (match?.length) {
match
.
forEach
((
item
)
=>
{
// match.forEach((item) => {
if
(
item
.
includes
(
'diffOfNow'
))
{
// if (item.includes('diffOfNow')) {
// 取出()里面的内容
// // 取出()里面的内容
const
regex
=
/
(?<
=
\()\S
+
(?=\))
/g
// const regex = /(\()\S+(\))/g
const
value
=
item
.
match
(
regex
)
// const value = item.matchAll(regex)
if
(
value
?.
length
)
{
// if (value?.length) {
diffOfNow
(
parseInt
(
value
[
0
]))
// diffOfNow(parseInt(value[0]))
const
str
=
'@'
+
item
// const str = '@' + item
paramStr
=
paramStr
.
replace
(
str
,
diffOfNow
(
parseInt
(
value
[
0
])))
// paramStr = paramStr.replace(str, diffOfNow(parseInt(value[0])))
}
// }
// }
// })
// }
// ios会有零宽断言的兼容性问题,废弃掉正则判断,使用强制解析判断
const
reg
=
'@diffOfNow('
if
(
paramStr
.
includes
(
reg
))
{
const
match
=
paramStr
.
split
(
reg
)
if
(
match
.
length
>=
2
)
{
const
str
=
match
[
1
]
const
nums
=
str
.
split
(
')'
)
if
(
nums
.
length
)
{
const
res
=
reg
+
nums
[
0
]
+
')'
paramStr
=
paramStr
.
replace
(
res
,
diffOfNow
(
parseInt
(
nums
[
0
])))
}
}
}
)
}
}
}
return
JSON
.
parse
(
paramStr
)
return
JSON
.
parse
(
paramStr
)
}
}
...
...
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