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