Commit f24f1fc3 authored by leon's avatar leon

Merge branch 'develop' into feature-retail

parents a9cb3377 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)
} }
......
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