Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/.vuepress/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { defineDocSearchConfig } from '@vuepress/plugin-docsearch/client';
import { computed } from 'vue';
import { defineClientConfig, usePageData, useRouter, withBase } from 'vuepress/client';
import useLegacyRoute from './composables/useLegacyRoute';
import DocSearch from './components/DocSearch.vue';
import { getDocVersion } from './utils/index.js';

Expand All @@ -27,6 +28,7 @@ export default defineClientConfig({
app.component('DocSearch', DocSearch);
},
setup() {
useLegacyRoute();
const pageData = usePageData();
const router = useRouter();

Expand Down
5 changes: 4 additions & 1 deletion src/.vuepress/components/Sidevar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,20 @@ watch(
}
.switch-list {
display: flex;
width: 100px;
text-align: center;
width: 120px;
margin-right: 12px;
border-radius: 14px;
background-color: #f0f1fa;
list-style-type: none;
padding: 4px;
margin: 0;
margin-left: 16px;
margin-top: 1rem;

.switch-type {
padding: 3px 9px;
flex: 1;
cursor: pointer;
border-radius: 14px;
background-color: transparent;
Expand Down
31 changes: 31 additions & 0 deletions src/.vuepress/composables/useLegacyRoute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { onMounted } from 'vue';
import { useRoute, withBase } from 'vuepress/client';
import { getDocVersion } from '../utils/index.js';

const useLegacyRoute = () => {
const route = useRoute();
onMounted(() => {
let lang = 'zh';
const allPath: string[] = route.path?.split('/');
if (allPath && allPath.length > 2) {
if ((allPath[0]==='' && allPath[1] === 'zh')||(allPath[0]==='zh')) {
lang = 'zh';
} else {
lang = '';
}
}
const version = getDocVersion(route.path, '');
// 如果路径中包含 Tree 或 Table,并且当前页面内容为 404,则跳转到对应的 Quick Start 页面
if (version==='latest' || version.includes('-Tree') || version.includes('-Table')) {
if(document.getElementsByClassName('not-found-hint').length>0){
// 替换 URL 中的 Tree 或 Table 之后的内容为 QuickStart/QuickStart.html

window.location.href = `${window.location.origin}${withBase(lang+'/UserGuide/'+version+'/QuickStart/QuickStart.html')}`;
//window.location.href = `${window.location.origin}/docs/zh/UserGuide/V2.0.1/${dialect}/QuickStart/QuickStart.html`;
}
}
});
}

export default useLegacyRoute;
export { useLegacyRoute };