chore: fixed navigation & route links issues

This commit is contained in:
2024-12-04 14:30:56 +01:00
parent a3a0fb358c
commit 75b04ad247
2 changed files with 25 additions and 12 deletions
+24 -11
View File
@@ -1,9 +1,9 @@
<template>
<section class="stock-section">
<div class="section_modes">
<router-link v-for="(route, i) in testRoutes" :key="route" class="link-btn" :to="`/${route}`">
<span class="text--accent">{{ i + 1 }}.</span> {{ $t(`topbar.${route}`) }}
<span v-if="route == 'stock-list'">({{ store.stockList.length }})</span>
<router-link v-for="(route, i) in routes" :key="route.name" class="link-btn" :to="route.href">
<span class="text--accent">{{ i + 1 }}.</span> {{ $t(`topbar.${route.name}`) }}
<span class="text--grayed" v-if="route.name == 'stock'">({{ store.stockList.length }})</span>
</router-link>
</div>
@@ -18,12 +18,30 @@
<script lang="ts" setup>
import { onMounted } from 'vue';
import { useStore } from '../../store';
import { useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
const store = useStore();
const route = useRoute();
const router = useRouter();
const testRoutes = ['stock', 'wiki', 'numgen', 'stockgen'];
const routes = [
{
name: 'stock',
href: '/',
},
{
name: 'wiki',
href: '/wiki',
},
{
name: 'numgen',
href: '/numgen',
},
{
name: 'stockgen',
href: '/stockgen',
},
];
onMounted(() => {
window.addEventListener('keydown', (e) => {
@@ -32,8 +50,7 @@ onMounted(() => {
if (/^[1234]$/.test(e.key)) {
const keyNum = Number(e.key);
// store.stockSectionMode = sectionModes[keyNum - 1];
// (sectionButtonRefs.value[keyNum - 1] as HTMLButtonElement)?.focus();
router.push(routes[keyNum - 1].href);
}
});
});
@@ -74,10 +91,6 @@ onMounted(() => {
margin-bottom: 1em;
}
a.router-link-active {
color: gold;
}
@media screen and (max-width: 650px) {
.section_modes {
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));