You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaweb/components/menu.vue

75 lines
1.5 KiB
Vue

6 months ago
<!--
* menu.vue
* Copyright (C) 2024 veypi <i@veypi.com>
* 2024-06-06 16:18
* Distributed under terms of the MIT license.
-->
<template>
<div class="select-none items flex flex-col">
<template v-for="(v, i) in menus">
<div class="item flex items-center justify-start px-3 gap-1 py-4" :active='is_equal(v.path, route.fullPath)'
6 months ago
@click="$router.push(v.path)">
<slot :name="'L' + i" @click='$router.push(v.path)'>
<div class='ico' v-if="show_ico">
<OneIcon :name='v.ico' />
6 months ago
</div>
<div class="text-nowrap" v-if="show_name">
{{ v.name }}
</div>
</slot>
</div>
</template>
</div>
</template>
<script lang="ts" setup>
import { OneIcon } from '@veypi/one-icon'
let menu_handler = useMenuStore()
let menus = computed(() => menu_handler.menus)
6 months ago
let route = useRoute()
const is_equal = (p1: string, p2: string) => {
if (!p1.endsWith('/')) {
p1 = p1 + '/'
}
if (!p2.endsWith('/')) {
p2 = p2 + '/'
}
return p1 === p2
6 months ago
}
withDefaults(defineProps<{
vertical?: boolean,
show_ico?: boolean,
show_name?: boolean,
}>(),
{
vertical: true,
show_ico: true,
show_name: true
}
)
</script>
<style scoped lang="scss">
.items {
.item {
6 months ago
opacity: 0.8;
cursor: pointer;
color: var(--base-txt);
6 months ago
}
.item[active=true] {
opacity: 1;
color: var(--color-warning);
6 months ago
cursor: default;
6 months ago
}
.item:hover {
6 months ago
background: var(--base-bg-1);
6 months ago
}
}
</style>