Skip to content

Commit 27abdd6

Browse files
committed
Fix window reference being accessed in computed(), replaced with onMounted instead
1 parent 2446899 commit 27abdd6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/.vitepress/theme/404/NotFoundComponent.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup lang="ts">
22
import { useData } from "vitepress";
3-
import { computed } from "vue";
3+
import { computed, ref, onMounted } from "vue";
44
import { changingVersion, currentVersion, isLatest, isOld } from "../versioning/version";
55
import getRandomNotFoundMsg from "./notFoundMsg";
66
77
const {theme} = useData();
8-
const redirectFromAnotherVersion = computed(() =>
9-
window.location.search.startsWith("?from=") && !changingVersion.value,
8+
const redirectFromAnotherVersion = ref(false);
9+
onMounted(() =>
10+
redirectFromAnotherVersion.value = window.location.search.startsWith("?from=") && !changingVersion.value,
1011
);
1112
const redirectFromVersion = computed(() => {
1213
if (redirectFromAnotherVersion.value) {

docs/.vitepress/theme/versioning/VersionSwitcher.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ const route = useRoute();
1717
let versionList: string[] = [];
1818
let oldVersionList: string[] = [];
1919
const versions = ref<string[]>([]);
20-
const docsPath = computed(() => {
20+
const docsPath = ref("");
21+
22+
onMounted(() => {
2123
if (isLatest.value) {
22-
return window.location.pathname;
24+
docsPath.value = window.location.pathname;
2325
} else {
24-
return window.location.pathname.split(`/${ currentVersion.value }/`)[1];
26+
docsPath.value = window.location.pathname.split(`/${ currentVersion.value }/`)[1];
2527
}
2628
});
2729

0 commit comments

Comments
 (0)