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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user