Files
halo/ui/console-src/router/guards/auth-check.ts
Ryan Wang ac88ee70cb Rename @halo-dev/console-shared to @halo-dev/ui-shared (#7926)
#### What type of PR is this?

/area ui
/kind api-change
/milestone 2.22.x

#### What this PR does / why we need it:

See #7925 

#### Which issue(s) this PR fixes:

Fixes #7925 

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
将 `@halo-dev/console-shared` 重命名为 `@halo-dev/ui-shared`
```
2025-11-10 16:20:41 +00:00

18 lines
428 B
TypeScript

import { stores } from "@halo-dev/ui-shared";
import type { Router } from "vue-router";
export function setupAuthCheckGuard(router: Router) {
router.beforeEach((_to, _, next) => {
const currentUserStore = stores.currentUser();
if (currentUserStore.isAnonymous) {
window.location.href = `/login?redirect_uri=${encodeURIComponent(
window.location.href
)}`;
return;
}
next();
});
}