refine: 官网 AI 首页输入台布局、精选封面与信任条,顶栏 Logo 圆角方标
All checks were successful
Build and Deploy Front / deploy (push) Successful in 11m49s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-11-27 15:46:24 +08:00
parent a8d71d821d
commit c3c00eb764
7 changed files with 728 additions and 422 deletions

View File

@ -1408,7 +1408,7 @@ onUnmounted(() => {
align-items: center;
gap: 8px;
/* 独立白底圆标:大图标 + 克制高级感(细描边 / 轻环境光) */
/* 独立白底圆角方标 */
.top-nav-logo {
position: relative;
z-index: 2;
@ -1419,7 +1419,7 @@ onUnmounted(() => {
width: 44px;
height: 44px;
margin: 0;
border-radius: 50%;
border-radius: 8px;
background: #fff;
border: 1px solid rgba(15, 23, 42, 0.08);
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
@ -1442,8 +1442,8 @@ onUnmounted(() => {
}
img {
height: 30px;
width: 30px;
height: 36px;
width: 36px;
box-sizing: border-box;
object-fit: contain;
display: block;

View File

@ -31,7 +31,6 @@
<SiteRunway :text="heroTitle" />
<h1 class="ai-welcome-title ai-welcome-title--sr">{{ heroTitle }}</h1>
</div>
<p class="ai-welcome-fullname">{{ brandCopy.navFullName }}</p>
<div class="ai-welcome__stack">
<div class="ai-welcome__command">
<div class="ai-ask">
@ -66,11 +65,25 @@
</button>
</div>
<a
class="ai-ask__cta ai-ask__cta--solid"
class="ai-ask__cta ai-ask__cta--solid ai-welcome-cta"
:href="loginUrl"
@pointerenter="$emit('warm-login')"
@focus="$emit('warm-login')"
>{{ copy.heroCta }}</a>
>
<span>{{ copy.heroCta }}</span>
<svg
class="ai-welcome-cta__arrow"
viewBox="0 0 16 16"
width="14"
height="14"
aria-hidden="true"
>
<path
fill="currentColor"
d="M2.5 8a.75.75 0 0 1 .75-.75h7.69L8.22 4.53a.75.75 0 0 1 1.06-1.06l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 1 1-1.06-1.06l2.72-2.72H3.25A.75.75 0 0 1 2.5 8"
/>
</svg>
</a>
</div>
</template>
</EdiComposer>
@ -167,10 +180,13 @@
@submit="$emit('submit', draft)"
/>
</div>
</div>
</div>
<!-- 贴视口底:不进 flex 内容流,避免随 VV/矮屏一起被挤缩 -->
<div class="ai-trust-bar">
<SitePartnerMarquee
:is-zh="isZh"
:tag="copy.partnerTag"
:tag="brandCopy.navFullName"
:aria="copy.partnerAria"
/>
<a class="ai-trust-icp" href="https://beian.miit.gov.cn" target="_blank" rel="noopener">
@ -184,8 +200,6 @@
</a>
</div>
</div>
</div>
</div>
<aside
class="ai-history-sidebar ai-history-sidebar--chat"
:aria-hidden="historyOpen ? 'false' : 'true'"

View File

@ -88,13 +88,21 @@
:tabindex="index === activeIndex ? 0 : -1"
:aria-current="index === activeIndex ? 'true' : undefined"
:aria-label="cardAria(item)"
:style="cardBgStyle(item)"
@click="onCard(item, index)"
>
<!-- 封面独立图层:可做 Ken Burns,且不跟文字一起被 3D 糊边 -->
<span
v-if="routeHasRealCover(item)"
class="ai-featured-routes__media"
:class="{ 'is-ready': isCoverReady(item) }"
aria-hidden="true"
:style="cardBgStyle(item)"
/>
<span class="ai-featured-routes__card-top">
<span
v-if="!routeHasRealCover(item)"
v-if="routeCoverageLabel(item, lang)"
class="ai-featured-routes__dest"
:class="{ 'is-on-cover': routeHasRealCover(item) }"
>{{ routeCoverageLabel(item, lang) }}</span>
<span
v-else
@ -140,6 +148,11 @@
>
{{ item.productDescription }}
</p>
<span
v-if="index === activeIndex"
class="ai-featured-routes__ask-hint"
aria-hidden="true"
>{{ copy.featuredRoutesAsk }}</span>
</span>
</button>
</div>
@ -184,9 +197,11 @@
type RouteItem,
} from './lib/portal-catalog';
import {
isRouteCoverReady,
preloadFeaturedRouteCovers,
resolveRouteCoverUrl,
routeHasRealCover,
subscribeRouteCoverReady,
} from './lib/route-cover';
const AUTOPLAY_MS = 4500;
@ -213,6 +228,9 @@
const paused = ref(false);
const stageWidth = ref(1100);
const cardWidth = ref(280);
/** 驱动封面 is-ready 重绘;实际就绪态在 route-cover 模块里 */
const coverReadyTick = ref(0);
const coverReadyUnsubs: Array<() => void> = [];
const visible = computed(() => loading.value || featured.value.length > 0);
const canPrev = computed(() => featured.value.length > 1);
@ -239,19 +257,33 @@
function cardBgStyle(item: RouteItem) {
const url = resolveRouteCoverUrl(item);
// 3D rotateY 下 background-size:cover 比 img+object-fit 更稳,不会露底
// 封面走独立 media 层;cover + overflow 裁切,比 img 在 rotateY 下更稳
return url
? {
backgroundImage: `url("${url}")`,
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundOrigin: 'border-box',
backgroundClip: 'border-box',
}
: undefined;
}
function isCoverReady(item: RouteItem) {
void coverReadyTick.value;
const url = resolveRouteCoverUrl(item);
return Boolean(url && isRouteCoverReady(url));
}
function bindCoverReady(items: RouteItem[]) {
while (coverReadyUnsubs.length) coverReadyUnsubs.pop()?.();
for (const item of items) {
const url = resolveRouteCoverUrl(item);
if (!url) continue;
coverReadyUnsubs.push(
subscribeRouteCoverReady(url, () => {
coverReadyTick.value += 1;
}),
);
}
}
function applyFeatured(items: RouteItem[], opts?: { keepIndex?: boolean }) {
featured.value = items;
const len = items.length;
@ -261,6 +293,7 @@
activeIndex.value = Math.max(0, len - 1);
}
preloadFeaturedRouteCovers(items, activeIndex.value);
bindCoverReady(items);
}
/** 环形最短偏移:末张右侧接首张,首张左侧接末张 */
@ -497,6 +530,7 @@
ro?.disconnect();
ro = null;
stopAutoplay();
while (coverReadyUnsubs.length) coverReadyUnsubs.pop()?.();
});
watch(stageRef, (el) => {

View File

@ -6,7 +6,7 @@
<script lang="ts" setup>
/**
* 欢迎标题 canvas:保留逐字入场 / 斜切;整行蓝→橙均分斜切。
* 欢迎标题 canvas:逐字入场 / 斜切;按文字实测宽度收缩,避免旁边按钮盖住字。
*/
import { onMounted, onUnmounted, ref, watch } from 'vue';
import { isPortalIrisActive } from '@/utils/page-transition-flag';
@ -52,12 +52,12 @@
let cachedChars: string[] = [];
let cachedLabel = '';
let brandColor = '#023e8a';
let accentColor = '#e96a26';
let accentColor = '#f56668';
const syncThemeColors = () => {
const css = getComputedStyle(root);
brandColor = css.getPropertyValue('--ai-brand').trim() || '#023e8a';
accentColor = css.getPropertyValue('--ai-accent').trim() || '#e96a26';
accentColor = css.getPropertyValue('--ai-accent').trim() || '#f56668';
};
const easeOutCubic = (t: number) => 1 - (1 - t) ** 3;
@ -65,25 +65,15 @@
const enterTotalMs = (charCount: number) =>
TEXT_AT + Math.max(0, charCount - 1) * CHAR_STAGGER + CHAR_DUR;
const paint = () => {
ctx.clearRect(0, 0, width, height);
if (width < 40 || height < 24) return;
const shearOf = () => (isNarrow ? -0.22 : -0.36);
const label = currentText.trim();
if (!label) return;
const cx = width / 2;
const cy = height / 2;
// 约为原大标题一半
const fontSize = Math.max(
const fontSizeOf = (h: number) =>
Math.max(
isNarrow ? 13 : 14,
Math.min(
height * (isNarrow ? 0.5 : 0.48),
width / Math.max(9, (label.length || 1) * (isNarrow ? 0.72 : 0.82)),
),
Math.min(h * (isNarrow ? 0.5 : 0.48), isNarrow ? 20 : 30),
);
// 原 shear -0.32 ≈ 更明显斜体;窄屏略收,避免长标题裁切
const shear = isNarrow ? -0.22 : -0.36;
const measureLabel = (label: string, fontSize: number) => {
const font = `600 ${fontSize}px "PingFang SC","Hiragino Sans GB","Microsoft YaHei","Segoe UI",sans-serif`;
if (font !== cachedFont || label !== cachedLabel) {
ctx.font = font;
@ -94,12 +84,32 @@
} else {
ctx.font = font;
}
const chars = cachedChars;
const letterGap = fontSize * 0.14;
const charWidths = cachedCharWidths;
const totalW =
charWidths.reduce((s, w) => s + w, 0) + letterGap * Math.max(0, chars.length - 1);
cachedCharWidths.reduce((s, w) => s + w, 0) +
letterGap * Math.max(0, cachedChars.length - 1);
return { font, letterGap, totalW, chars: cachedChars, charWidths: cachedCharWidths };
};
/** 文字宽 + 斜切/阴影边距,避免裁字 */
const fitWidthOf = (totalW: number, fontSize: number) => {
const shearExtra = Math.abs(shearOf()) * fontSize * 0.7;
const padX = Math.max(12, fontSize * 0.32) + shearExtra;
return Math.ceil(totalW + padX * 2);
};
const paint = () => {
ctx.clearRect(0, 0, width, height);
if (width < 40 || height < 24) return;
const label = currentText.trim();
if (!label) return;
const cx = width / 2;
const cy = height / 2;
const fontSize = fontSizeOf(height);
const shear = shearOf();
const { font, letterGap, totalW, chars, charWidths } = measureLabel(label, fontSize);
const whooshMax = Math.min(36, width * 0.05);
const yGlyph = fontSize * 0.02;
const shadowX = fontSize * 0.045;
@ -113,7 +123,7 @@
ctx.textBaseline = 'middle';
ctx.font = font;
// 整行左上蓝 → 右下橙均分斜切
// 整行左上蓝 → 右下珊瑚均分斜切
const titleFill = ctx.createLinearGradient(
-totalW / 2,
-fontSize * 0.42,
@ -190,8 +200,23 @@
const rebuild = () => {
syncThemeColors();
const rect = root.getBoundingClientRect();
const nextW = Math.max(1, Math.floor(rect.width));
const nextH = Math.max(1, Math.floor(rect.height));
const nextH = Math.max(
1,
Math.floor(rect.height || parseFloat(getComputedStyle(root).height) || 48),
);
const label = currentText.trim();
const fontSize = fontSizeOf(nextH);
cachedFont = '';
const { totalW } = measureLabel(label || ' ', fontSize);
const fitW = fitWidthOf(totalW, fontSize);
const maxW = Math.floor(window.innerWidth * (isNarrow ? 0.58 : 0.7));
const nextW = Math.max(80, Math.min(fitW, maxW));
// 按字宽写回,避免 CSS 固定大宽导致按钮盖字 / 离太远
if (Math.abs((parseFloat(root.style.width) || 0) - nextW) > 0.5) {
root.style.width = `${nextW}px`;
}
const dpr = Math.min(window.devicePixelRatio || 1, dprCap);
if (nextW === width && nextH === height) {
paint();
@ -199,7 +224,6 @@
}
width = nextW;
height = nextH;
cachedFont = '';
canvas.width = Math.floor(width * dpr);
canvas.height = Math.floor(height * dpr);
canvas.style.width = `${width}px`;
@ -224,7 +248,10 @@
ro.observe(root);
rebuild();
const kick = () => startEnter();
const kick = () => {
rebuild();
startEnter();
};
if ('fonts' in document) {
void document.fonts.ready.then(kick);
} else {
@ -257,7 +284,9 @@
.ai-runway {
position: relative;
z-index: 2;
width: min(760px, 96%);
/* 宽度由脚本按文字实测写入;这里只定高度兜底 */
width: auto;
max-width: 100%;
height: clamp(44px, 5.5vw, 64px);
margin: 0 auto;
pointer-events: none;
@ -271,14 +300,12 @@
@media (max-height: 900px) {
.ai-runway {
width: min(480px, 90%);
height: 42px;
}
}
@media (max-width: 640px) {
.ai-runway {
width: 100%;
height: 46px;
}
}

View File

@ -312,7 +312,7 @@ export async function fetchRoutesCatalog(lang: SiteLang): Promise<RoutesCatalog>
return fetchRoutesCatalogNetwork(lang);
}
/** 欢迎区精选:按目的地区尽量分散,优先有时效的线路 */
/** 欢迎区精选:封面优先 + 目的地分散;封面不足时再补无封面,避免空段 */
export function pickFeaturedRoutes(catalog: RoutesCatalog | null, limit = 6): RouteItem[] {
const items = catalog?.items || [];
if (!items.length) return [];
@ -326,12 +326,18 @@ export function pickFeaturedRoutes(catalog: RoutesCatalog | null, limit = 6): Ro
if (formatRouteTimeliness(item)) s += 3;
if (item.tradeTerms === 'DDP' || item.tradeTerms === 'DDU') s += 1;
if (item.productDescription) s += 1;
if (item.coverImageUrl) s += 2;
if (item.coverImageUrl?.trim()) s += 5;
return s;
};
const hasCover = (item: RouteItem) => Boolean(item.coverImageUrl?.trim());
const fillFromPool = (pool: RouteItem[]) => {
if (!pool.length || picked.length >= limit) return;
const byDest = new Map<string, RouteItem[]>();
for (const item of items) {
for (const item of pool) {
if (used.has(item.id)) continue;
const ids = inferRouteDestIds(item);
const key = ids.find((id) => id !== 'other') || 'other';
const list = byDest.get(key) || [];
@ -344,22 +350,24 @@ export function pickFeaturedRoutes(catalog: RoutesCatalog | null, limit = 6): Ro
for (const destId of destOrder) {
if (picked.length >= limit) break;
const list = byDest.get(destId);
const hit = list?.find((item) => !used.has(item.id));
const hit = byDest.get(destId)?.find((item) => !used.has(item.id));
if (!hit) continue;
used.add(hit.id);
picked.push(hit);
}
if (picked.length < limit) {
const rest = [...items].sort((a, b) => score(b) - score(a));
if (picked.length >= limit) return;
const rest = [...pool].sort((a, b) => score(b) - score(a));
for (const item of rest) {
if (picked.length >= limit) break;
if (used.has(item.id)) continue;
used.add(item.id);
picked.push(item);
}
}
};
fillFromPool(items.filter(hasCover));
if (picked.length < limit) fillFromPool(items.filter((item) => !hasCover(item)));
return picked;
}

View File

@ -1,6 +1,8 @@
import type { RouteItem } from './portal-catalog';
const warmedCoverUrls = new Set<string>();
const readyCoverUrls = new Set<string>();
const readyListeners = new Map<string, Set<() => void>>();
export function routeHasRealCover(item: RouteItem): boolean {
return Boolean(item.coverImageUrl?.trim());
@ -11,6 +13,69 @@ export function resolveRouteCoverUrl(item: RouteItem): string {
return item.coverImageUrl?.trim() || '';
}
export function isRouteCoverReady(url: string): boolean {
const u = String(url || '').trim();
return Boolean(u && readyCoverUrls.has(u));
}
function notifyCoverReady(url: string) {
const set = readyListeners.get(url);
if (!set?.size) return;
readyListeners.delete(url);
for (const cb of set) {
try {
cb();
} catch {
/* ignore */
}
}
}
function markCoverReady(url: string) {
const u = String(url || '').trim();
if (!u || readyCoverUrls.has(u)) return;
readyCoverUrls.add(u);
notifyCoverReady(u);
}
/** 订阅封面就绪(命中缓存则同步回调);返回取消函数 */
export function subscribeRouteCoverReady(url: string, cb: () => void): () => void {
const u = String(url || '').trim();
if (!u) return () => {};
if (readyCoverUrls.has(u)) {
cb();
return () => {};
}
let set = readyListeners.get(u);
if (!set) {
set = new Set();
readyListeners.set(u, set);
}
set.add(cb);
return () => {
set?.delete(cb);
if (set && set.size === 0) readyListeners.delete(u);
};
}
function warmOneCover(url: string) {
const u = String(url || '').trim();
if (!u || typeof window === 'undefined') return;
if (readyCoverUrls.has(u)) return;
const finish = () => markCoverReady(u);
try {
const img = new Image();
img.decoding = 'async';
img.onload = finish;
img.onerror = finish;
img.src = u;
if (img.complete && img.naturalWidth > 0) finish();
} catch {
finish();
}
}
/**
* 把精选封面提前推进浏览器缓存。
* highPriorityUrl 额外挂 link rel=preload,优先中心卡。
@ -22,15 +87,8 @@ export function preloadRouteCovers(
if (typeof window === 'undefined') return;
const list = [...new Set(urls.map((u) => String(u || '').trim()).filter(Boolean))];
for (const url of list) {
if (warmedCoverUrls.has(url)) continue;
warmedCoverUrls.add(url);
try {
const img = new Image();
img.decoding = 'async';
img.src = url;
} catch {
warmedCoverUrls.delete(url);
}
if (!warmedCoverUrls.has(url)) warmedCoverUrls.add(url);
warmOneCover(url);
}
const high = opts?.highPriorityUrl?.trim();

File diff suppressed because it is too large Load Diff