mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 17:04:48 +00:00
refactor: optimize side bar component to make it more friendly (#230)
This commit is contained in:
parent
2b88266d67
commit
1877776720
@ -101,7 +101,7 @@ limitations under the License. -->
|
|||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.nav-bar {
|
.nav-bar {
|
||||||
padding: 5px 10px 5px 28px;
|
padding: 5px 10px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
background-color: #fafbfc;
|
background-color: #fafbfc;
|
||||||
|
@ -13,17 +13,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="side-bar" v-if="showMenu">
|
<div class="side-bar" v-if="showMenu" @click="isCollapse = false" @mouseleave="isCollapse = true">
|
||||||
<div :class="isCollapse ? 'logo-icon-collapse' : 'logo-icon'">
|
<div :class="isCollapse ? 'logo-icon-collapse' : 'logo-icon'">
|
||||||
<Icon :size="isCollapse ? 'xl' : 'logo'" :iconName="isCollapse ? 'logo' : 'logo-sw'" />
|
<Icon :size="isCollapse ? 'xl' : 'logo'" :iconName="isCollapse ? 'logo' : 'logo-sw'" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="menu scroll_bar_dark" :style="isCollapse ? {} : { width: '220px' }">
|
||||||
<el-menu
|
<el-menu
|
||||||
active-text-color="#448dfe"
|
active-text-color="#448dfe"
|
||||||
background-color="#252a2f"
|
background-color="#252a2f"
|
||||||
class="el-menu-vertical"
|
class="el-menu-vertical"
|
||||||
:default-active="name"
|
:default-active="name"
|
||||||
text-color="#efefef"
|
text-color="#efefef"
|
||||||
:unique-opened="true"
|
|
||||||
:collapse="isCollapse"
|
:collapse="isCollapse"
|
||||||
:style="{ border: 'none' }"
|
:style="{ border: 'none' }"
|
||||||
>
|
>
|
||||||
@ -31,7 +31,7 @@ limitations under the License. -->
|
|||||||
<el-sub-menu :index="String(menu.name)" v-if="menu.meta.hasGroup">
|
<el-sub-menu :index="String(menu.name)" v-if="menu.meta.hasGroup">
|
||||||
<template #title>
|
<template #title>
|
||||||
<router-link class="items" :to="menu.path">
|
<router-link class="items" :to="menu.path">
|
||||||
<el-icon class="menu-icons" :style="{ marginRight: '12px' }">
|
<el-icon class="menu-icons" :style="{ marginRight: '12px' }" @mouseover="setCollapse">
|
||||||
<Icon size="lg" :iconName="menu.meta.icon" />
|
<Icon size="lg" :iconName="menu.meta.icon" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span class="title" :class="isCollapse ? 'collapse' : ''">
|
<span class="title" :class="isCollapse ? 'collapse' : ''">
|
||||||
@ -48,7 +48,7 @@ limitations under the License. -->
|
|||||||
</el-menu-item-group>
|
</el-menu-item-group>
|
||||||
</el-sub-menu>
|
</el-sub-menu>
|
||||||
<el-menu-item :index="String(menu.name)" @click="changePage(menu)" v-else>
|
<el-menu-item :index="String(menu.name)" @click="changePage(menu)" v-else>
|
||||||
<el-icon class="menu-icons" :style="{ marginRight: '12px' }">
|
<el-icon class="menu-icons" :style="{ marginRight: '12px' }" @mouseover="setCollapse">
|
||||||
<router-link class="items" :to="menu.children[0].path">
|
<router-link class="items" :to="menu.children[0].path">
|
||||||
<Icon size="lg" :iconName="menu.meta.icon" />
|
<Icon size="lg" :iconName="menu.meta.icon" />
|
||||||
</router-link>
|
</router-link>
|
||||||
@ -61,14 +61,6 @@ limitations under the License. -->
|
|||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</template>
|
</template>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
<div
|
|
||||||
class="menu-control"
|
|
||||||
:class="isCollapse ? 'collapse' : ''"
|
|
||||||
:style="{
|
|
||||||
color: theme === 'light' ? '#eee' : '#252a2f',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<Icon size="middle" iconName="format_indent_decrease" @click="controlMenu" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -87,7 +79,7 @@ limitations under the License. -->
|
|||||||
const theme = ["VirtualMachine", "Kubernetes"].includes(name.value || "") ? ref("light") : ref("black");
|
const theme = ["VirtualMachine", "Kubernetes"].includes(name.value || "") ? ref("light") : ref("black");
|
||||||
const routes = ref<RouteRecordRaw[] | any>(useRouter().options.routes);
|
const routes = ref<RouteRecordRaw[] | any>(useRouter().options.routes);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const isCollapse = ref(false);
|
const isCollapse = ref(true);
|
||||||
const showMenu = ref(true);
|
const showMenu = ref(true);
|
||||||
|
|
||||||
if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
|
if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
|
||||||
@ -98,29 +90,37 @@ limitations under the License. -->
|
|||||||
if (route.name === "ViewWidget") {
|
if (route.name === "ViewWidget") {
|
||||||
showMenu.value = false;
|
showMenu.value = false;
|
||||||
}
|
}
|
||||||
const controlMenu = () => {
|
|
||||||
isCollapse.value = !isCollapse.value;
|
|
||||||
};
|
|
||||||
const changePage = (menu: RouteRecordRaw) => {
|
const changePage = (menu: RouteRecordRaw) => {
|
||||||
theme.value = ["VirtualMachine", "Kubernetes"].includes(String(menu.name)) ? "light" : "black";
|
theme.value = ["VirtualMachine", "Kubernetes"].includes(String(menu.name)) ? "light" : "black";
|
||||||
};
|
};
|
||||||
const filterMenus = (menus: any[]) => {
|
const filterMenus = (menus: any[]) => {
|
||||||
return menus.filter((d) => d.meta && !d.meta.notShow);
|
return menus.filter((d) => d.meta && !d.meta.notShow);
|
||||||
};
|
};
|
||||||
|
function setCollapse() {
|
||||||
|
isCollapse.value = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.side-bar {
|
.side-bar {
|
||||||
background: #252a2f;
|
background: #252a2f;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin-bottom: 100px;
|
overflow: hidden;
|
||||||
|
margin-bottom: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
height: calc(100% - 30px);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu:hover {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu-vertical:not(.el-menu--collapse) {
|
.el-menu-vertical:not(.el-menu--collapse) {
|
||||||
width: 220px;
|
width: 220px;
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo-icon-collapse {
|
.logo-icon-collapse {
|
||||||
@ -142,16 +142,6 @@ limitations under the License. -->
|
|||||||
width: 110px;
|
width: 110px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-control {
|
|
||||||
position: absolute;
|
|
||||||
top: 7px;
|
|
||||||
left: 220px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s linear;
|
|
||||||
z-index: 99;
|
|
||||||
color: #252a2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-control.collapse {
|
.menu-control.collapse {
|
||||||
left: 70px;
|
left: 70px;
|
||||||
}
|
}
|
||||||
|
@ -197,3 +197,21 @@
|
|||||||
box-shadow: inset 0 0 6px #ccc;
|
box-shadow: inset 0 0 6px #ccc;
|
||||||
background-color: #aaa;
|
background-color: #aaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scroll_bar_dark::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
background-color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scroll_bar_dark::-webkit-scrollbar-track {
|
||||||
|
background-color: #252a2f;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: inset 0 0 6px #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scroll_bar_dark::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: inset 0 0 6px #888;
|
||||||
|
background-color: #999;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user