frpc-desktop/src/layout/compoenets/LeftMenu.vue

70 lines
1.7 KiB
Vue
Raw Normal View History

2023-11-27 15:03:25 +08:00
<script lang="ts" setup>
2024-08-05 22:46:14 +08:00
import {computed, defineComponent, onMounted, ref} from "vue";
import {Icon} from "@iconify/vue";
2023-11-27 15:03:25 +08:00
import router from "@/router";
2024-08-05 22:46:14 +08:00
import {RouteRecordRaw} from "vue-router";
2024-08-11 16:54:01 +08:00
import pkg from '../../../package.json';
2023-11-27 15:03:25 +08:00
defineComponent({
name: "AppMain"
});
const routes = ref<Array<RouteRecordRaw>>([]);
const currentRoute = computed(() => {
return router.currentRoute.value;
});
/**
* 菜单切换
* @param mi 菜单索引
*/
2024-07-17 14:21:31 +08:00
const handleMenuChange = (route: any) => {
2023-11-27 15:03:25 +08:00
if (currentRoute.value.name === route.name) {
return;
}
router.push({
path: route.path
});
};
2024-08-11 16:54:01 +08:00
const handleOpenGitHubReleases = () => {
// ipcRenderer.send("github.openReleases")
router.push({
name: "About"
})
}
2024-08-05 23:22:06 +08:00
2023-11-27 15:03:25 +08:00
onMounted(() => {
routes.value = router.options.routes[0].children?.filter(
2024-08-05 22:46:14 +08:00
f => !f.meta?.hidden
2023-11-27 15:03:25 +08:00
) as Array<RouteRecordRaw>;
});
</script>
<template>
<div class="left-menu-container drop-shadow-xl">
<div class="logo-container">
2024-08-11 16:54:01 +08:00
<img src="/logo/only/128x128.png" class="logo animate__animated animate__lightSpeedInLeft" alt="Logo"/>
2023-11-27 15:03:25 +08:00
</div>
<ul class="menu-container">
2024-08-05 23:13:55 +08:00
<!-- enter-active-class="animate__animated animate__bounceIn"-->
<!-- leave-active-class="animate__animated animate__fadeOut"-->
2023-11-27 15:03:25 +08:00
<li
2024-08-05 23:13:55 +08:00
class="menu animate__animated"
2024-08-05 22:46:14 +08:00
:class="currentRoute?.name === r.name ? 'menu-selected' : ''"
v-for="r in routes"
:key="r.name"
@click="handleMenuChange(r)"
2023-11-27 15:03:25 +08:00
>
2024-08-05 23:13:55 +08:00
<Icon class="animate__animated" :icon="r?.meta?.icon as string"/>
2023-11-27 15:03:25 +08:00
</li>
</ul>
2024-08-05 23:22:06 +08:00
<div class="version mb-2 animate__animated" @click="handleOpenGitHubReleases">
2024-08-11 16:54:01 +08:00
{{ pkg.version }}
2024-08-05 22:46:14 +08:00
</div>
2023-11-27 15:03:25 +08:00
</div>
</template>