v3.5.0 固定顶部导航栏&窗口大小改变实时更新栏数

pull/2/head
YunaiV 2022-02-15 20:40:59 +08:00
parent cff4391f2d
commit 63b7ee096a
2 changed files with 15 additions and 11 deletions

View File

@ -47,7 +47,7 @@ export default {
topMenus() { topMenus() {
let topMenus = []; let topMenus = [];
this.routers.map((menu) => { this.routers.map((menu) => {
if (menu.hidden === false) { if (menu.hidden !== true) {
topMenus.push(menu); topMenus.push(menu);
} }
}); });
@ -95,21 +95,20 @@ export default {
return activePath; return activePath;
}, },
}, },
beforeMount() {
window.addEventListener('resize', this.setVisibleNumber)
},
beforeDestroy() {
window.removeEventListener('resize', this.setVisibleNumber)
},
mounted() { mounted() {
this.setVisibleNumber(); this.setVisibleNumber();
}, },
methods: { methods: {
// //
setVisibleNumber() { setVisibleNumber() {
const width = document.body.getBoundingClientRect().width - 380; const width = document.body.getBoundingClientRect().width / 3;
const elWidth = this.$el.getBoundingClientRect().width; this.visibleNumber = parseInt(width / 85);
const menuItemNodes = this.$el.children;
const menuWidth = Array.from(menuItemNodes).map(
(i) => i.getBoundingClientRect().width
);
this.visibleNumber = (
parseInt(width - elWidth) / parseInt(menuWidth)
).toFixed(0);
}, },
// //
handleSelect(key, keyPath) { handleSelect(key, keyPath) {

View File

@ -3,7 +3,7 @@
<hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/> <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
<top-nav id="topmenu-container" class="breadcrumb-container" v-if="topNav"/> <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>
<div class="right-menu"> <div class="right-menu">
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
@ -135,6 +135,11 @@ export default {
float: left; float: left;
} }
.topmenu-container {
position: absolute;
left: 50px;
}
.errLog-container { .errLog-container {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;