fix: 修改跳转
parent
29bc4c5b23
commit
c86cb997f2
|
@ -35,7 +35,6 @@ import { ref } from 'vue'
|
|||
import { getTrxToken } from 'utils/auth'
|
||||
import { getAppList } from '@/services'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { appendParamsToUrl } from 'utils/url.ts'
|
||||
let iconIndex = 1
|
||||
const getAppIcon = () => {
|
||||
if (iconIndex > 9) iconIndex = 1
|
||||
|
@ -64,10 +63,19 @@ export default {
|
|||
if (!item.appAddress) return ElMessage.error('缺少appAddress, 请联系管理员')
|
||||
const trxToken = getTrxToken()
|
||||
if (!trxToken) return ElMessage.error('缺少trxToken, 请联系管理员')
|
||||
const params = {
|
||||
token: getTrxToken()
|
||||
let url = item.appAddress
|
||||
const searchParams = 'token=' + trxToken
|
||||
if (url.endsWith('?') || url.endsWith('&')) {
|
||||
url += searchParams
|
||||
} else if (url.indexOf('?') > -1) {
|
||||
if (url.endsWith('&')) {
|
||||
url += searchParams
|
||||
} else {
|
||||
url += '&' + searchParams
|
||||
}
|
||||
} else {
|
||||
url += '?' + searchParams
|
||||
}
|
||||
const url = appendParamsToUrl(item.appAddress, '', params)
|
||||
console.log('跳转应用时完整地址: ', url)
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
export function appendParamsToUrl(url = '', pathname = '', params: Record<string, string> = {}) {
|
||||
// 创建一个新的URL对象,在末尾添加 pathname
|
||||
const urlObject = new URL(pathname, url)
|
||||
|
||||
// 获取该URL的查询参数对象
|
||||
const searchParams = new URLSearchParams(urlObject.search)
|
||||
|
||||
// 添加新的参数
|
||||
for (const key in params) {
|
||||
searchParams.append(key, params[key])
|
||||
}
|
||||
// 设置URL的查询参数
|
||||
let result = urlObject.toString()
|
||||
if (result.endsWith('?') || result.endsWith('&')) {
|
||||
result += searchParams.toString()
|
||||
} else if (result.indexOf('?') > -1) {
|
||||
if (result.endsWith('&')) {
|
||||
result += searchParams.toString()
|
||||
} else {
|
||||
result += '&' + searchParams.toString()
|
||||
}
|
||||
} else {
|
||||
result += '?' + searchParams.toString()
|
||||
}
|
||||
// 返回处理后的URL字符串
|
||||
return result
|
||||
}
|
Loading…
Reference in New Issue