Skip to content

Commit 7b292c9

Browse files
committed
fix: fix version switch
1 parent 1e71640 commit 7b292c9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,33 @@ const route = useRoute();
1515
1616
let versionList: string[] = [];
1717
const versions = ref<string[]>([]);
18+
const isLatest = ref(true);
1819
1920
function refresh() {
2021
let version = latestVersion.value;
2122
let refreshPage = false;
2223
2324
for (const v of versionList) {
2425
if (window.location.pathname.startsWith(`/${v}/`)) {
25-
if(currentVersion.value !== '' && v !== currentVersion.value) {
26+
if (currentVersion.value !== '' && v !== currentVersion.value) {
2627
refreshPage = true;
2728
}
2829
version = v;
30+
isLatest.value = false;
2931
break;
3032
}
3133
}
3234
3335
currentVersion.value = version;
3436
versions.value = versionList;
3537
36-
if(refreshPage) {
38+
if (refreshPage) {
3739
window.location.reload();
3840
}
3941
}
4042
4143
async function init() {
42-
const versionDataFileUrl = `${window.location.origin}/versions.yml`;
44+
const versionDataFileUrl = `${window.location.origin}/9.4.2/versions.yml`;
4345
const versionDataFileContent = await (await fetch(versionDataFileUrl)).text();
4446
const versionData = parse(versionDataFileContent);
4547
versionList = versionData.versions;
@@ -64,14 +66,14 @@ watch(
6466
<VPFlyout v-if="!screenMenu" class="VPVersionSwitcher" icon="vpi-versioning" :button="currentVersion"
6567
:label="'Switch Version'">
6668
<div class="items">
67-
<VPMenuLink v-if="currentVersion != latestVersion" :item="{
69+
<VPMenuLink v-if="!isLatest" :item="{
6870
text: latestVersion,
69-
link: `/`,
71+
link: `/../`,
7072
}"/>
7173
<template v-for="version in versions" :key="version">
7274
<VPMenuLink v-if="currentVersion != version" :item="{
7375
text: version,
74-
link: `/${version}/`,
76+
link: `${isLatest? '' : '/..'}/${version}/`,
7577
}"/>
7678
</template>
7779
</div>
@@ -85,12 +87,12 @@ watch(
8587
<div id="navbar-group-version" class="items">
8688
<VPMenuLink :item="{
8789
text: latestVersion,
88-
link: `/`,
90+
link: `${isLatest? '' : '/..'}/`,
8991
}"/>
9092
<template v-for="version in versions" :key="version">
9193
<VPMenuLink :item="{
9294
text: version,
93-
link: `/${version}/`,
95+
link: `${isLatest? '' : '/..'}/${version}/`,
9496
}"/>
9597
</template>
9698
</div>

0 commit comments

Comments
 (0)