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")); } }