This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-docs.git
The following commit(s) were added to refs/heads/main by this push:
new 37bb6f58 fix 404 (#545)
37bb6f58 is described below
commit 37bb6f586247cad6b72568480f882314bf0b6713
Author: CritasWang <[email protected]>
AuthorDate: Tue Feb 11 17:25:17 2025 +0800
fix 404 (#545)
---
src/.vuepress/client.ts | 2 ++
src/.vuepress/components/Sidevar.vue | 5 ++++-
src/.vuepress/composables/useLegacyRoute.ts | 31 +++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/src/.vuepress/client.ts b/src/.vuepress/client.ts
index d2b0d35f..cfe0e3bf 100644
--- a/src/.vuepress/client.ts
+++ b/src/.vuepress/client.ts
@@ -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';
@@ -27,6 +28,7 @@ export default defineClientConfig({
app.component('DocSearch', DocSearch);
},
setup() {
+ useLegacyRoute();
const pageData = usePageData();
const router = useRouter();
diff --git a/src/.vuepress/components/Sidevar.vue
b/src/.vuepress/components/Sidevar.vue
index 1fbedddf..8d8fc9bb 100644
--- a/src/.vuepress/components/Sidevar.vue
+++ b/src/.vuepress/components/Sidevar.vue
@@ -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;
diff --git a/src/.vuepress/composables/useLegacyRoute.ts
b/src/.vuepress/composables/useLegacyRoute.ts
new file mode 100644
index 00000000..3a703639
--- /dev/null
+++ b/src/.vuepress/composables/useLegacyRoute.ts
@@ -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 };
\ No newline at end of file