fix routeer push on nav menu click

This commit is contained in:
pa
2025-11-05 23:12:46 +09:00
committed by Natsumi
parent ca862a1273
commit 6ad7052485
2 changed files with 15 additions and 8 deletions

View File

@@ -19,14 +19,14 @@
></el-button>
</div>
<el-menu collapse router default-active="feed" :collapse-transition="false" ref="navMenuRef">
<el-menu collapse default-active="feed" :collapse-transition="false" ref="navMenuRef">
<el-popover
v-for="item in navItems"
:disabled="!item.entries?.length"
:key="item.index"
placement="right-start"
trigger="hover"
:hide-after="isSteamVRRunning ? 800 : 150"
:hide-after="isSteamVRRunning ? 600 : 150"
:show-arrow="false"
:offset="0"
:width="navPopoverWidth"
@@ -50,7 +50,7 @@
<span class="nav-menu-popover__menu-label"
>{{ t(entry.label)
}}<span
v-if="route.path === entry.path"
v-if="notifiedMenus.includes(entry.path.split('/').pop())"
class="nav-menu-popover__menu-label-dot"></span
></span>
</button>
@@ -64,7 +64,8 @@
notify:
notifiedMenus.includes(item.index) ||
(notifiedMenus.includes('friend-log') && item.index === 'social')
}">
}"
@click="handleRouteChange(item.index)">
<i :class="item.icon"></i>
<template #title v-if="item.tooltip">
<span>{{ t(item.tooltip) }}</span>
@@ -198,7 +199,7 @@
</template>
<script setup>
import { computed, onMounted, ref, watch } from 'vue';
import { computed, h, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
@@ -371,6 +372,11 @@
themeMenuVisible.value = false;
};
const handleRouteChange = (index) => {
router.push({ name: index });
navMenuRef.value?.updateActiveIndex(index);
};
watch(settingsMenuVisible, (visible) => {
if (visible) {
supportMenuVisible.value = false;

View File

@@ -18,7 +18,7 @@ const routes = [
{ path: '/feed', name: 'feed', component: Feed },
{
path: '/friend-location',
name: 'friendLocation',
name: 'friend-location',
component: FriendLocation
},
{ path: '/game-log', name: 'game-log', component: GameLog },
@@ -53,9 +53,10 @@ export function initRouter(app) {
router.beforeEach((to, from) => {
if (to.path == '/') {
return { name: 'feed' };
router.push({ name: 'feed' });
return false;
}
if (to.path === '/social' || to.path === '/social/social') {
if (to.path === '/social') {
return false;
}
return true;