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

86 lines
1.8 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">
2021-09-29 15:26:13 +08:00
<div class="app-menu-item" v-for="(item,index) in menus">
<router-link class="app-menu-item-link" :to="item.path">
<i
class="iconfont app-menu-item-icon"
:style="iconStyle(index)"
:class="item.mate.icon"
></i>
<span v-if="isText" class="app-menu-item-text ml-3">{{ item.mate.title }}</span>
2021-07-19 17:36:48 +08:00
</router-link>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
2021-09-29 15:26:13 +08:00
import { useRoute } from "vue-router";
2021-07-19 17:36:48 +08:00
const props = defineProps({
isText: {
type: Boolean,
default: false
},
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-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
})
const iconStyle = (index: any) => {
let style = {
2021-07-19 17:36:48 +08:00
fontSize: props.size,
2021-09-29 15:26:13 +08:00
color: path.value === props.menus[index].path ? props.selectColor : props.color
2021-07-19 17:36:48 +08:00
}
2021-09-29 15:26:13 +08:00
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
}
</style>