Skip to content

Commit

Permalink
fixed directly referencing the router instead of utilising useRouter()
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Nov 15, 2023
1 parent 133ad97 commit 2225de9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion webclient/src/components/AppSearchBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { extractFacets } from "@/modules/autocomplete";
import router from "@/router";
import { useRouter } from "vue-router";
import { useGlobalStore } from "@/stores/global";
import { useI18n } from "vue-i18n";
import { useFetch } from "@/composables/fetch";
Expand All @@ -21,6 +21,7 @@ const autocomplete = reactive({ sections: [] as SectionFacet[], highlighted: nul
// visible results.
const queryCounter = ref(0);
const latestUsedQueryId = ref(-1);
const router = useRouter();
function searchFocus(): void {
global.focusSearchBar();
Expand Down
2 changes: 1 addition & 1 deletion webclient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createApp } from "vue";
import { createPinia } from "pinia";

import App from "@/App.vue";
import router from "@/router";
import { router } from "@/router";
import { createI18n } from "vue-i18n";

const i18n = createI18n<Record<string, never>, "de" | "en", false>({
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/pages/view/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { useClipboard } from "@vueuse/core";
import { selectedMap, useDetailsStore } from "@/stores/details";
import { computed, nextTick, onMounted, ref, watchEffect } from "vue";
import { useFetch } from "@/composables/fetch";
import { useRoute } from "vue-router";
import router from "@/router";
import { useRoute, useRouter } from "vue-router";
import type { components } from "@/api_types";
type DetailsResponse = components["schemas"]["DetailsResponse"];
const { t } = useI18n({ useScope: "local" });
const route = useRoute();
const router = useRouter();
function loadData(data: DetailsResponse) {
if (route.fullPath !== data.redirect_url) router.replace({ path: data.redirect_url });
Expand Down
6 changes: 2 additions & 4 deletions webclient/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MainView from "@/pages/index.vue";
import NotFoundView from "@/pages/[...slug].vue";
import SearchView from "@/pages/search.vue";

const routes = [
export const routes = [
{
component: MainView,
name: "main",
Expand Down Expand Up @@ -36,7 +36,7 @@ const routes = [
},
];

const router = createRouter({
export const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: routes,
scrollBehavior(to, from, savedPosition) {
Expand Down Expand Up @@ -73,5 +73,3 @@ const router = createRouter({
router.afterEach(
() => document.querySelector('meta[property="og:url"]')?.setAttribute("content", window.location.href),
);

export default router;

0 comments on commit 2225de9

Please sign in to comment.