merge(main): 同步主站最新 UI 与审核优化代码并保持分销多租户隔离

This commit is contained in:
yml2213
2026-09-07 17:37:31 +08:00
51 changed files with 11152 additions and 4950 deletions
+198 -126
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { RouterLink, onBeforeRouteLeave, useRoute, useRouter } from 'vue-router'
import { usePcHomeCacheStore } from '@/stores/pcHomeCache'
import {
defaultAWRecycleConfig,
defaultCooperationFeedbackConfig,
@@ -36,7 +37,6 @@ import {
import { useListingQuery } from '@/features/listings/composables/useListingQuery'
import HomeAnnouncement from '../components/HomeAnnouncement.vue'
import HomeBanner from '../components/HomeBanner.vue'
import HomeStats from '../components/HomeStats.vue'
import HomeFilters from '../components/HomeFilters.vue'
import HomeZones from '../components/HomeZones.vue'
import ListingCard from '../components/ListingCard.vue'
@@ -96,6 +96,8 @@ const {
hasMoreListings,
loadListingsPage,
zoneCount,
restoreSnapshot,
getSnapshot,
} = useListingQuery(filters, sortBy, activeZone)
watch(
@@ -182,6 +184,7 @@ async function loadHome() {
publishOptions.value = emptyListingPublishOptions
} finally {
loading.value = false
saveToCache()
restorePcHomeScroll()
}
}
@@ -303,65 +306,118 @@ function buildDesktopHomeQueryValues(): Record<string, HomeQueryValue> {
}
}
// ========== PC 首页滚动位置持久化 ==========
// 详情页返回/浏览器后退时,首页列表异步加载导致页面高度不足,
// vue-router 的 savedPosition 恢复会被浏览器钳制到错误位置,
// 因此按「筛选签名」显式保存/恢复滚动位置,确保回到上次筛选的位置。
// ========== PC 首页状态与滚动持久化 ==========
// 详情页返回/浏览器后退时,利用 Pinia 缓存同步恢复全部已加载列表与高度,
// 使首帧渲染即可完成完整布局,结合 instant 滚动定位彻底解决「从顶部闪跳」问题。
const pcHomeScrollStorageKey = 'hfb.home.scroll.desktop'
const pcHomeCache = usePcHomeCacheStore()
function restoreFromCache(): boolean {
const signature = desktopHomeStateSignature()
if (!pcHomeCache.matchList(signature)) return false
restoreSnapshot({
listings: pcHomeCache.listings,
totalListings: pcHomeCache.totalListings,
zoneCounts: pcHomeCache.zoneCounts,
currentPage: pcHomeCache.currentPage,
hasMoreListings: pcHomeCache.hasMoreListings,
})
if (pcHomeCache.homeConfigLoaded) {
announcements.value = pcHomeCache.announcements.slice()
banners.value = pcHomeCache.banners.map(slide => ({ ...slide }))
awRecycle.value = { ...pcHomeCache.awRecycle }
cooperationFeedback.value = { ...pcHomeCache.cooperationFeedback }
publishOptions.value = pcHomeCache.publishOptions
}
return true
}
function saveToCache() {
const snapshot = getSnapshot()
if (snapshot.listings.length === 0) return
pcHomeCache.saveList({
signature: desktopHomeStateSignature(),
listings: snapshot.listings,
totalListings: snapshot.totalListings,
zoneCounts: snapshot.zoneCounts,
currentPage: snapshot.currentPage,
hasMoreListings: snapshot.hasMoreListings,
})
pcHomeCache.saveHomeConfig({
announcements: announcements.value,
banners: banners.value,
awRecycle: awRecycle.value,
cooperationFeedback: cooperationFeedback.value,
publishOptions: publishOptions.value,
})
pcHomeCache.saveScrollTop(window.scrollY)
}
function savePcHomeScroll() {
saveToCache()
try {
window.sessionStorage.setItem(
pcHomeScrollStorageKey,
JSON.stringify({ signature: desktopHomeStateSignature(), top: window.scrollY })
)
} catch {
// sessionStorage 不可用时忽略,仅损失滚动恢复
// sessionStorage 不可用时忽略
}
}
function restorePcHomeScroll() {
let savedTop = 0
let savedSignature = ''
try {
const raw = window.sessionStorage.getItem(pcHomeScrollStorageKey)
if (raw) {
const parsed = JSON.parse(raw) as { signature?: string; top?: number }
if (typeof parsed.signature === 'string' && typeof parsed.top === 'number') {
savedSignature = parsed.signature
savedTop = parsed.top
let savedTop = pcHomeCache.scrollTop
let savedSignature = pcHomeCache.listSignature
if (savedTop <= 0) {
try {
const raw = window.sessionStorage.getItem(pcHomeScrollStorageKey)
if (raw) {
const parsed = JSON.parse(raw) as { signature?: string; top?: number }
if (typeof parsed.signature === 'string' && typeof parsed.top === 'number') {
savedSignature = parsed.signature
savedTop = parsed.top
}
}
}
} catch {
return
}
// 仅当返回时的筛选条件与离开时一致才恢复,避免把滚动带到别的筛选结果上
if (savedTop <= 0 || savedSignature !== desktopHomeStateSignature()) return
let attempts = 0
const apply = () => {
const maxTop = Math.max(0, document.documentElement.scrollHeight - window.innerHeight)
if (savedTop <= maxTop) {
window.scrollTo({ top: savedTop })
} catch {
return
}
// 首页无限滚动分页:已渲染高度不足时继续加载一页后重试,尽量恢复到位
if (attempts < 5 && hasMoreListings.value && !loadingMore.value) {
attempts += 1
void loadListingsPage(false).then(() => requestAnimationFrame(apply))
} else {
window.scrollTo({ top: maxTop })
}
}
if (savedTop <= 0 || savedSignature !== desktopHomeStateSignature()) return
const apply = () => {
window.scrollTo({ top: savedTop, behavior: 'instant' })
}
apply()
requestAnimationFrame(apply)
}
function handleScroll() {
if (window.scrollY > 0) {
pcHomeCache.saveScrollTop(window.scrollY)
}
}
onMounted(() => {
window.addEventListener('scroll', handleScroll, { passive: true })
if (restored) {
restorePcHomeScroll()
}
})
onBeforeUnmount(() => {
window.removeEventListener('scroll', handleScroll)
})
onBeforeRouteLeave(() => {
savePcHomeScroll()
})
syncHomeQuery()
loadHome()
const restored = restoreFromCache()
if (!restored) {
loadHome()
}
</script>
<template>
@@ -407,18 +463,23 @@ loadHome()
</div>
<div class="hero-section">
<HomeBanner :banners="banners" />
<HomeStats :stats="statCards" />
<HomeBanner :banners="banners" :stats="statCards" />
</div>
<div class="biz-entry-grid" aria-label="业务入口">
<RouterLink class="biz-entry" to="/">
<strong>租号大厅</strong>
<small>高哈夫币 · 安全交接 · 随租随玩</small>
<div class="biz-title-row">
<strong>租号大厅</strong>
<small>安全交接 · 随租随玩</small>
</div>
<van-icon name="arrow" :size="12" class="biz-arrow" />
</RouterLink>
<RouterLink v-if="!siteStore.isDistribution" class="biz-entry crash" to="/crash">
<strong>撞车 <em>NEW</em></strong>
<small>选购商品 · 支付后进群联系客服</small>
<div class="biz-title-row">
<strong>撞车 <em>NEW</em></strong>
<small>选购商品 · 进群交接</small>
</div>
<van-icon name="arrow" :size="12" class="biz-arrow" />
</RouterLink>
<button
v-if="awRecycle.enabled"
@@ -426,8 +487,11 @@ loadHome()
class="biz-entry aw-recycle"
@click="openAWRecycle"
>
<strong>{{ awRecycle.title }}</strong>
<small>{{ awRecycle.subtitle }}</small>
<div class="biz-title-row">
<strong>{{ awRecycle.title }}</strong>
<small>{{ awRecycle.subtitle }}</small>
</div>
<van-icon name="arrow" :size="12" class="biz-arrow" />
</button>
<button
v-if="cooperationFeedback.enabled"
@@ -435,8 +499,11 @@ loadHome()
class="biz-entry cooperation-feedback"
@click="openCooperationFeedback"
>
<strong>{{ cooperationFeedback.title }}</strong>
<small>{{ cooperationFeedback.subtitle }}</small>
<div class="biz-title-row">
<strong>{{ cooperationFeedback.title }}</strong>
<small>{{ cooperationFeedback.subtitle }}</small>
</div>
<van-icon name="arrow" :size="12" class="biz-arrow" />
</button>
</div>
@@ -493,11 +560,13 @@ loadHome()
@reset="handleResetFilters"
/>
<div class="list-head">
<div class="zone-head">
<p class="eyebrow">Account Zone</p>
<h2>账号专区</h2>
</div>
<!-- 专区与排序合并为同一行极简操作条 -->
<div class="list-control-bar">
<HomeZones
:zones="zoneOptions"
:active-zone="activeZone"
@update:active-zone="activeZone = $event"
/>
<div class="list-actions sort-bar" role="group" aria-label="排序方式">
<button
v-for="item in sortOptions"
@@ -512,12 +581,6 @@ loadHome()
</div>
</div>
<HomeZones
:zones="zoneOptions"
:active-zone="activeZone"
@update:active-zone="activeZone = $event"
/>
<div v-if="!loading && listings.length === 0" class="home-empty-state">
<strong>没有符合条件的账号</strong>
<span>可以放宽筛选条件或切回全部专区。</span>
@@ -538,7 +601,7 @@ loadHome()
<style scoped>
.pc-home-redesign {
display: grid;
gap: 20px;
gap: 12px;
width: 100%;
max-width: 1720px;
min-width: 0;
@@ -548,7 +611,12 @@ loadHome()
.home-content {
display: grid;
gap: 20px;
gap: 12px;
min-width: 0;
}
.hero-section {
width: 100%;
min-width: 0;
}
@@ -560,54 +628,85 @@ loadHome()
.biz-entry {
display: flex;
flex-direction: column;
gap: 6px;
padding: 16px 18px;
border-radius: 14px;
border: 1px solid #eef1f5;
background: #fff;
align-items: center;
justify-content: space-between;
gap: 10px;
min-height: 52px;
padding: 12px 18px;
border-radius: 12px;
border: 1px solid #e2e8f0;
background: #ffffff;
text-decoration: none;
text-align: left;
cursor: pointer;
font: inherit;
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
transition:
border-color 0.18s ease,
box-shadow 0.18s ease;
border-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease;
}
.biz-entry:hover {
border-color: #ffd4b0;
border-color: #ffbe98;
box-shadow: 0 6px 16px rgba(255, 106, 0, 0.08);
transform: translateY(-2px);
}
.biz-title-row {
display: flex;
align-items: baseline;
gap: 10px;
min-width: 0;
}
.biz-entry strong {
color: #17233d;
font-size: 16px;
color: #0f172a;
font-size: 15px;
font-weight: 700;
letter-spacing: -0.01em;
white-space: nowrap;
}
.biz-entry small {
color: #7b8798;
font-size: 13px;
color: #64748b;
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.biz-arrow {
color: #94a3b8;
flex-shrink: 0;
transition:
transform 0.2s ease,
color 0.2s ease;
}
.biz-entry:hover .biz-arrow {
color: #ff6a00;
transform: translateX(2px);
}
.biz-entry.crash strong em {
margin-left: 6px;
padding: 1px 6px;
padding: 2px 6px;
border-radius: 999px;
background: #ff6a00;
color: #fff;
font-size: 11px;
font-size: 10px;
font-style: normal;
font-weight: 700;
}
.biz-entry.aw-recycle {
border-color: #e8edff;
background: linear-gradient(135deg, #ffffff 0%, #f5f8ff 100%);
border-color: #e0e7ff;
background: linear-gradient(135deg, #ffffff 0%, #f6f8fe 100%);
}
.biz-entry.cooperation-feedback {
border-color: #d9f0e5;
background: linear-gradient(135deg, #ffffff 0%, #f1fbf6 100%);
border-color: #ccfbf1;
background: linear-gradient(135deg, #ffffff 0%, #f0fdf9 100%);
}
:deep(.aw-recycle-image) {
@@ -621,74 +720,47 @@ loadHome()
@media (max-width: 960px) {
.biz-entry-grid {
grid-template-columns: 1fr;
grid-template-columns: repeat(2, 1fr);
}
}
.infinite-load-state {
padding: 6px 0 18px;
padding: 12px 0 24px;
color: #94a3b8;
font-size: 13px;
font-weight: 700;
font-weight: 600;
text-align: center;
}
.hero-section {
display: grid;
grid-template-columns: minmax(0, 1fr) 320px;
gap: 20px;
min-width: 0;
}
.list-head {
/* 专区与排序单行交互条 */
.list-control-bar {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 16px;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.zone-head {
display: flex;
flex-direction: column;
gap: 4px;
}
.eyebrow {
margin: 0;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.1em;
color: #ff6a00;
}
.zone-head h2 {
margin: 0;
font-size: 28px;
font-weight: 900;
color: #17233d;
padding: 2px 0;
}
.sort-bar {
display: inline-flex;
flex-wrap: wrap;
gap: 8px;
gap: 4px;
align-items: center;
padding: 4px;
border-radius: 12px;
background: #f3f5f9;
padding: 3px;
border-radius: 10px;
background: #f1f5f9;
}
.sort-chip {
min-height: 32px;
padding: 0 14px;
min-height: 28px;
padding: 0 12px;
border: none;
border-radius: 9px;
border-radius: 8px;
background: transparent;
color: #64748b;
font-size: 13px;
font-weight: 700;
font-size: 12px;
font-weight: 600;
cursor: pointer;
transition:
background 0.15s ease,
@@ -697,14 +769,14 @@ loadHome()
}
.sort-chip:hover {
color: #334155;
background: rgba(255, 255, 255, 0.7);
color: #0f172a;
background: rgba(255, 255, 255, 0.8);
}
.sort-chip.active {
background: #ffffff;
color: #ff6a00;
box-shadow: 0 1px 4px rgba(23, 35, 61, 0.08);
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.enhanced-desktop-list {