fix: 升级说明改为内嵌背景的独立页面
This commit is contained in:
@@ -679,10 +679,10 @@ _dist = Path(__file__).resolve().parents[2] / "web" / "dist"
|
|||||||
@app.get("/tool-upgrade", include_in_schema=False)
|
@app.get("/tool-upgrade", include_in_schema=False)
|
||||||
@app.get("/tool-upgrade/", include_in_schema=False)
|
@app.get("/tool-upgrade/", include_in_schema=False)
|
||||||
def tool_upgrade_page() -> FileResponse:
|
def tool_upgrade_page() -> FileResponse:
|
||||||
index = _dist / "index.html"
|
page = _dist / "tool-upgrade" / "index.html"
|
||||||
if not index.is_file():
|
if not page.is_file():
|
||||||
raise HTTPException(status_code=404, detail="页面不存在")
|
raise HTTPException(status_code=404, detail="页面不存在")
|
||||||
return FileResponse(index, headers={"Cache-Control": "no-cache"})
|
return FileResponse(page, headers={"Cache-Control": "no-cache"})
|
||||||
|
|
||||||
|
|
||||||
if _dist.is_dir():
|
if _dist.is_dir():
|
||||||
|
|||||||
@@ -1227,5 +1227,7 @@ def test_tool_upgrade_page_is_reachable_only_by_its_address() -> None:
|
|||||||
|
|
||||||
response = TestClient(api_module.app).get("/tool-upgrade")
|
response = TestClient(api_module.app).get("/tool-upgrade")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert 'id="app"' in response.text
|
assert "旧版工具已失效" in response.text
|
||||||
|
assert "复制地址" in response.text
|
||||||
|
assert 'type="module"' not in response.text
|
||||||
assert response.headers["cache-control"] == "no-cache"
|
assert response.headers["cache-control"] == "no-cache"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-5
@@ -3,7 +3,6 @@ import { onMounted, onUnmounted, ref } from "vue";
|
|||||||
import { apiFetch, setSessionDenied } from "./shared/http";
|
import { apiFetch, setSessionDenied } from "./shared/http";
|
||||||
import { darkTheme, dateZhCN, NButton, NConfigProvider, NDialogProvider, zhCN } from "naive-ui";
|
import { darkTheme, dateZhCN, NButton, NConfigProvider, NDialogProvider, zhCN } from "naive-ui";
|
||||||
import LoginView from "./features/auth/LoginView.vue";
|
import LoginView from "./features/auth/LoginView.vue";
|
||||||
import ToolUpgradeView from "./features/tool-upgrade/ToolUpgradeView.vue";
|
|
||||||
import Shell from "./shell/Shell.vue";
|
import Shell from "./shell/Shell.vue";
|
||||||
import AdminShell from "./shell/AdminShell.vue";
|
import AdminShell from "./shell/AdminShell.vue";
|
||||||
import { isDark, themeOverrides } from "./shared/theme";
|
import { isDark, themeOverrides } from "./shared/theme";
|
||||||
@@ -12,7 +11,6 @@ import { sessionFromPayload, type AppSession } from "./shared/session";
|
|||||||
const ready = ref(false);
|
const ready = ref(false);
|
||||||
const session = ref<AppSession | null>(null);
|
const session = ref<AppSession | null>(null);
|
||||||
const sessionError = ref("");
|
const sessionError = ref("");
|
||||||
const isToolUpgrade = window.location.pathname.replace(/\/+$/, "") === "/tool-upgrade";
|
|
||||||
|
|
||||||
function applyPayload(payload: unknown) {
|
function applyPayload(payload: unknown) {
|
||||||
if (!payload || typeof payload !== "object") return null;
|
if (!payload || typeof payload !== "object") return null;
|
||||||
@@ -46,7 +44,6 @@ async function loadSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (isToolUpgrade) return;
|
|
||||||
setSessionDenied(() => {
|
setSessionDenied(() => {
|
||||||
void loadSession();
|
void loadSession();
|
||||||
});
|
});
|
||||||
@@ -112,8 +109,7 @@ function onLogin(next: AppSession) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider class="app-root" :locale="zhCN" :date-locale="dateZhCN" :theme="isDark ? darkTheme : null" :theme-overrides="themeOverrides">
|
<n-config-provider class="app-root" :locale="zhCN" :date-locale="dateZhCN" :theme="isDark ? darkTheme : null" :theme-overrides="themeOverrides">
|
||||||
<ToolUpgradeView v-if="isToolUpgrade" />
|
<n-dialog-provider>
|
||||||
<n-dialog-provider v-else>
|
|
||||||
<div v-if="ready && sessionError && !session" class="gate">
|
<div v-if="ready && sessionError && !session" class="gate">
|
||||||
<section class="gate-card">
|
<section class="gate-card">
|
||||||
<p class="session-note">暂时无法确认登录状态</p>
|
<p class="session-note">暂时无法确认登录状态</p>
|
||||||
|
|||||||
@@ -1,199 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref } from "vue";
|
|
||||||
import backgroundUrl from "./background.png";
|
|
||||||
|
|
||||||
const toolUrl = "https://euniv.asio.asia";
|
|
||||||
const urlEl = ref<HTMLElement | null>(null);
|
|
||||||
const copied = ref(false);
|
|
||||||
const copyFailed = ref(false);
|
|
||||||
let copiedTimer = 0;
|
|
||||||
|
|
||||||
async function copyUrl() {
|
|
||||||
copied.value = false;
|
|
||||||
copyFailed.value = false;
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(toolUrl);
|
|
||||||
copied.value = true;
|
|
||||||
} catch {
|
|
||||||
copyFailed.value = true;
|
|
||||||
const node = urlEl.value;
|
|
||||||
if (!node) return;
|
|
||||||
const range = document.createRange();
|
|
||||||
range.selectNodeContents(node);
|
|
||||||
const selection = window.getSelection();
|
|
||||||
selection?.removeAllRanges();
|
|
||||||
selection?.addRange(range);
|
|
||||||
}
|
|
||||||
window.clearTimeout(copiedTimer);
|
|
||||||
copiedTimer = window.setTimeout(() => {
|
|
||||||
copied.value = false;
|
|
||||||
copyFailed.value = false;
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<main class="upgrade" :style="{ backgroundImage: `url(${backgroundUrl})` }">
|
|
||||||
<section class="wrap">
|
|
||||||
<div class="ring" aria-hidden="true"><div class="spin"></div></div>
|
|
||||||
<div class="card">
|
|
||||||
<h1>旧版工具已失效</h1>
|
|
||||||
<p>因目标平台升级,旧版工具已失效,无法登录使用。新版工具已上线。</p>
|
|
||||||
<p>请复制下面的地址,打开浏览器,粘贴到地址栏后访问。</p>
|
|
||||||
<p ref="urlEl" class="url">{{ toolUrl }}</p>
|
|
||||||
<button type="button" class="copy" @click="copyUrl">{{ copied ? "已复制" : "复制地址" }}</button>
|
|
||||||
<p v-if="copied" class="result">已复制。请到浏览器地址栏粘贴后访问。</p>
|
|
||||||
<p v-else-if="copyFailed" class="result miss">没有复制成功,地址已选中,请手动使用 CTRL+C 复制。</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.upgrade {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 20;
|
|
||||||
display: grid;
|
|
||||||
place-items: center;
|
|
||||||
padding: 32px 16px;
|
|
||||||
overflow: auto;
|
|
||||||
background-color: #bdbec0;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
background-size: cover;
|
|
||||||
color: #1c1c1c;
|
|
||||||
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrap {
|
|
||||||
position: relative;
|
|
||||||
width: min(460px, 100%);
|
|
||||||
box-shadow: 0 0 0 1px #6e7073;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ring {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2;
|
|
||||||
padding: 2px;
|
|
||||||
overflow: hidden;
|
|
||||||
pointer-events: none;
|
|
||||||
-webkit-mask:
|
|
||||||
linear-gradient(#000 0 0) content-box,
|
|
||||||
linear-gradient(#000 0 0);
|
|
||||||
-webkit-mask-composite: xor;
|
|
||||||
mask:
|
|
||||||
linear-gradient(#000 0 0) content-box,
|
|
||||||
linear-gradient(#000 0 0);
|
|
||||||
mask-composite: exclude;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spin {
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
width: 220%;
|
|
||||||
height: 220%;
|
|
||||||
background: conic-gradient(
|
|
||||||
transparent 0deg,
|
|
||||||
transparent 230deg,
|
|
||||||
#3ec4ff 292deg,
|
|
||||||
#ffffff 318deg,
|
|
||||||
#3ec4ff 344deg,
|
|
||||||
transparent 360deg
|
|
||||||
);
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
animation: beam 2.4s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
margin: 2px;
|
|
||||||
padding: 28px 24px;
|
|
||||||
background: rgba(243, 243, 243, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
margin: 0 0 14px;
|
|
||||||
font-size: 22px;
|
|
||||||
font-weight: 650;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
line-height: 1.7;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.url {
|
|
||||||
margin: 16px 0;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid rgba(28, 28, 28, 0.28);
|
|
||||||
background: rgba(255, 255, 255, 0.72);
|
|
||||||
color: #1a3f73;
|
|
||||||
word-break: break-all;
|
|
||||||
user-select: all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
height: 36px;
|
|
||||||
padding: 0 16px;
|
|
||||||
border: 1px solid rgba(26, 63, 115, 0.55);
|
|
||||||
background: rgba(255, 255, 255, 0.55);
|
|
||||||
color: #1c1c1c;
|
|
||||||
font: inherit;
|
|
||||||
font-size: 14px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy::before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
background: linear-gradient(105deg, transparent 30%, rgba(127, 215, 255, 0.95) 50%, transparent 70%);
|
|
||||||
transform: translateX(-130%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy:hover {
|
|
||||||
border-color: #1a6ea8;
|
|
||||||
box-shadow: 0 0 0 1px rgba(90, 190, 255, 0.7), 0 0 16px rgba(90, 190, 255, 0.45);
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy:hover::before {
|
|
||||||
transform: translateX(130%);
|
|
||||||
transition: transform 0.45s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.result {
|
|
||||||
margin-top: 12px;
|
|
||||||
color: #1d5c32;
|
|
||||||
}
|
|
||||||
|
|
||||||
.miss {
|
|
||||||
color: #8a3b12;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes beam {
|
|
||||||
from {
|
|
||||||
transform: translate(-50%, -50%) rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: translate(-50%, -50%) rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.spin {
|
|
||||||
animation: none;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy:hover::before {
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 198 KiB |
Vendored
-4
@@ -1,4 +0,0 @@
|
|||||||
declare module "*.png" {
|
|
||||||
const src: string;
|
|
||||||
export default src;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user