diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 18583424864c4d1f1cf2cc068e295c3c04f5aeb9..a3438203c52d63b653ceebec8159f874a8557c2b 100644 --- a/pages/API/get-window-info/get-window-info.uvue +++ b/pages/API/get-window-info/get-window-info.uvue @@ -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]; diff --git a/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js b/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js index 72aed05c060a04850c7f264a8e805cf0a4628191..bd0c169d7554c45e04410e21d12e8f8b702db891 100644 --- a/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js +++ b/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js @@ -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, "-")}`; diff --git a/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue b/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue index bd9e698a5f13a6080f080bf1c583c3fa3302cb9e..d05d877b4425c42a6edc56a7372118a8063066fa 100644 --- a/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue +++ b/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue @@ -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(` diff --git a/store/index.uts b/store/index.uts index 0f85f420a0877c82e0f56bc244d37c9277c82aff..51718581e38026053bbd53115d28366ea63cbd51 100644 --- a/store/index.uts +++ b/store/index.uts @@ -1,19 +1,19 @@ 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) => {