This commit is contained in:
xiaogang 2024-11-07 15:16:00 +08:00
parent 878b533e0b
commit a58725fbae
2 changed files with 43 additions and 0 deletions

42
demo.js Normal file
View File

@ -0,0 +1,42 @@
const url = 'https://gateway.dev.cdlsxd.cn/h5/?param=activity-swtest#/'
function getUrlPathName() {
// const url = window.location.href
let code = 'activity'
if (url.indexOf('#/') !== -1) {
let strR = ''
const str =
url.indexOf('#/') !== -1 ? url.split('#/')[1] : url.split('/')[url.split('/').length - 1]
if (str.indexOf('/') === -1) {
strR = str || ''
} else {
strR = str.split('/')[0]
}
if (strR.indexOf('-') === -1) {
code = 'activity'
} else {
code = strR.split('-')[0]
strR = strR.split('-')[1]
}
return { codeS: code, activity_code: strR }
} else if (url.indexOf('?') !== -1) {
let strR = ''
strR = url.split('=')[1]
code = strR.split('-')[0]
return { codeS: code, activity_code: strR.split('-')[1] }
} else {
const str = url.split('/')
const strP = str[str.length - 1]
let strR = ''
if (strP.indexOf('-') === -1) {
strR = strP
code = 'activity'
} else {
code = strP.split('-')[0]
strR = strP.split('-')[1]
}
return { codeS: code, activity_code: strR }
}
}
console.log(getUrlPathName(url))

View File

@ -49,6 +49,7 @@ const srcList = reactive<SrcListType>({
title: '',
})
const { MODE } = useEnv()
console.log('----mode', MODE)
const urlPath: any = MODE === 'production' ? getUrlPathNameProd() : getUrlPathName()
console.log('.....urlPath', urlPath)
activityCode.value = urlPath.activity_code