fix: 退出和直接打开登录页都停在用户登录页

This commit is contained in:
2026-11-05 10:21:26 +08:00
parent 81b39d9e09
commit cf63388e8e
4 changed files with 8 additions and 10 deletions
+4 -1
View File
@@ -60,7 +60,10 @@ router.beforeEach(async (to) => {
if (!installed && to.path !== "/install") return "/install";
if (installed && to.path === "/install") return "/login";
if (to.path === "/install") return true;
if (hosted && !token()) return enterFromPlatform(to);
if (hosted && !token()) {
if (to.path === "/login") return true;
return enterFromPlatform(to);
}
if (to.path === "/denied") return token() ? "/" : "/login";
if (to.path === "/login") return token() ? "/" : true;
if (!token()) return "/login";
+2 -7
View File
@@ -4,7 +4,7 @@ import type { Component } from "vue";
import { useRoute, useRouter } from "vue-router";
import { NButton, NIcon, NLayout, NLayoutSider, NMenu } from "naive-ui";
import { AppsOutline, CloudDownloadOutline, HomeOutline, KeyOutline, ListOutline, LogOutOutline, PeopleOutline, PersonOutline, SettingsOutline } from "@vicons/ionicons5";
import { platformHome } from "../shared/base";
import { appUrl, platformHome } from "../shared/base";
import { api, clearSession, sessionInfo, token } from "../shared/http";
import { hosted } from "../shared/installState";
import ThemeButton from "./ThemeButton.vue";
@@ -35,7 +35,6 @@ onMounted(() => window.addEventListener("resize", onResize));
onUnmounted(() => window.removeEventListener("resize", onResize));
async function logout() {
const fromPlatform = sessionInfo().kind === "platform";
if (token()) {
try {
await api("/api/auth/logout", { method: "POST" });
@@ -44,11 +43,7 @@ async function logout() {
}
}
clearSession();
if (fromPlatform) {
window.location.assign(platformHome);
return;
}
router.push("/login");
window.location.assign(appUrl("login"));
}
</script>