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">
|
2024-05-16 18:54:30 +08:00
|
|
|
<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">
|
2024-05-16 18:54:30 +08:00
|
|
|
<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>
|
2024-05-16 18:54:30 +08:00
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
|
|
2021-07-19 17:36:48 +08:00
|
|
|
const props = defineProps({
|
|
|
|
|
isText: {
|
|
|
|
|
type: Boolean,
|
2024-05-16 18:54:30 +08:00
|
|
|
default: false,
|
2021-07-19 17:36:48 +08:00
|
|
|
},
|
|
|
|
|
size: {
|
|
|
|
|
type: String,
|
2024-05-16 18:54:30 +08:00
|
|
|
default: '26px',
|
2021-07-19 17:36:48 +08:00
|
|
|
},
|
|
|
|
|
color: {
|
|
|
|
|
type: String,
|
2024-05-16 18:54:30 +08:00
|
|
|
default: '#aaa',
|
2021-07-19 17:36:48 +08:00
|
|
|
},
|
2021-09-29 15:26:13 +08:00
|
|
|
selectColor: {
|
|
|
|
|
type: String,
|
2024-05-16 18:54:30 +08:00
|
|
|
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,
|
2024-05-16 18:54:30 +08:00
|
|
|
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);
|
2024-05-16 18:54:30 +08:00
|
|
|
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) => {
|
2024-05-16 18:54:30 +08:00
|
|
|
const style = {
|
2021-07-19 17:36:48 +08:00
|
|
|
fontSize: props.size,
|
2024-05-16 18:54:30 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-20 15:29:20 +08:00
|
|
|
.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;
|
2021-07-20 15:29:20 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-16 18:54:30 +08:00
|
|
|
</style>
|