Files
AlgerMusicPlayer/src/layout/components/AppMenu.vue
T

107 lines
2.1 KiB
Vue
Raw Normal View History

2021-07-19 17:36:48 +08:00
<template>
<div>
<!-- menu -->
<div class="app-menu">
<div class="app-menu-header">
<div class="app-menu-logo">
2023-12-27 14:39:52 +08:00
<img src="/icon.png" class="w-9 h-9" alt="logo" />
2021-07-19 17:36:48 +08:00
</div>
</div>
<div class="app-menu-list">
<div v-for="(item, index) in menus" :key="item.path" class="app-menu-item">
2021-09-29 15:26:13 +08:00
<router-link class="app-menu-item-link" :to="item.path">
<i class="iconfont app-menu-item-icon" :style="iconStyle(index)" :class="item.meta.icon"></i>
2024-01-02 22:19:39 +08:00
<span v-if="isText" class="app-menu-item-text ml-3">{{ item.meta.title }}</span>
2021-07-19 17:36:48 +08:00
</router-link>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { useRoute } from 'vue-router';
2021-07-19 17:36:48 +08:00
const props = defineProps({
isText: {
type: Boolean,
default: false,
2021-07-19 17:36:48 +08:00
},
size: {
type: String,
default: '26px',
2021-07-19 17:36:48 +08:00
},
color: {
type: String,
default: '#aaa',
2021-07-19 17:36:48 +08:00
},
2021-09-29 15:26:13 +08:00
selectColor: {
type: String,
default: '#10B981',
2021-09-29 15:26:13 +08:00
},
2021-07-19 17:36:48 +08:00
menus: {
2021-09-29 15:26:13 +08:00
type: Array as any,
default: () => [],
},
});
2021-07-19 17:36:48 +08:00
2021-09-29 15:26:13 +08:00
const route = useRoute();
const path = ref(route.path);
watch(
() => route.path,
async (newParams) => {
path.value = newParams;
},
);
2021-09-29 15:26:13 +08:00
2024-05-21 11:01:23 +08:00
const iconStyle = (index: number) => {
const style = {
2021-07-19 17:36:48 +08:00
fontSize: props.size,
color: path.value === props.menus[index].path ? props.selectColor : props.color,
};
return style;
};
2021-07-19 17:36:48 +08:00
</script>
<style lang="scss" scoped>
.app-menu {
2023-12-27 14:39:52 +08:00
@apply flex-col items-center justify-center px-6;
2021-07-19 17:36:48 +08:00
max-width: 100px;
}
.app-menu-item-link,
.app-menu-header {
@apply flex items-center justify-center;
}
.app-menu-item-link {
@apply mb-6 mt-6;
}
.app-menu-item-icon:hover {
2021-09-29 15:26:13 +08:00
color: #10b981 !important;
transform: scale(1.05);
transition: 0.2s ease-in-out;
2021-07-19 17:36:48 +08:00
}
2024-05-23 17:12:35 +08:00
.mobile {
.app-menu {
max-width: 100%;
width: 100vw;
position: relative;
z-index: 999999;
background-color: #000;
&-header {
display: none;
}
&-list {
@apply flex justify-between;
}
&-item {
&-link {
@apply my-4;
}
}
}
}
</style>