Files
anxinyan/admin-web/src/utils/navigation.ts
wushumin 9aac78b8da first
2026-05-11 15:28:27 +08:00

34 lines
776 B
TypeScript

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