first
This commit is contained in:
33
admin-web/src/utils/navigation.ts
Normal file
33
admin-web/src/utils/navigation.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Router } from "vue-router";
|
||||
|
||||
let appRouter: Router | null = null;
|
||||
|
||||
export function setAppRouter(router: Router) {
|
||||
appRouter = router;
|
||||
}
|
||||
|
||||
export function goToAdminLogin() {
|
||||
if (appRouter) {
|
||||
if (appRouter.currentRoute.value.name !== "login") {
|
||||
appRouter.replace({ name: "login" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.location.hash !== "#/login") {
|
||||
window.history.replaceState({}, "", "/#/login");
|
||||
window.dispatchEvent(new PopStateEvent("popstate"));
|
||||
}
|
||||
}
|
||||
|
||||
export function goToAdminHome() {
|
||||
if (appRouter) {
|
||||
appRouter.replace({ name: "dashboard" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.location.hash !== "#/dashboard") {
|
||||
window.history.replaceState({}, "", "/#/dashboard");
|
||||
window.dispatchEvent(new PopStateEvent("popstate"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user