feat: 增加升级说明页,退出弹窗默认选退出系统

This commit is contained in:
Nixevol
2026-11-18 10:22:53 +08:00
parent 3670a76dfe
commit 71373839c6
6 changed files with 119 additions and 5 deletions
+5 -1
View File
@@ -3,6 +3,7 @@ import { onMounted, onUnmounted, ref } from "vue";
import { apiFetch, setSessionDenied } from "./shared/http";
import { darkTheme, dateZhCN, NButton, NConfigProvider, NDialogProvider, zhCN } from "naive-ui";
import LoginView from "./features/auth/LoginView.vue";
import NoticeView from "./features/notice/NoticeView.vue";
import Shell from "./shell/Shell.vue";
import AdminShell from "./shell/AdminShell.vue";
import { isDark, themeOverrides } from "./shared/theme";
@@ -11,6 +12,7 @@ import { sessionFromPayload, type AppSession } from "./shared/session";
const ready = ref(false);
const session = ref<AppSession | null>(null);
const sessionError = ref("");
const isNotice = window.location.pathname.replace(/\/+$/, "") === "/msg01";
function applyPayload(payload: unknown) {
if (!payload || typeof payload !== "object") return null;
@@ -44,6 +46,7 @@ async function loadSession() {
}
onMounted(() => {
if (isNotice) return;
setSessionDenied(() => {
void loadSession();
});
@@ -109,7 +112,8 @@ function onLogin(next: AppSession) {
<template>
<n-config-provider class="app-root" :locale="zhCN" :date-locale="dateZhCN" :theme="isDark ? darkTheme : null" :theme-overrides="themeOverrides">
<n-dialog-provider>
<NoticeView v-if="isNotice" />
<n-dialog-provider v-else>
<div v-if="ready && sessionError && !session" class="gate">
<section class="gate-card">
<p class="session-note">暂时无法确认登录状态</p>
+49
View File
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { ref } from "vue";
import { NButton } from "naive-ui";
const toolUrl = "https://euniv.asio.asia";
const copied = ref(false);
let copiedTimer = 0;
async function copyUrl() {
try {
await navigator.clipboard.writeText(toolUrl);
} catch {
const box = document.createElement("textarea");
box.value = toolUrl;
box.setAttribute("readonly", "");
box.style.position = "fixed";
box.style.left = "-9999px";
document.body.appendChild(box);
box.select();
document.execCommand("copy");
box.remove();
}
copied.value = true;
window.clearTimeout(copiedTimer);
copiedTimer = window.setTimeout(() => {
copied.value = false;
}, 2000);
}
function openTool() {
const opened = window.open(toolUrl, "_blank", "noopener");
if (!opened) window.location.assign(toolUrl);
}
</script>
<template>
<main class="notice-page">
<section class="notice-card">
<h1>旧版工具已失效</h1>
<p>因目标平台升级,旧版工具已失效,无法登录使用。</p>
<p>新版工具已上线,请访问:</p>
<p class="notice-url">{{ toolUrl }}</p>
<div class="notice-actions">
<n-button type="primary" @click="openTool">打开新版工具</n-button>
<n-button @click="copyUrl">{{ copied ? "已复制" : "复制地址" }}</n-button>
</div>
</section>
</main>
</template>
+2 -3
View File
@@ -15,7 +15,7 @@ const page = ref<PageKey>(pageFromHash());
const collapsed = ref(window.innerWidth < 800);
const holdOpen = ref(false);
const leaveOpen = ref(false);
const leaveChoice = ref<"logout" | "revoke" | null>(null);
const leaveChoice = ref<"logout" | "revoke">("logout");
const pages = new Set<PageKey>(["home", "history", "exams", "trainings"]);
function hashName() {
@@ -79,7 +79,7 @@ function onMenu(key: string) {
}
function openLeave() {
leaveChoice.value = null;
leaveChoice.value = "logout";
leaveOpen.value = true;
}
@@ -163,7 +163,6 @@ function confirmLeave() {
<n-button @click="leaveOpen = false">取消</n-button>
<n-button
:type="leaveChoice === 'revoke' ? 'error' : 'primary'"
:disabled="leaveChoice === null"
@click="confirmLeave"
>
{{ leaveChoice === "revoke" ? "注销账号" : "退出系统" }}
+42
View File
@@ -1657,6 +1657,48 @@ select {
line-height: 1.6;
}
.notice-page {
min-height: 100%;
display: grid;
place-items: center;
padding: 32px 16px;
}
.notice-card {
width: min(440px, 100%);
padding: 28px 24px;
border: 1px solid var(--line);
border-radius: 4px;
background: var(--panel);
}
.notice-card h1 {
margin: 0 0 16px;
font-size: 22px;
font-weight: 650;
}
.notice-card p {
margin: 0 0 12px;
line-height: 1.6;
}
.notice-url {
margin: 0 0 20px;
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 4px;
background: var(--elevated);
color: var(--accent);
word-break: break-all;
user-select: all;
}
.notice-actions {
display: flex;
gap: 8px;
}
.app-root {
position: relative;
}