fix: 修复 Web 预览宽度及底部操作栏对齐
This commit is contained in:
1 parent
7e8fc01fba
commit
e5a1a60eee
3 files changed
+52
-7
No files matched your search
+13
-7
@@ -35,21 +35,27 @@ image {
|
||||
border-bottom: 1px solid #eee;
|
||||
font-size: 22px;
|
||||
}
|
||||
@media (min-width: 600px) {
|
||||
/* postcss-pxtransform disable */
|
||||
@media (min-width: 430px) {
|
||||
html {
|
||||
font-size: 22.933333px !important;
|
||||
background: #e7e5e4;
|
||||
}
|
||||
body {
|
||||
max-width: 430px;
|
||||
margin: 0 auto;
|
||||
background: #e7e5e4;
|
||||
}
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
background: #fafaf9;
|
||||
}
|
||||
}
|
||||
/* postcss-pxtransform disable */
|
||||
@media (min-width: 600px) {
|
||||
html {
|
||||
font-size: 22.933333px !important;
|
||||
.taro-tabbar__tabbar,
|
||||
.food-detail .bar,
|
||||
.editorial-detail .bar {
|
||||
width: 430px;
|
||||
left: 50%;
|
||||
right: auto;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
/* postcss-pxtransform enable */
|
||||
@@ -79,3 +79,38 @@ test("林境模板使用真实品牌数据与独立路由", async ({ page }) =>
|
||||
});
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
for (const width of [375, 430, 768, 1280]) {
|
||||
test(`预览宽度 ${width}:页面与导航对齐且无横向溢出`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.goto("/");
|
||||
await expect(page.locator(".food-home .name")).toBeVisible();
|
||||
const expectedWidth = Math.min(width, 430);
|
||||
const bounds = await page.evaluate(() => {
|
||||
const rect = (selector: string) => {
|
||||
const box = document.querySelector(selector)!.getBoundingClientRect();
|
||||
return { width: box.width, left: box.left };
|
||||
};
|
||||
return {
|
||||
page: rect(".food-home .page"),
|
||||
tab: rect(".taro-tabbar__tabbar"),
|
||||
overflow: document.documentElement.scrollWidth > window.innerWidth,
|
||||
};
|
||||
});
|
||||
expect(bounds.page.width).toBeCloseTo(expectedWidth, 0);
|
||||
expect(bounds.tab.width).toBeCloseTo(expectedWidth, 0);
|
||||
expect(bounds.tab.left).toBeCloseTo(bounds.page.left, 0);
|
||||
expect(bounds.overflow).toBe(false);
|
||||
await page.goto("/#/pages/offerings/index");
|
||||
await page.locator(".offering-card").first().click();
|
||||
await expect(page.locator(".bar")).toBeVisible();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const bar = await page.locator(".bar").boundingBox();
|
||||
return Math.abs(bar!.x - (width - expectedWidth) / 2);
|
||||
})
|
||||
.toBeLessThan(1);
|
||||
const bar = await page.locator(".bar").boundingBox();
|
||||
expect(bar!.width).toBeCloseTo(expectedWidth, 0);
|
||||
});
|
||||
}
|
||||
@@ -29,3 +29,7 @@ Web 未接入微信身份登录,没有已有会话时仅支持填写与校验
|
||||
## 切换
|
||||
|
||||
先由用户浏览新分支预览并确认,之后才切换主工作区或合并。旧 `template:dev` 和原生产配置继续作为回滚基线。
|
||||
|
||||
## Web 预览宽度
|
||||
|
||||
手机小于 430px 时使用屏幕宽度;更宽屏幕使用居中的 430px 内容区。预览外框使用真实 CSS 像素并锁定对应 rem 基准,避免被 Taro 设计稿单位转换二次缩放。底部导航和详情操作栏与内容区对齐。响应式浏览器测试覆盖 375、430、768、1280px;包括原有交互共 9 项通过。
|
||||
Reference in new issue
Block a user