feat: 登录提示改为顶部刘海弹出并带动效收缩

This commit is contained in:
2026-11-03 08:48:13 +08:00
parent d301acedfd
commit d3565f1aa9
2 changed files with 135 additions and 24 deletions
+36 -4
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { NButton, NInput, NModal, NSpin } from "naive-ui";
import { api, saveSession } from "../../shared/http";
@@ -34,6 +34,7 @@ const smsSending = ref(false);
const countdown = ref(0);
const busy = ref(false);
const noticeVisible = ref(false);
const noticeLeaving = ref(false);
const noticePinned = ref(false);
let countdownTimer = 0;
let noticeTimer = 0;
@@ -46,8 +47,28 @@ function clearNoticeTimer() {
function showNotice() {
if (mode.value !== "nqi") return;
noticePinned.value = false;
noticeVisible.value = true;
noticeLeaving.value = false;
clearNoticeTimer();
if (noticeVisible.value) {
noticeVisible.value = false;
void nextTick(() => {
if (mode.value === "nqi") noticeVisible.value = true;
});
return;
}
noticeVisible.value = true;
}
function collapseNotice() {
if (mode.value !== "nqi" || noticePinned.value || noticeLeaving.value) return;
if (!noticeVisible.value) return;
noticeVisible.value = false;
noticeLeaving.value = true;
}
function finishIslandLeave(event: AnimationEvent) {
if (event.animationName !== "lv-island-out") return;
noticeLeaving.value = false;
}
function beginNoticeCountdown() {
@@ -55,7 +76,7 @@ function beginNoticeCountdown() {
clearNoticeTimer();
noticeTimer = window.setTimeout(() => {
noticeTimer = 0;
if (!noticePinned.value) noticeVisible.value = false;
collapseNotice();
}, 5000);
}
@@ -63,6 +84,7 @@ function pinNotice() {
if (mode.value !== "nqi") return;
clearNoticeTimer();
noticePinned.value = true;
noticeLeaving.value = false;
noticeVisible.value = true;
}
@@ -71,6 +93,7 @@ watch(mode, (value) => {
else {
noticePinned.value = false;
noticeVisible.value = false;
noticeLeaving.value = false;
clearNoticeTimer();
}
});
@@ -316,6 +339,16 @@ async function finishNqi() {
</section>
<div v-else class="gate lv-tower">
<ThemeButton placement="left" />
<div
v-if="mode === 'nqi'"
class="lv-island"
:class="{ on: noticeVisible, out: noticeLeaving }"
role="status"
:aria-hidden="!noticeVisible"
@animationend="finishIslandLeave"
>
<span>请使用大数据平台账号登录</span>
</div>
<div class="lv-mast" aria-hidden="true"><span /></div>
<section class="lv-side">
<div class="lv-brand">
@@ -338,7 +371,6 @@ async function finishNqi() {
</template>
<button class="lv-go" type="submit" :disabled="busy">{{ busy ? "登录中" : "登录" }}</button>
</form>
<p v-if="mode === 'nqi'" class="lv-notice" :class="{ on: noticeVisible }" :aria-hidden="!noticeVisible">请使用大数据平台账号登录</p>
</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">
+99 -20
View File
@@ -32,9 +32,47 @@ html[data-theme="dark"] .gate.lv-tower {
position: absolute;
top: 16px;
right: 16px;
z-index: 2;
z-index: 4;
color: var(--ink-line);
}
.gate.lv-tower .lv-island {
--island-w: min(268px, calc(100% - 120px));
position: absolute;
top: 0;
left: 50%;
z-index: 3;
display: flex;
align-items: center;
justify-content: center;
width: 84px;
height: 8px;
padding: 0 18px;
overflow: hidden;
border: 1px solid var(--ink-line);
border-top: 0;
border-radius: 0 0 20px 20px;
background: var(--ink-line);
color: color-mix(in srgb, var(--notice) 48%, var(--paper));
font-size: 13px;
letter-spacing: 0.04em;
white-space: nowrap;
pointer-events: none;
transform: translateX(-50%) translateY(-110%);
transform-origin: top center;
opacity: 0;
}
.gate.lv-tower .lv-island.on {
animation: lv-island-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.gate.lv-tower .lv-island.out {
animation: lv-island-out 0.78s cubic-bezier(0.32, 0.02, 0.18, 1) forwards;
}
.gate.lv-tower .lv-island.on span {
animation: lv-island-text-in 0.28s ease 0.2s both;
}
.gate.lv-tower .lv-island.out span {
animation: lv-island-text-out 0.14s ease both;
}
.gate.lv-tower .lv-mast {
position: relative;
align-self: stretch;
@@ -94,25 +132,6 @@ html[data-theme="dark"] .gate.lv-tower {
letter-spacing: 0.18em;
text-align: center;
}
.gate.lv-tower .lv-notice {
margin: 14px 0 0;
padding: 0;
border: 0;
border-radius: 0;
background: transparent;
color: var(--notice);
text-align: center;
font-size: 13px;
line-height: 1.45;
min-height: 1.45em;
visibility: hidden;
opacity: 0;
pointer-events: none;
}
.gate.lv-tower .lv-notice.on {
visibility: visible;
opacity: 1;
}
.gate.lv-tower .lv-fields {
display: grid;
grid-template-columns: 4.2em minmax(0, 1fr);
@@ -191,10 +210,70 @@ html[data-theme="dark"] .gate.lv-tower {
}
}
@media (prefers-reduced-motion: reduce) {
.gate.lv-tower .lv-island.on,
.gate.lv-tower .lv-island.out,
.gate.lv-tower .lv-island.on span,
.gate.lv-tower .lv-island.out span {
animation: none;
}
.gate.lv-tower .lv-island.on {
width: var(--island-w);
height: 36px;
transform: translateX(-50%) translateY(0);
opacity: 1;
}
}
@keyframes lv-mast {
to { clip-path: inset(0 0 0 0); }
}
@keyframes lv-island-in {
0% {
width: 84px;
height: 8px;
transform: translateX(-50%) translateY(-100%);
opacity: 1;
}
100% {
width: var(--island-w);
height: 36px;
transform: translateX(-50%) translateY(0);
opacity: 1;
}
}
@keyframes lv-island-out {
0% {
width: var(--island-w);
height: 36px;
transform: translateX(-50%) translateY(0);
opacity: 1;
}
62% {
width: 96px;
height: 14px;
transform: translateX(-50%) translateY(0);
opacity: 1;
}
100% {
width: 68px;
height: 8px;
transform: translateX(-50%) translateY(-120%);
opacity: 0;
}
}
@keyframes lv-island-text-in {
from { opacity: 0; transform: translateY(-3px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes lv-island-text-out {
to { opacity: 0; }
}
.lv-sms-sheet {
--paper: color-mix(in srgb, #ebe4d2 70%, #d7dce2);
--ink-line: #2c3038;