mirror of
https://github.com/gkd-kit/docs.git
synced 2024-12-27 17:25:35 +08:00
fix: router
This commit is contained in:
parent
a7d05c6aed
commit
dc0d58dcf6
|
@ -1,17 +1,17 @@
|
||||||
import 'uno.css';
|
import 'uno.css';
|
||||||
import type { Theme } from 'vitepress';
|
import { useRouter, type Theme } from 'vitepress';
|
||||||
import DefaultTheme from 'vitepress/theme';
|
import DefaultTheme from 'vitepress/theme';
|
||||||
|
import {
|
||||||
|
defineComponent,
|
||||||
|
Fragment,
|
||||||
|
h,
|
||||||
|
onMounted,
|
||||||
|
shallowRef,
|
||||||
|
Teleport,
|
||||||
|
} from 'vue';
|
||||||
import components from '../components';
|
import components from '../components';
|
||||||
import BodyScrollbar from '../components/BodyScrollbar.vue';
|
import BodyScrollbar from '../components/BodyScrollbar.vue';
|
||||||
import './custom.css';
|
import './custom.css';
|
||||||
import {
|
|
||||||
Fragment,
|
|
||||||
h,
|
|
||||||
Teleport,
|
|
||||||
defineComponent,
|
|
||||||
shallowRef,
|
|
||||||
onMounted,
|
|
||||||
} from 'vue';
|
|
||||||
|
|
||||||
const ScrollbarWrapper = defineComponent(() => {
|
const ScrollbarWrapper = defineComponent(() => {
|
||||||
const show = shallowRef(false);
|
const show = shallowRef(false);
|
||||||
|
@ -30,17 +30,10 @@ const ScrollbarWrapper = defineComponent(() => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export default {
|
const Redirect = defineComponent(() => {
|
||||||
extends: DefaultTheme,
|
const router = useRouter();
|
||||||
Layout() {
|
onMounted(() => {
|
||||||
return h(Fragment, null, [h(DefaultTheme.Layout), h(ScrollbarWrapper)]);
|
|
||||||
},
|
|
||||||
enhanceApp({ app, router }) {
|
|
||||||
Object.entries(components).forEach(([name, component]) => {
|
|
||||||
app.component(name, component);
|
|
||||||
});
|
|
||||||
// 兼容旧链接/短链重定向
|
// 兼容旧链接/短链重定向
|
||||||
if (!import.meta.env.SSR) {
|
|
||||||
const u = location.href.substring(location.origin.length);
|
const u = location.href.substring(location.origin.length);
|
||||||
if (location.pathname.startsWith('/selector/')) {
|
if (location.pathname.startsWith('/selector/')) {
|
||||||
if (location.pathname.at(-1) === '/') {
|
if (location.pathname.at(-1) === '/') {
|
||||||
|
@ -64,6 +57,22 @@ export default {
|
||||||
} else if (u === '/guide/faq#fail_setting_secure_settings') {
|
} else if (u === '/guide/faq#fail_setting_secure_settings') {
|
||||||
location.hash = 'adb_failed';
|
location.hash = 'adb_failed';
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
return () => {};
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
extends: DefaultTheme,
|
||||||
|
Layout() {
|
||||||
|
return h(Fragment, null, [
|
||||||
|
h(DefaultTheme.Layout),
|
||||||
|
h(ScrollbarWrapper),
|
||||||
|
h(Redirect),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
enhanceApp({ app }) {
|
||||||
|
Object.entries(components).forEach(([name, component]) => {
|
||||||
|
app.component(name, component);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
} satisfies Theme;
|
} satisfies Theme;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user