fix: 无权使用页和管理员登录入口先退出平台当前账号,不再被直接送回

This commit is contained in:
2026-11-03 14:42:41 +08:00
parent 98a3ad5ef2
commit ccc63b1c7e
4 changed files with 10 additions and 8 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { NButton } from "naive-ui";
import { platformHome } from "../../shared/base";
import { basePath, platformHome } from "../../shared/base";
import { goPlatformLogin } from "../../shared/platform";
import ThemeButton from "../../shell/ThemeButton.vue";
</script>
@@ -16,7 +16,7 @@ import ThemeButton from "../../shell/ThemeButton.vue";
<h2 id="denied-title" class="gate-title">无权使用</h2>
<p class="gate-text">当前平台账号没有使用 DecomEval 的权限。请联系平台管理员开通,或换一个有权限的账号登录。</p>
<div class="gate-actions">
<n-button @click="goPlatformLogin()">重新登录</n-button>
<n-button @click="goPlatformLogin(basePath, true)">重新登录</n-button>
<n-button type="primary" tag="a" :href="platformHome">返回平台</n-button>
</div>
</section>
+2 -2
View File
@@ -2,7 +2,7 @@
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { NButton, NInput, NModal, NSpin } from "naive-ui";
import { platformLoginUrl } from "../../shared/base";
import { basePath, platformLoginUrl } from "../../shared/base";
import { api, saveSession } from "../../shared/http";
import { hosted } from "../../shared/installState";
import { useToast } from "../../shared/toast";
@@ -15,7 +15,7 @@ const emit = defineEmits<{ done: [] }>();
const route = useRoute();
const router = useRouter();
const toast = useToast();
const adminLoginUrl = platformLoginUrl();
const adminLoginUrl = platformLoginUrl(basePath, true);
const mode = ref("local");
const username = ref("");
const password = ref("");
+4 -2
View File
@@ -12,6 +12,8 @@ export function appUrl(path: string) {
export const platformHome = "/";
export function platformLoginUrl(target = basePath) {
return `/login?redirect=${encodeURIComponent(target)}`;
/** switchAccount 让平台先退出当前账号再显示登录表单,否则已登录的平台账号会被直接送回来。 */
export function platformLoginUrl(target = basePath, switchAccount = false) {
const url = `/login?redirect=${encodeURIComponent(target)}`;
return switchAccount ? `${url}&switch=1` : url;
}
+2 -2
View File
@@ -36,7 +36,7 @@ export function justBounced() {
return at > 0 && Date.now() - at < BOUNCE_MS;
}
export function goPlatformLogin(target = basePath) {
export function goPlatformLogin(target = basePath, switchAccount = false) {
sessionStorage.setItem(BOUNCE_KEY, String(Date.now()));
window.location.assign(platformLoginUrl(target));
window.location.assign(platformLoginUrl(target, switchAccount));
}