Skip to content

Commit ca0c06d

Browse files
committed
fix: router
1 parent 79bf73f commit ca0c06d

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

docs/.vitepress/theme/index.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,6 @@ import {
1313
onMounted,
1414
} from 'vue';
1515

16-
// 兼容旧链接/短链重定向
17-
if (!import.meta.env.SSR) {
18-
const u = location.href.substring(location.origin.length);
19-
if (location.pathname.startsWith('/selector/')) {
20-
if (location.pathname.at(-1) === '/') {
21-
location.pathname = '/guide/selector';
22-
} else {
23-
location.pathname = location.pathname.replace('/selector/', '/guide/');
24-
}
25-
} else if (location.pathname === '/subscription/') {
26-
location.pathname = '/guide/subscription';
27-
} else if (location.pathname === '/') {
28-
const r = new URLSearchParams(location.search).get('r');
29-
if (r === '1') {
30-
location.href = '/guide/snapshot#how-to-upload';
31-
} else if (r === '2') {
32-
location.href = '/guide/faq#restriction';
33-
} else if (r === '3') {
34-
location.href = '/guide/faq#adb_failed';
35-
} else if (r === '4') {
36-
location.href = 'https://shizuku.rikka.app';
37-
}
38-
} else if (u === '/guide/faq#fail_setting_secure_settings') {
39-
location.hash = 'adb_failed';
40-
}
41-
}
42-
4316
const ScrollbarWrapper = defineComponent(() => {
4417
const show = shallowRef(false);
4518
onMounted(() => {
@@ -62,9 +35,35 @@ export default {
6235
Layout() {
6336
return h(Fragment, null, [h(DefaultTheme.Layout), h(ScrollbarWrapper)]);
6437
},
65-
enhanceApp({ app }) {
38+
enhanceApp({ app, router }) {
6639
Object.entries(components).forEach(([name, component]) => {
6740
app.component(name, component);
6841
});
42+
// 兼容旧链接/短链重定向
43+
if (!import.meta.env.SSR) {
44+
const u = location.href.substring(location.origin.length);
45+
if (location.pathname.startsWith('/selector/')) {
46+
if (location.pathname.at(-1) === '/') {
47+
router.go('/guide/selector');
48+
} else {
49+
router.go(location.pathname.replace('/selector/', '/guide/'));
50+
}
51+
} else if (location.pathname === '/subscription/') {
52+
router.go('/guide/subscription');
53+
} else if (location.pathname === '/') {
54+
const r = new URLSearchParams(location.search).get('r');
55+
if (r === '1') {
56+
router.go('/guide/snapshot#how-to-upload');
57+
} else if (r === '2') {
58+
router.go('/guide/faq#restriction');
59+
} else if (r === '3') {
60+
router.go('/guide/faq#adb_failed');
61+
} else if (r === '4') {
62+
location.href = 'https://shizuku.rikka.app';
63+
}
64+
} else if (u === '/guide/faq#fail_setting_secure_settings') {
65+
location.hash = 'adb_failed';
66+
}
67+
}
6968
},
7069
} satisfies Theme;

0 commit comments

Comments
 (0)