fix: router

This commit is contained in:
二刺螈 2024-12-04 18:26:06 +08:00
parent 79bf73f544
commit ca0c06d115

View File

@ -13,33 +13,6 @@ import {
onMounted, onMounted,
} from 'vue'; } from 'vue';
// 兼容旧链接/短链重定向
if (!import.meta.env.SSR) {
const u = location.href.substring(location.origin.length);
if (location.pathname.startsWith('/selector/')) {
if (location.pathname.at(-1) === '/') {
location.pathname = '/guide/selector';
} else {
location.pathname = location.pathname.replace('/selector/', '/guide/');
}
} else if (location.pathname === '/subscription/') {
location.pathname = '/guide/subscription';
} else if (location.pathname === '/') {
const r = new URLSearchParams(location.search).get('r');
if (r === '1') {
location.href = '/guide/snapshot#how-to-upload';
} else if (r === '2') {
location.href = '/guide/faq#restriction';
} else if (r === '3') {
location.href = '/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';
}
}
const ScrollbarWrapper = defineComponent(() => { const ScrollbarWrapper = defineComponent(() => {
const show = shallowRef(false); const show = shallowRef(false);
onMounted(() => { onMounted(() => {
@ -62,9 +35,35 @@ export default {
Layout() { Layout() {
return h(Fragment, null, [h(DefaultTheme.Layout), h(ScrollbarWrapper)]); return h(Fragment, null, [h(DefaultTheme.Layout), h(ScrollbarWrapper)]);
}, },
enhanceApp({ app }) { enhanceApp({ app, router }) {
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;