mirror of
https://github.com/gkd-kit/docs.git
synced 2024-12-27 02:25:36 +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,40 +30,49 @@ const ScrollbarWrapper = defineComponent(() => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Redirect = defineComponent(() => {
|
||||||
|
const router = useRouter();
|
||||||
|
onMounted(() => {
|
||||||
|
// 兼容旧链接/短链重定向
|
||||||
|
const u = location.href.substring(location.origin.length);
|
||||||
|
if (location.pathname.startsWith('/selector/')) {
|
||||||
|
if (location.pathname.at(-1) === '/') {
|
||||||
|
router.go('/guide/selector');
|
||||||
|
} else {
|
||||||
|
router.go(location.pathname.replace('/selector/', '/guide/'));
|
||||||
|
}
|
||||||
|
} else if (location.pathname === '/subscription/') {
|
||||||
|
router.go('/guide/subscription');
|
||||||
|
} else if (location.pathname === '/') {
|
||||||
|
const r = new URLSearchParams(location.search).get('r');
|
||||||
|
if (r === '1') {
|
||||||
|
router.go('/guide/snapshot#how-to-upload');
|
||||||
|
} else if (r === '2') {
|
||||||
|
router.go('/guide/faq#restriction');
|
||||||
|
} else if (r === '3') {
|
||||||
|
router.go('/guide/faq#adb_failed');
|
||||||
|
} else if (r === '4') {
|
||||||
|
location.href = 'https://shizuku.rikka.app';
|
||||||
|
}
|
||||||
|
} else if (u === '/guide/faq#fail_setting_secure_settings') {
|
||||||
|
location.hash = 'adb_failed';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () => {};
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: DefaultTheme,
|
extends: DefaultTheme,
|
||||||
Layout() {
|
Layout() {
|
||||||
return h(Fragment, null, [h(DefaultTheme.Layout), h(ScrollbarWrapper)]);
|
return h(Fragment, null, [
|
||||||
|
h(DefaultTheme.Layout),
|
||||||
|
h(ScrollbarWrapper),
|
||||||
|
h(Redirect),
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
enhanceApp({ app, router }) {
|
enhanceApp({ app }) {
|
||||||
Object.entries(components).forEach(([name, component]) => {
|
Object.entries(components).forEach(([name, component]) => {
|
||||||
app.component(name, component);
|
app.component(name, component);
|
||||||
});
|
});
|
||||||
// 兼容旧链接/短链重定向
|
|
||||||
if (!import.meta.env.SSR) {
|
|
||||||
const u = location.href.substring(location.origin.length);
|
|
||||||
if (location.pathname.startsWith('/selector/')) {
|
|
||||||
if (location.pathname.at(-1) === '/') {
|
|
||||||
router.go('/guide/selector');
|
|
||||||
} else {
|
|
||||||
router.go(location.pathname.replace('/selector/', '/guide/'));
|
|
||||||
}
|
|
||||||
} else if (location.pathname === '/subscription/') {
|
|
||||||
router.go('/guide/subscription');
|
|
||||||
} else if (location.pathname === '/') {
|
|
||||||
const r = new URLSearchParams(location.search).get('r');
|
|
||||||
if (r === '1') {
|
|
||||||
router.go('/guide/snapshot#how-to-upload');
|
|
||||||
} else if (r === '2') {
|
|
||||||
router.go('/guide/faq#restriction');
|
|
||||||
} else if (r === '3') {
|
|
||||||
router.go('/guide/faq#adb_failed');
|
|
||||||
} else if (r === '4') {
|
|
||||||
location.href = 'https://shizuku.rikka.app';
|
|
||||||
}
|
|
||||||
} else if (u === '/guide/faq#fail_setting_secure_settings') {
|
|
||||||
location.hash = 'adb_failed';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
} satisfies Theme;
|
} satisfies Theme;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user