front/src/App.vue
zzh f511c3b8d8
All checks were successful
Build and Deploy Front / deploy (push) Successful in 4m0s
feat: 客户登录品牌布局与官网登录体验优化
收紧客户登录左区品牌层次,补查单/看价入口,并顺带优化验证码、注册与官网跑道表现。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-14 22:31:17 +08:00

366 lines
10 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<a-config-provider :locale="locale">
<template #empty>
<AppMascotState mode="empty" compact />
</template>
<div
class="app-portal-stage"
:class="{ 'app-portal-stage--iris': isPageIris }"
>
<router-view v-slot="{ Component, route }">
<Transition
:css="false"
@leave="onPortalLeave"
@enter="onPortalEnter"
@after-leave="clearPortalTransition"
>
<component
:is="Component"
v-if="Component"
:key="portalViewKey(route)"
/>
</Transition>
</router-view>
</div>
<GlobalSetting v-if="showGlobalSetting" />
</a-config-provider>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';
import type { RouteLocationNormalizedLoaded } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
import useLocale from '@/hooks/locale';
import { isLoginRouteName } from '@/utils/login-portal';
import {
consumePageFlip,
PORTAL_IRIS_ACTIVE_CLASS,
PORTAL_IRIS_SETTLED_CLASS,
shouldPortalIris,
} from '@/utils/page-transition-flag';
import GlobalSetting from '@/components/global-setting/index.vue';
import AppMascotState from '@/components/AppMascotState/index.vue';
const route = useRoute();
const router = useRouter();
/** '' | 'oms-iris' — 中心展开(官网→登录 / 登录互切) */
const portalTransition = ref('');
const isPageIris = computed(() => portalTransition.value === 'oms-iris');
/**
* 圆半径约 71% 盖住四角;收到 78% 留余量。
* 时长略收、缓动更匀,减少「点了发呆再猛撑开」的感觉。
*/
const IRIS_MS = 720;
const IRIS_EASE = 'cubic-bezier(0.22, 0.82, 0.28, 1)';
/** 新页最多等一帧解码窗口;超时也开裁剪,优先跟手 */
const IRIS_READY_CAP_MS = 64;
const IRIS_AT = '50% 50%';
const IRIS_END = '78%';
function clearPortalTransition() {
portalTransition.value = '';
}
/** 用顶层路由名作 key,避免业务页切路由时整页 remount */
function portalViewKey(r: RouteLocationNormalizedLoaded) {
const top = r.matched[0];
if (top?.name) return String(top.name);
return top?.path || r.path;
}
function prepareSheet(node: HTMLElement, z: number) {
node.style.position = 'absolute';
node.style.inset = '0';
node.style.width = '100%';
node.style.height = '100%';
node.style.minHeight = '100%';
node.style.zIndex = String(z);
node.style.overflow = 'hidden';
}
function clearSheetStyles(node: HTMLElement) {
node.style.position = '';
node.style.inset = '';
node.style.width = '';
node.style.height = '';
node.style.minHeight = '';
node.style.zIndex = '';
node.style.overflow = '';
node.style.willChange = '';
node.style.transform = '';
node.style.filter = '';
node.style.opacity = '';
node.style.clipPath = '';
node.style.pointerEvents = '';
node.style.removeProperty('-webkit-clip-path');
}
/** 旧页卸掉之后再调;新页铺满前不能提前放 */
let releaseIrisLeave: (() => void) | null = null;
function markIrisSettled() {
const root = document.documentElement;
root.classList.add(PORTAL_IRIS_SETTLED_CLASS);
root.classList.remove(PORTAL_IRIS_ACTIVE_CLASS);
}
/**
* 等新页完成一次完整绘制,再开裁剪。
* 若边裁边解码大图,每一帧都要重绘,圆就会一卡一卡地长。
*/
function whenIncomingReady(node: HTMLElement) {
const pending = [...node.querySelectorAll('img')].filter((img) => !img.complete);
const decoded = Promise.all(
pending.map((img) =>
typeof img.decode === 'function'
? img.decode().catch(() => undefined)
: Promise.resolve(),
),
);
const cap = new Promise<void>((resolve) => {
window.setTimeout(resolve, IRIS_READY_CAP_MS);
});
const frames = new Promise<void>((resolve) => {
requestAnimationFrame(() => {
requestAnimationFrame(() => resolve());
});
});
return Promise.all([frames, Promise.race([decoded, cap])]).then(() => undefined);
}
/**
* 旧页只作一张静止底图。亮度滤镜会让整页每一帧都重采样,是掉帧的主要来源。
*/
function playIrisLeave(node: HTMLElement, done: () => void) {
prepareSheet(node, 2);
node.classList.add('portal-iris-frozen');
node.style.transform = 'translateZ(0)';
node.style.pointerEvents = 'none';
try {
node.getAnimations({ subtree: true }).forEach((anim) => anim.pause());
} catch {
/* 旧环境没有 getAnimations 时,样式冻结仍然生效 */
}
let released = false;
const release = () => {
if (released) return;
released = true;
if (releaseIrisLeave === release) releaseIrisLeave = null;
done();
};
releaseIrisLeave = release;
window.setTimeout(release, IRIS_MS + IRIS_READY_CAP_MS + 480);
}
async function playIrisEnter(node: HTMLElement, done: () => void) {
prepareSheet(node, 1);
node.style.willChange = 'clip-path';
node.style.transform = 'translateZ(0)';
node.style.pointerEvents = 'none';
node.style.clipPath = 'none';
node.style.setProperty('-webkit-clip-path', 'none');
let finished = false;
let anim: Animation | null = null;
const finish = () => {
if (finished) return;
finished = true;
// 先去掉内联裁剪再 cancel,避免 fill 被取消后回到 circle(0%)
node.style.clipPath = '';
node.style.removeProperty('-webkit-clip-path');
anim?.cancel();
clearSheetStyles(node);
done();
releaseIrisLeave?.();
markIrisSettled();
};
try {
await whenIncomingReady(node);
} catch {
/* 解码失败也继续展开 */
}
if (!node.isConnected) {
finish();
return;
}
const at = IRIS_AT;
const end = IRIS_END;
const startClip = `circle(0% at ${at})`;
const endClip = `circle(${end} at ${at})`;
// 先收到 0 再抬到上层,避免动画首帧还没写上时整页闪一下
node.style.clipPath = startClip;
node.style.setProperty('-webkit-clip-path', startClip);
node.style.zIndex = '3';
// 强制一次合成同步,减少首帧卡顿
void node.offsetWidth;
try {
const frames = [
{ clipPath: startClip, webkitClipPath: startClip },
{ clipPath: endClip, webkitClipPath: endClip },
] as Keyframe[];
anim = node.animate(frames, {
duration: IRIS_MS,
easing: IRIS_EASE,
fill: 'forwards',
});
} catch {
finish();
return;
}
anim.finished.catch(() => undefined).finally(finish);
}
function onPortalLeave(el: Element, done: () => void) {
if (portalTransition.value !== 'oms-iris') {
done();
return;
}
playIrisLeave(el as HTMLElement, done);
}
function onPortalEnter(el: Element, done: () => void) {
if (portalTransition.value !== 'oms-iris') {
done();
return;
}
playIrisEnter(el as HTMLElement, done);
}
function isStandalonePortalPath(path: string) {
return (
path === '/' ||
path.startsWith('/h5') ||
path.startsWith('/wechat/') ||
path === '/track/query' ||
path.startsWith('/track/query/')
);
}
function isLoginPath(path: string) {
return path === '/login' || path === '/admin' || path === '/h5/login';
}
const showGlobalSetting = computed(() => {
const path = String(route.path || '');
if (isStandalonePortalPath(path)) return false;
if (isLoginPath(path)) return false;
const name = route.name ? String(route.name) : '';
if (name && isLoginRouteName(name)) return false;
return true;
});
router.beforeEach((to, from) => {
const iris = shouldPortalIris(to, from);
consumePageFlip();
portalTransition.value = iris ? 'oms-iris' : '';
const root = document.documentElement;
if (iris) {
root.classList.add(PORTAL_IRIS_ACTIVE_CLASS);
} else {
root.classList.remove(PORTAL_IRIS_ACTIVE_CLASS, PORTAL_IRIS_SETTLED_CLASS);
}
});
const { currentLocale } = useLocale();
const locale = computed(() => {
switch (currentLocale.value) {
case 'zh-CN':
return zhCN;
case 'en-US':
return enUS;
default:
return enUS;
}
});
</script>
<style>
/* 侧边菜单栏背景(主题色变量) */
.main-menu {
background: var(--app-sidebar-bg) !important;
}
[data-v-eb552580].main-menu {
background: var(--app-sidebar-bg) !important;
}
.main-menu[data-v-eb552580] {
background: var(--app-sidebar-bg) !important;
}
div.main-menu[data-v-eb552580] {
background: var(--app-sidebar-bg) !important;
}
html body .main-menu {
background: var(--app-sidebar-bg) !important;
}
.main-menu .menu-text {
font-size: 12px !important;
font-weight: bold !important;
}
[data-v-eb552580] .menu-text {
font-size: 12px !important;
font-weight: bold !important;
}
.main-menu[data-v-eb552580] .menu-text {
font-size: 12px !important;
font-weight: bold !important;
}
html body .main-menu .menu-text {
font-size: 12px !important;
font-weight: bold !important;
}
.app-portal-stage {
min-height: 100%;
}
.app-portal-stage--iris {
position: relative;
overflow: hidden;
min-height: 100vh;
min-height: 100dvh;
/* 与登录页灰底一致,避免展开时露黑缝 */
background: var(--app-page-bg, #f0f3f4);
}
/* 旧页:停掉无限动画和额外合成层,让底图在展开期间保持同一张纹理 */
.portal-iris-frozen,
.portal-iris-frozen * {
animation-play-state: paused !important;
transition: none !important;
will-change: auto !important;
}
/* 新页:展开期间不要再叠模糊和入场动画,否则裁剪每一帧都要重绘 */
html.portal-iris-active .login-split,
html.portal-iris-active .login-pane {
will-change: auto !important;
}
html.portal-iris-active .login-container,
html.portal-iris-active .login-container * {
backdrop-filter: none !important;
-webkit-backdrop-filter: none !important;
}
html.portal-iris-active .login-hero__principle,
html.portal-iris-settled .login-hero__principle {
animation: none !important;
opacity: 1 !important;
}
</style>