From 54d5d1d871d83ee8286faf8836adab2a2150ae19 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sat, 20 Jan 2024 16:18:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E6=B5=8B=E8=AF=95=E8=AE=A1=E7=AE=97=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A0=8F=E9=AB=98=E5=BA=A6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-window-info/get-window-info.uvue | 2 +- .../webview-screenshot-comparison.test.js | 4 ++-- .../webview-screenshot-comparison.uvue | 6 +++--- store/index.uts | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 18583424..a3438203 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 72aed05c..bd0c169d 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 bd9e698a..d05d877b 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 0f85f420..51718581 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) => { -- GitLab