commit
This commit is contained in:
@@ -324,48 +324,12 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
this.menus = res.data
|
||||
window.sessionStorage.setItem("zhgh_sub_app_menus", JSON.stringify(res.data))
|
||||
this.echoMenus()
|
||||
// this.matchUrlToMenu()
|
||||
} else {
|
||||
this.menus = []
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 按 URL 精准激活
|
||||
matchUrlToMenu() {
|
||||
// 跳转带过来的地址
|
||||
const pathname = window.location.pathname
|
||||
const find = (list, parentIds = []) => {
|
||||
for (const m of list) {
|
||||
if (m.href && pathname.includes(m.href.split('?')[0])) {
|
||||
return {menu: m, parentIds}
|
||||
}
|
||||
if (m.children?.length) {
|
||||
const hit = find(m.children, [...parentIds, m.id])
|
||||
if (hit) return hit
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const hit = find(this.menus)
|
||||
if (hit) {
|
||||
// 激活跳转菜单
|
||||
this.activeMenuIndex = hit.menu.id
|
||||
this.openedMenus = hit.parentIds
|
||||
const app = JSON.parse(window.sessionStorage.getItem("zhgh_sub_app"))
|
||||
$("#sub-app-container #sidebar-menu .menu-header .menu-title").text(app?.name)
|
||||
this.$nextTick(() => {
|
||||
this.menuSelect(hit.menu.id, hit.parentIds)
|
||||
// 保证内容区对应
|
||||
commonUtil.pjaxPush(hit.menu.href)
|
||||
})
|
||||
} else if (!this.activeMenuIndex) {
|
||||
// 没命中且缓存也没有 → 再降级到第一个
|
||||
this.defaultSelect()
|
||||
}
|
||||
},
|
||||
|
||||
// 设置应用信息
|
||||
setAppInfo(app) {
|
||||
if (app) {
|
||||
@@ -389,7 +353,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
if (!this.activeMenuIndex && '/platform/v4/subApp' === window.location.pathname) {
|
||||
this.defaultSelect()
|
||||
} else {
|
||||
|
||||
this.hrefSelect()
|
||||
}
|
||||
|
||||
@@ -419,14 +382,14 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
|
||||
const result = findMenuPath(this.menus, window.location.pathname)
|
||||
|
||||
this.activeMenuIndex = result[result.length-1]
|
||||
this.openedMenus = result.map(v=>v.id)
|
||||
if(result){
|
||||
this.activeMenuIndex = result[result.length-1]['id']
|
||||
this.openedMenus = result.map(v=>v.id)
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.menuSelect(this.activeMenuIndex, this.openedMenus)
|
||||
// 使用pjax跳转
|
||||
commonUtil.pjaxPush(self.href)
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
this.menuSelect(this.activeMenuIndex, this.openedMenus)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user