Skip to content

Commit dafa2c4

Browse files
authored
Merge pull request #11 from MC-XiaoHei/master
Fix: update `docsPath` in `refresh`
2 parents 27abdd6 + 5fd7b88 commit dafa2c4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ let oldVersionList: string[] = [];
1919
const versions = ref<string[]>([]);
2020
const docsPath = ref("");
2121
22-
onMounted(() => {
23-
if (isLatest.value) {
24-
docsPath.value = window.location.pathname;
25-
} else {
26-
docsPath.value = window.location.pathname.split(`/${ currentVersion.value }/`)[1];
27-
}
28-
});
29-
3022
function refresh() {
3123
let version = latestVersion.value;
3224
let refreshPage = false;
@@ -49,6 +41,12 @@ function refresh() {
4941
versions.value = versionList;
5042
isOld.value = oldVersionList.includes(version);
5143
44+
if (isLatest.value) {
45+
docsPath.value = window.location.pathname;
46+
} else {
47+
docsPath.value = window.location.pathname.split(`/${ currentVersion.value }/`)[1];
48+
}
49+
5250
if (refreshPage) {
5351
window.location.pathname = isLatest.value ? "/" : `/${ version }/`;
5452
window.location.reload();

0 commit comments

Comments
 (0)