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

View File

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