perf: 修改切换组织时的 url 替换

This commit is contained in:
ibuler
2023-06-14 16:10:42 +08:00
parent b65a007d37
commit 17d73f2b3c
3 changed files with 14 additions and 10 deletions

View File

@@ -36,13 +36,12 @@ export default [
children: [
{
path: '',
component: () => import('@/views/assets/Cloud/'),
name: 'AccountList',
hidden: true,
redirect: '/console/assets/cloud',
meta: {
title: i18n.t('xpack.Cloud.AccountList'),
permissions: ['xpack.view_account'],
hidden: true
permissions: ['xpack.view_account']
}
},
{

View File

@@ -395,4 +395,9 @@ export const copy = _.throttle(function(value) {
document.body.removeChild(inputDom)
}, 1400)
export function getQueryFromPath(path) {
const url = new URL(path, location.origin)
return Object.fromEntries(url.searchParams)
}
export { BASE_URL }

View File

@@ -27,19 +27,19 @@ async function changeOrg(org, reload = true, vm = null) {
if (index !== -1) {
path = path.slice(0, index)
}
const idRegex = /\/(-?\d+(\.\d+)?|[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12})\//
const i = path.search(idRegex)
if (i !== -1) {
path = path.slice(0, i + 1)
}
const idRegex = /\/?(-?\d+(\.\d+)?|([a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}))\/?/
path = path.replace(idRegex, '')
if (vm) {
const result = vm.$router.resolve({ path })
console.log('path: ', path)
if (result.resolved.name === '404') {
path = '/'
}
console.log('route', result)
}
location.hash = '#' + path
setTimeout(() => location.reload(), 400)
// location.hash = '#' + path
// setTimeout(() => location.reload(), 400)
}
function hasCurrentOrgPermission() {