提交 54d5d1d8 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

chore: 优化截图对比测试计算状态栏高度逻辑

上级 d3404d85
......@@ -40,7 +40,7 @@
getWindowInfo: function () {
const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用
setHeaderHeight(res.screenHeight - res.windowHeight);
setStatusBarHeight(res.statusBarHeight);
this.items = [] as Item[];
for (const key in res) {
const value = res[key];
......
......@@ -269,7 +269,7 @@ describe("shot-compare", () => {
const isNeedAdbScreenshot = needAdbScreenshot(pages[pageIndex]);
const isCustomNavigationBar = customNavigationPages.includes(pages[pageIndex]);
const {
headerHeight,
statusBarHeight,
devicePixelRatio
} = await page.data();
const screenshotParams = {
......@@ -278,7 +278,7 @@ describe("shot-compare", () => {
// adb 截图时跳过状态栏
area: {
x: 0,
y: (headerHeight - 44) * devicePixelRatio,
y: statusBarHeight * devicePixelRatio,
},
}
const screenshotPath = `__webview__${pages[pageIndex].replace(/\//g, "-")}`;
......
......@@ -15,11 +15,11 @@
src: '',
webviewContext: null as WebviewContext | null,
isLoaded: false,
headerHeight: state.headerHeight,
statusBarHeight: state.statusBarHeight,
isCustomNavigationBar: false,
placeholderStyle: {
display: 'block',
height: `${state.headerHeight - 44}px`,
height: `${state.statusBarHeight}px`,
backgroundColor: '#007aff'
},
devicePixelRatio: state.devicePixelRatio,
......@@ -36,7 +36,7 @@
if (this.src.indexOf('pages/template/navbar-lite/navbar-lite') > -1) {
this.webviewContext?.evalJS(`
const uniNavbar = document.querySelector('.uni-navbar');
uniNavbar.style.paddingTop = '${state.headerHeight - 44}px';
uniNavbar.style.paddingTop = '${state.statusBarHeight}px';
`)
} else if (this.src.indexOf('pages/template/scroll-fold-nav/scroll-fold-nav') > -1) {
this.webviewContext?.evalJS(`
......
type State = {
lifeCycleNum : number,
// 状态栏 + 导航栏高度
headerHeight : number,
// 状态栏高度
statusBarHeight : number,
// 设备像素比
devicePixelRatio : number
}
export const state = reactive({ lifeCycleNum: 0, headerHeight: 0, devicePixelRatio: 1 } as State)
export const state = reactive({ lifeCycleNum: 0, statusBarHeight: 0, devicePixelRatio: 1 } as State)
export const setLifeCycleNum = (num : number) => {
state.lifeCycleNum = num
}
export const setHeaderHeight = (height : number) => {
state.headerHeight = height
export const setStatusBarHeight = (height : number) => {
state.statusBarHeight = height
}
export const setDevicePixelRatio = (devicePixelRatio : number) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册