功能:适配前端宽屏桌面布局

This commit is contained in:
xiaowang
2026-03-24 09:50:55 +08:00
parent 8043f13ea9
commit 5302af0c1a
13 changed files with 229 additions and 53 deletions
+33 -5
View File
@@ -4,11 +4,19 @@
<div class="app-container">
<BottomNav v-if="!isHiddenNav" />
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
<router-view v-slot="{ Component }">
<transition name="page-fade" mode="out-in">
<component :is="Component" :key="route.path" />
</transition>
</router-view>
<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>
</div>
</div>
</ConfigProvider>
@@ -32,6 +40,16 @@ 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)
@@ -98,6 +116,16 @@ 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;
+5 -5
View File
@@ -113,8 +113,9 @@ const handleNavClick = (tab: string) => {
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
left: 50%;
right: auto;
width: min(100%, var(--frontend-page-max-width));
height: 60px;
background: white;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
@@ -125,7 +126,7 @@ const handleNavClick = (tab: string) => {
overflow: hidden;
backface-visibility: hidden;
will-change: transform;
transform: translateZ(0);
transform: translateX(-50%) translateZ(0);
transition: none !important;
}
@@ -135,7 +136,6 @@ const handleNavClick = (tab: string) => {
align-items: center;
height: 100%;
width: 100%;
max-width: 600px;
padding: 0 10px;
transition: none !important;
}
@@ -182,4 +182,4 @@ const handleNavClick = (tab: string) => {
.nav-item.active .nav-label {
font-weight: 600;
}
</style>
</style>
+9
View File
@@ -6,6 +6,8 @@
--text-secondary: #999999;
--border-radius-base: 10px;
--border-radius-large: 30px;
--frontend-page-max-width: 480px;
--admin-content-max-width: 1440px;
}
* {
@@ -21,6 +23,7 @@ body {
}
.mobile-container {
width: 100%;
max-width: 375px;
margin: 0 auto;
min-height: 100vh;
@@ -28,3 +31,9 @@ body {
position: relative;
overflow-x: hidden;
}
@media (min-width: 768px) {
.mobile-container {
max-width: var(--frontend-page-max-width);
}
}
+9
View File
@@ -120,4 +120,13 @@ onMounted(loadOrders)
.title { font-weight: 600; }
.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%);
}
}
</style>
+10
View File
@@ -539,4 +539,14 @@ onMounted(async () => {
.artist-option.active { border-color: #1890ff; color: #1890ff; background: #f0f9ff; }
.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%);
}
}
</style>
+10 -1
View File
@@ -283,4 +283,13 @@ onMounted(() => {
background: #fff1f0;
color: #ff4d4f;
}
</style>
@media (min-width: 768px) {
.header {
width: min(100%, var(--frontend-page-max-width));
left: 50%;
right: auto;
transform: translateX(-50%);
}
}
</style>
+9
View File
@@ -119,4 +119,13 @@ onMounted(loadOrders)
.title { font-weight: 600; }
.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%);
}
}
</style>
+9
View File
@@ -560,4 +560,13 @@ onMounted(() => {
height: 44px;
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>
+9
View File
@@ -568,4 +568,13 @@ onMounted(async () => {
color: #999;
font-size: 14px;
}
@media (min-width: 768px) {
.header {
width: min(100%, var(--frontend-page-max-width));
left: 50%;
right: auto;
transform: translateX(-50%);
}
}
</style>
+10
View File
@@ -1027,4 +1027,14 @@ const loadWishlistCount = async () => {
background: #f5f5f5;
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>
+11 -1
View File
@@ -386,4 +386,14 @@ onMounted(() => {
object-fit: contain;
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>
+57 -41
View File
@@ -31,47 +31,51 @@
</a-layout-sider>
<a-layout>
<a-layout-header class="header">
<div class="header-left">
<MenuUnfoldOutlined
v-if="collapsed"
class="trigger"
@click="toggleCollapsed"
/>
<MenuFoldOutlined
v-else
class="trigger"
@click="toggleCollapsed"
/>
</div>
<div class="header-right">
<a-dropdown>
<a class="user-dropdown" @click.prevent>
<a-avatar :size="32" :src="userInfo?.avatar || DEFAULT_AVATAR" />
<span class="username">{{ userInfo?.nickname || '管理员' }}</span>
<DownOutlined />
</a>
<template #overlay>
<a-menu>
<a-menu-item key="profile" @click="goToProfile">
<template #icon>
<UserOutlined />
</template>
个人中心
</a-menu-item>
<a-menu-divider />
<a-menu-item key="logout" @click="handleLogout">
<template #icon>
<LogoutOutlined />
</template>
退出登录
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
<div class="header-shell">
<div class="header-left">
<MenuUnfoldOutlined
v-if="collapsed"
class="trigger"
@click="toggleCollapsed"
/>
<MenuFoldOutlined
v-else
class="trigger"
@click="toggleCollapsed"
/>
</div>
<div class="header-right">
<a-dropdown>
<a class="user-dropdown" @click.prevent>
<a-avatar :size="32" :src="userInfo?.avatar || DEFAULT_AVATAR" />
<span class="username">{{ userInfo?.nickname || '管理员' }}</span>
<DownOutlined />
</a>
<template #overlay>
<a-menu>
<a-menu-item key="profile" @click="goToProfile">
<template #icon>
<UserOutlined />
</template>
个人中心
</a-menu-item>
<a-menu-divider />
<a-menu-item key="logout" @click="handleLogout">
<template #icon>
<LogoutOutlined />
</template>
退出登录
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</div>
</div>
</a-layout-header>
<a-layout-content class="content">
<router-view />
<div class="content-shell">
<router-view />
</div>
</a-layout-content>
</a-layout>
</a-layout>
@@ -288,15 +292,21 @@ onMounted(async () => {
.header {
background: white;
padding: 0 24px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
position: sticky;
top: 0;
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 {
display: flex;
align-items: center;
@@ -346,6 +356,12 @@ onMounted(async () => {
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 {
margin-left: 80px;
}