From c041c754cb32c135099aac0b6b95fdbd6251acef Mon Sep 17 00:00:00 2001 From: xiaowang Date: Tue, 24 Mar 2026 09:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=B0=86=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=AE=BD=E5=B1=8F=E5=B8=83=E5=B1=80=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/App.vue | 38 ++------------- Frontend/src/components/BottomNav.vue | 10 ++-- Frontend/src/style.css | 7 +-- Frontend/src/views/ArtistOrderView.vue | 11 ++--- Frontend/src/views/CartView.vue | 12 ++--- Frontend/src/views/CouponView.vue | 11 ++--- Frontend/src/views/HomeView.vue | 35 +++++++++++++- Frontend/src/views/OrderView.vue | 11 ++--- Frontend/src/views/ProductDetailView.vue | 20 +++++--- Frontend/src/views/ProductListView.vue | 29 +++++++++--- Frontend/src/views/ProfileView.vue | 20 +++++--- Frontend/src/views/ShopDetailView.vue | 12 ++--- ...26-03-24-Frontend宽屏适配改为响应式布局.md | 46 +++++++++++++++++++ 13 files changed, 170 insertions(+), 92 deletions(-) create mode 100644 docs/changes/2026-03-24-Frontend宽屏适配改为响应式布局.md diff --git a/Frontend/src/App.vue b/Frontend/src/App.vue index 04a9db1f..43424a10 100644 --- a/Frontend/src/App.vue +++ b/Frontend/src/App.vue @@ -4,19 +4,11 @@
-
- - - - - -
+ + + + +
@@ -40,16 +32,6 @@ const isHiddenNav = computed(() => { return result }) -const isAdminRoute = computed(() => route.matched.some(r => r.meta.isAdmin)) - -const shouldCenterUserContent = computed(() => { - if (isAdminRoute.value) { - return false - } - - return route.name !== 'auth' && route.name !== 'not-found' -}) - // 全局购物车数量状态 const cartCount = ref(0) @@ -116,16 +98,6 @@ loadCartCount() z-index: 1; } -.page-renderer { - min-height: 100%; -} - -.page-renderer.centered-user-shell > * { - width: 100%; - max-width: var(--frontend-page-max-width); - margin: 0 auto; -} - /* 当导航栏隐藏时,移除底部 padding */ .page-content.no-nav-padding { padding-bottom: 0; diff --git a/Frontend/src/components/BottomNav.vue b/Frontend/src/components/BottomNav.vue index e43efcbf..609284f1 100644 --- a/Frontend/src/components/BottomNav.vue +++ b/Frontend/src/components/BottomNav.vue @@ -113,9 +113,9 @@ const handleNavClick = (tab: string) => { .bottom-nav { position: fixed; bottom: 0; - left: 50%; - right: auto; - width: min(100%, var(--frontend-page-max-width)); + left: 0; + right: 0; + width: 100%; height: 60px; background: white; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08); @@ -126,7 +126,7 @@ const handleNavClick = (tab: string) => { overflow: hidden; backface-visibility: hidden; will-change: transform; - transform: translateX(-50%) translateZ(0); + transform: translateZ(0); transition: none !important; } @@ -136,6 +136,8 @@ const handleNavClick = (tab: string) => { align-items: center; height: 100%; width: 100%; + max-width: 560px; + margin: 0 auto; padding: 0 10px; transition: none !important; } diff --git a/Frontend/src/style.css b/Frontend/src/style.css index d96ae20a..d4817d23 100644 --- a/Frontend/src/style.css +++ b/Frontend/src/style.css @@ -6,7 +6,8 @@ --text-secondary: #999999; --border-radius-base: 10px; --border-radius-large: 30px; - --frontend-page-max-width: 480px; + --frontend-page-max-width: 1280px; + --frontend-content-max-width: 1120px; --admin-content-max-width: 1440px; } @@ -24,7 +25,7 @@ body { .mobile-container { width: 100%; - max-width: 375px; + max-width: 100%; margin: 0 auto; min-height: 100vh; background-color: var(--bg-color); @@ -32,7 +33,7 @@ body { overflow-x: hidden; } -@media (min-width: 768px) { +@media (min-width: 992px) { .mobile-container { max-width: var(--frontend-page-max-width); } diff --git a/Frontend/src/views/ArtistOrderView.vue b/Frontend/src/views/ArtistOrderView.vue index 789e8a30..3a443076 100644 --- a/Frontend/src/views/ArtistOrderView.vue +++ b/Frontend/src/views/ArtistOrderView.vue @@ -121,12 +121,11 @@ onMounted(loadOrders) .line { margin-top: 4px; color: #666; font-size: 13px; } .appointment { color: #1890ff; } -@media (min-width: 768px) { - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .content { + max-width: 980px; + margin: 0 auto; + padding: 24px; } } diff --git a/Frontend/src/views/CartView.vue b/Frontend/src/views/CartView.vue index 41b368f2..2c49b412 100644 --- a/Frontend/src/views/CartView.vue +++ b/Frontend/src/views/CartView.vue @@ -540,13 +540,11 @@ onMounted(async () => { .artist-option img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; } .time-picker { border-radius: 8px; } -@media (min-width: 768px) { - .header, - .footer { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .content { + max-width: 980px; + margin: 0 auto; + padding: 24px 24px 140px; } } diff --git a/Frontend/src/views/CouponView.vue b/Frontend/src/views/CouponView.vue index 1c075322..274badfb 100644 --- a/Frontend/src/views/CouponView.vue +++ b/Frontend/src/views/CouponView.vue @@ -284,12 +284,11 @@ onMounted(() => { color: #ff4d4f; } -@media (min-width: 768px) { - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .coupon-section { + max-width: 960px; + margin: 0 auto; + padding: 24px; } } diff --git a/Frontend/src/views/HomeView.vue b/Frontend/src/views/HomeView.vue index a1b1d25f..1a649bc5 100644 --- a/Frontend/src/views/HomeView.vue +++ b/Frontend/src/views/HomeView.vue @@ -457,7 +457,6 @@ const handleProductClick = (item: any) => { height: 100%; object-fit: cover; border-radius: 16px; - object-fit: stretch; } /* 轮播指示器样式 */ @@ -681,4 +680,38 @@ const handleProductClick = (item: any) => { color: #999; font-size: 14px; } + +@media (min-width: 992px) { + .header, + .search-section, + .section { + max-width: var(--frontend-content-max-width); + margin-left: auto; + margin-right: auto; + } + + .banner-container { + padding: 0 24px; + } + + .banner-carousel { + aspect-ratio: 16 / 6; + max-height: 340px; + } + + .horizontal-scroll { + overflow: visible; + flex-wrap: wrap; + } + + .product-card { + flex: 1 1 calc(25% - 12px); + width: calc(25% - 12px); + min-width: 180px; + } + + .product-grid { + grid-template-columns: repeat(4, minmax(0, 1fr)); + } +} diff --git a/Frontend/src/views/OrderView.vue b/Frontend/src/views/OrderView.vue index c1187a44..b4b81a5f 100644 --- a/Frontend/src/views/OrderView.vue +++ b/Frontend/src/views/OrderView.vue @@ -120,12 +120,11 @@ onMounted(loadOrders) .line { margin-top: 4px; color: #666; font-size: 13px; } .appointment { color: #1890ff; } -@media (min-width: 768px) { - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .content { + max-width: 980px; + margin: 0 auto; + padding: 24px; } } diff --git a/Frontend/src/views/ProductDetailView.vue b/Frontend/src/views/ProductDetailView.vue index f4b6e6a0..3bd562bd 100644 --- a/Frontend/src/views/ProductDetailView.vue +++ b/Frontend/src/views/ProductDetailView.vue @@ -561,12 +561,20 @@ onMounted(() => { border-radius: 22px; } -@media (min-width: 768px) { - .action-buttons { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .product-image-container, + .product-info { + max-width: 1040px; + margin: 0 auto; + } + + .product-image-container { + padding: 28px 28px 18px; + } + + .product-info { + margin-top: 0; + padding: 24px 28px 96px; } } diff --git a/Frontend/src/views/ProductListView.vue b/Frontend/src/views/ProductListView.vue index 20609ae0..4dfcd023 100644 --- a/Frontend/src/views/ProductListView.vue +++ b/Frontend/src/views/ProductListView.vue @@ -569,12 +569,29 @@ onMounted(async () => { font-size: 14px; } -@media (min-width: 768px) { - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .main-content { + min-height: calc(100vh - 60px); + height: auto; + } + + .category-sidebar { + width: 128px; + } + + .product-section { + padding: 24px; + } + + .product-grid { + grid-template-columns: repeat(3, minmax(0, 1fr)); + padding: 0; + } +} + +@media (min-width: 1280px) { + .product-grid { + grid-template-columns: repeat(4, minmax(0, 1fr)); } } diff --git a/Frontend/src/views/ProfileView.vue b/Frontend/src/views/ProfileView.vue index d60c2071..31d2e529 100644 --- a/Frontend/src/views/ProfileView.vue +++ b/Frontend/src/views/ProfileView.vue @@ -1028,13 +1028,19 @@ const loadWishlistCount = async () => { color: #8b8b9a; } -@media (min-width: 768px) { - .header-bg, - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .profile-info, + .stats-section, + .menu-section, + .logout-section, + .content-card { + max-width: 1040px; + margin-left: auto; + margin-right: auto; + } + + .content-card { + margin-bottom: 15px; } } diff --git a/Frontend/src/views/ShopDetailView.vue b/Frontend/src/views/ShopDetailView.vue index c1103707..652eee54 100644 --- a/Frontend/src/views/ShopDetailView.vue +++ b/Frontend/src/views/ShopDetailView.vue @@ -387,13 +387,11 @@ onMounted(() => { border-radius: 8px; } -@media (min-width: 768px) { - .header-bg, - .header { - width: min(100%, var(--frontend-page-max-width)); - left: 50%; - right: auto; - transform: translateX(-50%); +@media (min-width: 992px) { + .shop-content { + max-width: 1040px; + margin: 0 auto; + padding: 100px 24px 24px; } } diff --git a/docs/changes/2026-03-24-Frontend宽屏适配改为响应式布局.md b/docs/changes/2026-03-24-Frontend宽屏适配改为响应式布局.md new file mode 100644 index 00000000..60b3b93f --- /dev/null +++ b/docs/changes/2026-03-24-Frontend宽屏适配改为响应式布局.md @@ -0,0 +1,46 @@ +# 2026-03-24 Frontend 宽屏适配改为响应式布局 + +## 本次目标 + +修正上一轮电脑端宽屏适配过于“窄框居中”的问题,改为正常的响应式桌面布局:页面背景仍保持自然铺满,主要内容在宽屏下限制合理最大宽度,并按桌面断点优化排版比例。 + +## 主要改动 + +- 撤回 `App.vue` 中前台页面的统一窄壳包裹逻辑,不再把用户端页面做成居中的窄列 +- 将前台全局最大宽度调整为更自然的桌面宽度 `1280px` +- 新增前台内容区变量 `1120px`,用于首页等页面的主要内容收口 +- 底部导航恢复为全宽底栏,只把导航项内容居中,不再形成悬浮窄条 +- 首页改为真正的桌面响应式: + - 头部、搜索区、内容区在宽屏下收口 + - Banner 调整为更适合桌面的宽屏比例 + - 修正 Banner 图片被拉伸的问题 + - 精选作品区支持宽屏换行展示 + - 热门作品区宽屏下增加列数 +- 作品列表页在宽屏下增加分类栏宽度,并将作品网格扩展为 3 到 4 列 +- 购物车、订单、优惠券、店铺详情、作品详情、个人中心等页面在宽屏下增加独立内容最大宽度,但不再把固定头部硬性缩成窄条 + +## 涉及文件 + +- [App.vue](/E:/code/xiaowang/Frontend/src/App.vue) +- [style.css](/E:/code/xiaowang/Frontend/src/style.css) +- [BottomNav.vue](/E:/code/xiaowang/Frontend/src/components/BottomNav.vue) +- [HomeView.vue](/E:/code/xiaowang/Frontend/src/views/HomeView.vue) +- [ProductListView.vue](/E:/code/xiaowang/Frontend/src/views/ProductListView.vue) +- [CouponView.vue](/E:/code/xiaowang/Frontend/src/views/CouponView.vue) +- [ProfileView.vue](/E:/code/xiaowang/Frontend/src/views/ProfileView.vue) +- [CartView.vue](/E:/code/xiaowang/Frontend/src/views/CartView.vue) +- [ShopDetailView.vue](/E:/code/xiaowang/Frontend/src/views/ShopDetailView.vue) +- [ProductDetailView.vue](/E:/code/xiaowang/Frontend/src/views/ProductDetailView.vue) +- [OrderView.vue](/E:/code/xiaowang/Frontend/src/views/OrderView.vue) +- [ArtistOrderView.vue](/E:/code/xiaowang/Frontend/src/views/ArtistOrderView.vue) + +## 验证情况 + +- 执行前端构建:`npm run build` +- 构建结果通过 +- 本次无 SQL 变更 + +## 说明 + +- 本轮重点是把“电脑端最大宽度控制”改成“正常响应式桌面布局”,避免出现假手机框、窄条头部、底部导航悬浮过窄等问题 +- 后台 `AdminLayout` 的宽屏内容壳保留不变