feat: 前端支持平台子路径,托管时从平台登录进入
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton } from "naive-ui";
|
||||
import { platformHome } from "../../shared/base";
|
||||
import { goPlatformLogin } from "../../shared/platform";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="gate">
|
||||
<ThemeButton placement="left" />
|
||||
<section class="gate-card" aria-labelledby="denied-title">
|
||||
<div class="gate-brand">
|
||||
<div class="brand-mark" aria-hidden="true">D</div>
|
||||
<h1>DecomEval</h1>
|
||||
</div>
|
||||
<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 type="primary" tag="a" :href="platformHome">返回平台</n-button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -2,16 +2,20 @@
|
||||
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 { api, saveSession } from "../../shared/http";
|
||||
import { hosted } from "../../shared/installState";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
import "./login-gate.css";
|
||||
|
||||
const BROKEN_CAPTCHA = "data:,";
|
||||
const props = defineProps<{ purpose?: "login" | "pool" }>();
|
||||
const emit = defineEmits<{ done: [] }>();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const toast = useToast();
|
||||
const adminLoginUrl = platformLoginUrl();
|
||||
const mode = ref("local");
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
@@ -19,13 +23,13 @@ const captcha = ref("");
|
||||
const captchaUrl = ref("");
|
||||
const captchaLoading = ref(false);
|
||||
const captchaBroken = ref(false);
|
||||
const captchaSrc = computed(() => captchaBroken.value || !captchaUrl.value ? "/__captcha_broken__" : captchaUrl.value);
|
||||
const captchaSrc = computed(() => captchaBroken.value || !captchaUrl.value ? BROKEN_CAPTCHA : captchaUrl.value);
|
||||
|
||||
function markCaptchaBroken(event: Event) {
|
||||
const img = event.target as HTMLImageElement;
|
||||
if (captchaBroken.value) return;
|
||||
captchaBroken.value = true;
|
||||
img.src = "/__captcha_broken__";
|
||||
img.src = BROKEN_CAPTCHA;
|
||||
}
|
||||
const sessionId = ref("");
|
||||
const smsCode = ref("");
|
||||
@@ -331,7 +335,7 @@ async function finishNqi() {
|
||||
<n-input :input-props="{ id: 'pool-captcha', autocomplete: 'off' }" v-model:value="captcha" @keyup.enter="submitLogin" />
|
||||
<button type="button" class="lv-captcha-box" title="点击刷新" @click="refreshCaptcha">
|
||||
<n-spin v-if="captchaLoading" size="small" />
|
||||
<img v-else :src="captchaSrc" alt="验证码" @error="markCaptchaBroken" />
|
||||
<img v-else :src="captchaSrc" :class="{ broken: captchaSrc === BROKEN_CAPTCHA }" alt="验证码" @error="markCaptchaBroken" />
|
||||
</button>
|
||||
</div>
|
||||
<n-button class="lv-go" type="primary" attr-type="submit" :loading="busy">添加</n-button>
|
||||
@@ -365,12 +369,13 @@ async function finishNqi() {
|
||||
<input id="login-captcha" v-model="captcha" placeholder="captcha" autocomplete="off" @keyup.enter="submitLogin" />
|
||||
<button type="button" class="lv-captcha-box" title="点击刷新" @click="refreshCaptcha">
|
||||
<n-spin v-if="captchaLoading" size="small" />
|
||||
<img v-else :src="captchaSrc" alt="验证码" @error="markCaptchaBroken" />
|
||||
<img v-else :src="captchaSrc" :class="{ broken: captchaSrc === BROKEN_CAPTCHA }" alt="验证码" @error="markCaptchaBroken" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<button class="lv-go" type="submit" :disabled="busy">{{ busy ? "登录中" : "登录" }}</button>
|
||||
</form>
|
||||
<a v-if="hosted && mode === 'nqi'" class="lv-admin" :href="adminLoginUrl">管理员登录</a>
|
||||
</section>
|
||||
<n-modal v-model:show="smsRequired" :mask-closable="false" :auto-focus="false">
|
||||
<div class="lv-sms-sheet" role="dialog" aria-modal="true" aria-labelledby="sms-title">
|
||||
|
||||
@@ -197,6 +197,21 @@ html[data-theme="dark"] .gate.lv-tower {
|
||||
}
|
||||
.gate.lv-tower .lv-go:hover { filter: brightness(1.12); }
|
||||
.gate.lv-tower .lv-go:disabled { opacity: 0.6; cursor: default; filter: none; }
|
||||
.gate.lv-tower .lv-admin {
|
||||
display: block;
|
||||
width: fit-content;
|
||||
margin: 18px 0 0 auto;
|
||||
color: var(--muted-line);
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.08em;
|
||||
text-decoration: none;
|
||||
}
|
||||
.gate.lv-tower .lv-admin:hover,
|
||||
.gate.lv-tower .lv-admin:focus-visible {
|
||||
color: var(--ink-line);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.gate.lv-tower { grid-template-columns: 28px 1fr; }
|
||||
|
||||
Reference in New Issue
Block a user