Commit 7b4fb3e7 authored by leon's avatar leon

fix: fix error js reg in ios device

parent 206f8396
......@@ -144,21 +144,35 @@ const install = (Vue, vm) => {
paramStr = paramStr.replace(/@yesterday/g, yesterday())
}
// 匹配以@开头,空格 或者 " 结尾的的字符串
const pattern = /((?<=@).*?(?=\s))|((?<=@).*?(?="))/g
const match = paramStr.match(pattern)
if (match?.length) {
match.forEach((item) => {
if (item.includes('diffOfNow')) {
// 取出()里面的内容
const regex = /(?<=\()\S+(?=\))/g
const value = item.match(regex)
if (value?.length) {
diffOfNow(parseInt(value[0]))
const str = '@' + item
paramStr = paramStr.replace(str, diffOfNow(parseInt(value[0])))
}
// const pattern = /((@).*?(\s))|((@).*?("))/g
// const match = paramStr.matchAll(pattern)
// if (match?.length) {
// match.forEach((item) => {
// if (item.includes('diffOfNow')) {
// // 取出()里面的内容
// const regex = /(\()\S+(\))/g
// const value = item.matchAll(regex)
// if (value?.length) {
// diffOfNow(parseInt(value[0]))
// const str = '@' + item
// 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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment