功能:适配前端宽屏桌面布局
This commit is contained in:
+33
-5
@@ -4,11 +4,19 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<BottomNav v-if="!isHiddenNav" />
|
<BottomNav v-if="!isHiddenNav" />
|
||||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||||
<router-view v-slot="{ Component }">
|
<div
|
||||||
<transition name="page-fade" mode="out-in">
|
class="page-renderer"
|
||||||
<component :is="Component" :key="route.path" />
|
:class="{
|
||||||
</transition>
|
'centered-user-shell': shouldCenterUserContent,
|
||||||
</router-view>
|
'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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
@@ -32,6 +40,16 @@ const isHiddenNav = computed(() => {
|
|||||||
return result
|
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)
|
const cartCount = ref(0)
|
||||||
|
|
||||||
@@ -98,6 +116,16 @@ loadCartCount()
|
|||||||
z-index: 1;
|
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 */
|
/* 当导航栏隐藏时,移除底部 padding */
|
||||||
.page-content.no-nav-padding {
|
.page-content.no-nav-padding {
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ const handleNavClick = (tab: string) => {
|
|||||||
.bottom-nav {
|
.bottom-nav {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 50%;
|
||||||
right: 0;
|
right: auto;
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
height: 60px;
|
height: 60px;
|
||||||
background: white;
|
background: white;
|
||||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
|
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
|
||||||
@@ -125,7 +126,7 @@ const handleNavClick = (tab: string) => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
backface-visibility: hidden;
|
backface-visibility: hidden;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
transform: translateZ(0);
|
transform: translateX(-50%) translateZ(0);
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +136,6 @@ const handleNavClick = (tab: string) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 600px;
|
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
@@ -182,4 +182,4 @@ const handleNavClick = (tab: string) => {
|
|||||||
.nav-item.active .nav-label {
|
.nav-item.active .nav-label {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
--text-secondary: #999999;
|
--text-secondary: #999999;
|
||||||
--border-radius-base: 10px;
|
--border-radius-base: 10px;
|
||||||
--border-radius-large: 30px;
|
--border-radius-large: 30px;
|
||||||
|
--frontend-page-max-width: 480px;
|
||||||
|
--admin-content-max-width: 1440px;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -21,6 +23,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mobile-container {
|
.mobile-container {
|
||||||
|
width: 100%;
|
||||||
max-width: 375px;
|
max-width: 375px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
@@ -28,3 +31,9 @@ body {
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.mobile-container {
|
||||||
|
max-width: var(--frontend-page-max-width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -120,4 +120,13 @@ onMounted(loadOrders)
|
|||||||
.title { font-weight: 600; }
|
.title { font-weight: 600; }
|
||||||
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
||||||
.appointment { color: #1890ff; }
|
.appointment { color: #1890ff; }
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -539,4 +539,14 @@ onMounted(async () => {
|
|||||||
.artist-option.active { border-color: #1890ff; color: #1890ff; background: #f0f9ff; }
|
.artist-option.active { border-color: #1890ff; color: #1890ff; background: #f0f9ff; }
|
||||||
.artist-option img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
|
.artist-option img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
|
||||||
.time-picker { border-radius: 8px; }
|
.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%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -283,4 +283,13 @@ onMounted(() => {
|
|||||||
background: #fff1f0;
|
background: #fff1f0;
|
||||||
color: #ff4d4f;
|
color: #ff4d4f;
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -119,4 +119,13 @@ onMounted(loadOrders)
|
|||||||
.title { font-weight: 600; }
|
.title { font-weight: 600; }
|
||||||
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
.line { margin-top: 4px; color: #666; font-size: 13px; }
|
||||||
.appointment { color: #1890ff; }
|
.appointment { color: #1890ff; }
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -560,4 +560,13 @@ onMounted(() => {
|
|||||||
height: 44px;
|
height: 44px;
|
||||||
border-radius: 22px;
|
border-radius: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.action-buttons {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -568,4 +568,13 @@ onMounted(async () => {
|
|||||||
color: #999;
|
color: #999;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1027,4 +1027,14 @@ const loadWishlistCount = async () => {
|
|||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
color: #8b8b9a;
|
color: #8b8b9a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header-bg,
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -386,4 +386,14 @@ onMounted(() => {
|
|||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.header-bg,
|
||||||
|
.header {
|
||||||
|
width: min(100%, var(--frontend-page-max-width));
|
||||||
|
left: 50%;
|
||||||
|
right: auto;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -31,47 +31,51 @@
|
|||||||
</a-layout-sider>
|
</a-layout-sider>
|
||||||
<a-layout>
|
<a-layout>
|
||||||
<a-layout-header class="header">
|
<a-layout-header class="header">
|
||||||
<div class="header-left">
|
<div class="header-shell">
|
||||||
<MenuUnfoldOutlined
|
<div class="header-left">
|
||||||
v-if="collapsed"
|
<MenuUnfoldOutlined
|
||||||
class="trigger"
|
v-if="collapsed"
|
||||||
@click="toggleCollapsed"
|
class="trigger"
|
||||||
/>
|
@click="toggleCollapsed"
|
||||||
<MenuFoldOutlined
|
/>
|
||||||
v-else
|
<MenuFoldOutlined
|
||||||
class="trigger"
|
v-else
|
||||||
@click="toggleCollapsed"
|
class="trigger"
|
||||||
/>
|
@click="toggleCollapsed"
|
||||||
</div>
|
/>
|
||||||
<div class="header-right">
|
</div>
|
||||||
<a-dropdown>
|
<div class="header-right">
|
||||||
<a class="user-dropdown" @click.prevent>
|
<a-dropdown>
|
||||||
<a-avatar :size="32" :src="userInfo?.avatar || DEFAULT_AVATAR" />
|
<a class="user-dropdown" @click.prevent>
|
||||||
<span class="username">{{ userInfo?.nickname || '管理员' }}</span>
|
<a-avatar :size="32" :src="userInfo?.avatar || DEFAULT_AVATAR" />
|
||||||
<DownOutlined />
|
<span class="username">{{ userInfo?.nickname || '管理员' }}</span>
|
||||||
</a>
|
<DownOutlined />
|
||||||
<template #overlay>
|
</a>
|
||||||
<a-menu>
|
<template #overlay>
|
||||||
<a-menu-item key="profile" @click="goToProfile">
|
<a-menu>
|
||||||
<template #icon>
|
<a-menu-item key="profile" @click="goToProfile">
|
||||||
<UserOutlined />
|
<template #icon>
|
||||||
</template>
|
<UserOutlined />
|
||||||
个人中心
|
</template>
|
||||||
</a-menu-item>
|
个人中心
|
||||||
<a-menu-divider />
|
</a-menu-item>
|
||||||
<a-menu-item key="logout" @click="handleLogout">
|
<a-menu-divider />
|
||||||
<template #icon>
|
<a-menu-item key="logout" @click="handleLogout">
|
||||||
<LogoutOutlined />
|
<template #icon>
|
||||||
</template>
|
<LogoutOutlined />
|
||||||
退出登录
|
</template>
|
||||||
</a-menu-item>
|
退出登录
|
||||||
</a-menu>
|
</a-menu-item>
|
||||||
</template>
|
</a-menu>
|
||||||
</a-dropdown>
|
</template>
|
||||||
|
</a-dropdown>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a-layout-header>
|
</a-layout-header>
|
||||||
<a-layout-content class="content">
|
<a-layout-content class="content">
|
||||||
<router-view />
|
<div class="content-shell">
|
||||||
|
<router-view />
|
||||||
|
</div>
|
||||||
</a-layout-content>
|
</a-layout-content>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
@@ -288,15 +292,21 @@ onMounted(async () => {
|
|||||||
.header {
|
.header {
|
||||||
background: white;
|
background: white;
|
||||||
padding: 0 24px;
|
padding: 0 24px;
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-shell {
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--admin-content-max-width);
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.header-left {
|
.header-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -346,6 +356,12 @@ onMounted(async () => {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content-shell {
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--admin-content-max-width);
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.admin-layout :deep(.ant-layout-sider-collapsed) + .ant-layout .content {
|
.admin-layout :deep(.ant-layout-sider-collapsed) + .ant-layout .content {
|
||||||
margin-left: 80px;
|
margin-left: 80px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# 2026-03-24 Frontend 电脑端宽屏适配
|
||||||
|
|
||||||
|
## 本次目标
|
||||||
|
|
||||||
|
为 YumiNail 前端补充电脑端宽屏适配能力,在超宽屏幕下保持主要内容居中展示,限制合理最大宽度,避免页面继续横向拉伸导致比例失衡。
|
||||||
|
|
||||||
|
## 主要改动
|
||||||
|
|
||||||
|
- 在全局样式中新增前台页面最大宽度变量 `480px`
|
||||||
|
- 在全局样式中新增后台内容区最大宽度变量 `1440px`
|
||||||
|
- `App.vue` 新增前台页面渲染壳,除登录页和 404 页外,前台页面在宽屏下自动居中
|
||||||
|
- `BottomNav.vue` 改为跟随前台主内容宽度居中,不再在桌面端横跨整屏
|
||||||
|
- 后台 `AdminLayout.vue` 为顶部栏和主内容增加统一内容壳,宽屏下保持居中且不无限变宽
|
||||||
|
- 为以下前台页面的固定头部或底部动作条补充宽屏宽度约束:
|
||||||
|
- 作品列表
|
||||||
|
- 优惠券
|
||||||
|
- 个人中心
|
||||||
|
- 购物车
|
||||||
|
- 店铺详情
|
||||||
|
- 作品详情
|
||||||
|
- 订单列表
|
||||||
|
- 美甲师订单列表
|
||||||
|
|
||||||
|
## 涉及文件
|
||||||
|
|
||||||
|
- [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)
|
||||||
|
- [AdminLayout.vue](/E:/code/xiaowang/Frontend/src/views/admin/AdminLayout.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 变更
|
||||||
|
|
||||||
|
## 说明
|
||||||
|
|
||||||
|
- 登录页和 404 页保持原有全屏展示,不强行套入居中宽屏壳
|
||||||
|
- 本次主要处理“超宽屏不再继续横向拉伸”的问题,没有改动业务接口和数据逻辑
|
||||||
Reference in New Issue
Block a user