refactor(client): Refine routing (#8846)
This commit is contained in:
parent
30a39a296d
commit
699f24f3dc
149 changed files with 6312 additions and 6670 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue