refactor(client): Refine routing (#8846)

This commit is contained in:
syuilo 2022-06-20 17:38:49 +09:00 committed by GitHub
parent 30a39a296d
commit 699f24f3dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
149 changed files with 6312 additions and 6670 deletions

View file

@ -3,12 +3,9 @@ import { post } from '@/os';
import { $i, login } from '@/account';
import { defaultStore } from '@/store';
import { getAccountFromId } from '@/scripts/get-account-from-id';
import { router } from '@/router';
import { mainRouter } from '@/router';
export function swInject() {
const navHook = inject('navHook', null);
const sideViewHook = inject('sideViewHook', null);
navigator.serviceWorker.addEventListener('message', ev => {
if (_DEV_) {
console.log('sw msg', ev.data);
@ -27,16 +24,10 @@ export function swInject() {
case 'post':
return post(ev.data.options);
case 'push':
if (router.currentRoute.value.path === ev.data.url) {
if (mainRouter.currentRoute.value.path === ev.data.url) {
return window.scroll({ top: 0, behavior: 'smooth' });
}
if (navHook) {
return navHook(ev.data.url);
}
if (sideViewHook && defaultStore.state.defaultSideView && ev.data.url !== '/') {
return sideViewHook(ev.data.url);
}
return router.push(ev.data.url);
return mainRouter.push(ev.data.url);
default:
return;
}