From 5302af0c1a28c414c9cba2da34f18b6aca576cd4 Mon Sep 17 00:00:00 2001 From: xiaowang Date: Tue, 24 Mar 2026 09:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=AE=BD=E5=B1=8F=E6=A1=8C=E9=9D=A2=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= 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 | 9 ++ Frontend/src/views/ArtistOrderView.vue | 9 ++ Frontend/src/views/CartView.vue | 10 ++ Frontend/src/views/CouponView.vue | 11 ++- Frontend/src/views/OrderView.vue | 9 ++ Frontend/src/views/ProductDetailView.vue | 9 ++ Frontend/src/views/ProductListView.vue | 9 ++ Frontend/src/views/ProfileView.vue | 10 ++ Frontend/src/views/ShopDetailView.vue | 12 ++- Frontend/src/views/admin/AdminLayout.vue | 98 +++++++++++-------- .../2026-03-24-Frontend电脑端宽屏适配.md | 48 +++++++++ 13 files changed, 229 insertions(+), 53 deletions(-) create mode 100644 docs/changes/2026-03-24-Frontend电脑端宽屏适配.md diff --git a/Frontend/src/App.vue b/Frontend/src/App.vue index 43424a10..04a9db1f 100644 --- a/Frontend/src/App.vue +++ b/Frontend/src/App.vue @@ -4,11 +4,19 @@
- - - - - +
+ + + + + +
@@ -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; diff --git a/Frontend/src/components/BottomNav.vue b/Frontend/src/components/BottomNav.vue index c2521959..e43efcbf 100644 --- a/Frontend/src/components/BottomNav.vue +++ b/Frontend/src/components/BottomNav.vue @@ -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; } - \ No newline at end of file + diff --git a/Frontend/src/style.css b/Frontend/src/style.css index 7e35e179..d96ae20a 100644 --- a/Frontend/src/style.css +++ b/Frontend/src/style.css @@ -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); + } +} diff --git a/Frontend/src/views/ArtistOrderView.vue b/Frontend/src/views/ArtistOrderView.vue index 96098437..789e8a30 100644 --- a/Frontend/src/views/ArtistOrderView.vue +++ b/Frontend/src/views/ArtistOrderView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/CartView.vue b/Frontend/src/views/CartView.vue index 492cc0c7..41b368f2 100644 --- a/Frontend/src/views/CartView.vue +++ b/Frontend/src/views/CartView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/CouponView.vue b/Frontend/src/views/CouponView.vue index 137a9e5f..1c075322 100644 --- a/Frontend/src/views/CouponView.vue +++ b/Frontend/src/views/CouponView.vue @@ -283,4 +283,13 @@ onMounted(() => { background: #fff1f0; color: #ff4d4f; } - \ No newline at end of file + +@media (min-width: 768px) { + .header { + width: min(100%, var(--frontend-page-max-width)); + left: 50%; + right: auto; + transform: translateX(-50%); + } +} + diff --git a/Frontend/src/views/OrderView.vue b/Frontend/src/views/OrderView.vue index eb435acb..c1187a44 100644 --- a/Frontend/src/views/OrderView.vue +++ b/Frontend/src/views/OrderView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/ProductDetailView.vue b/Frontend/src/views/ProductDetailView.vue index 38af75cf..f4b6e6a0 100644 --- a/Frontend/src/views/ProductDetailView.vue +++ b/Frontend/src/views/ProductDetailView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/ProductListView.vue b/Frontend/src/views/ProductListView.vue index d25470b0..20609ae0 100644 --- a/Frontend/src/views/ProductListView.vue +++ b/Frontend/src/views/ProductListView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/ProfileView.vue b/Frontend/src/views/ProfileView.vue index be26867a..d60c2071 100644 --- a/Frontend/src/views/ProfileView.vue +++ b/Frontend/src/views/ProfileView.vue @@ -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%); + } +} diff --git a/Frontend/src/views/ShopDetailView.vue b/Frontend/src/views/ShopDetailView.vue index df4d4a63..c1103707 100644 --- a/Frontend/src/views/ShopDetailView.vue +++ b/Frontend/src/views/ShopDetailView.vue @@ -386,4 +386,14 @@ onMounted(() => { object-fit: contain; border-radius: 8px; } - \ No newline at end of file + +@media (min-width: 768px) { + .header-bg, + .header { + width: min(100%, var(--frontend-page-max-width)); + left: 50%; + right: auto; + transform: translateX(-50%); + } +} + diff --git a/Frontend/src/views/admin/AdminLayout.vue b/Frontend/src/views/admin/AdminLayout.vue index 603a3eb7..34c8142c 100644 --- a/Frontend/src/views/admin/AdminLayout.vue +++ b/Frontend/src/views/admin/AdminLayout.vue @@ -31,47 +31,51 @@ -
- - -
-
- - - - {{ userInfo?.nickname || '管理员' }} - - - - + - +
+ +
@@ -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; } diff --git a/docs/changes/2026-03-24-Frontend电脑端宽屏适配.md b/docs/changes/2026-03-24-Frontend电脑端宽屏适配.md new file mode 100644 index 00000000..dc642076 --- /dev/null +++ b/docs/changes/2026-03-24-Frontend电脑端宽屏适配.md @@ -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 页保持原有全屏展示,不强行套入居中宽屏壳 +- 本次主要处理“超宽屏不再继续横向拉伸”的问题,没有改动业务接口和数据逻辑