修复:将前端宽屏布局改为响应式
This commit is contained in:
+5
-33
@@ -4,19 +4,11 @@
|
||||
<div class="app-container">
|
||||
<BottomNav v-if="!isHiddenNav" />
|
||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||
<div
|
||||
class="page-renderer"
|
||||
:class="{
|
||||
'centered-user-shell': shouldCenterUserContent,
|
||||
'admin-renderer': isAdminRoute
|
||||
}"
|
||||
>
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="page-fade" mode="out-in">
|
||||
<component :is="Component" :key="route.path" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</div>
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="page-fade" mode="out-in">
|
||||
<component :is="Component" :key="route.path" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</div>
|
||||
</div>
|
||||
</ConfigProvider>
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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` 的宽屏内容壳保留不变
|
||||
Reference in New Issue
Block a user