From 1181277d499223b25ddb4938cc437672bf75cba7 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Fri, 19 Jan 2024 17:08:27 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BC=98=E5=8C=96=20webview=20?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=88=AA=E5=9B=BE=E5=AF=B9=E6=AF=94=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webview-screenshot-comparison.uvue | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue b/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue index 0ead1c6e..c25418f7 100644 --- a/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue +++ b/pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue @@ -1,6 +1,6 @@ @@ -22,37 +22,39 @@ } }, onReady() { - this.webviewContext = uni.createWebviewContext('webview-screenshot', this) + this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this) }, methods: { appendWebHeadPlaceholder() { 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'; - `) + const uniNavbar = document.querySelector('.uni-navbar'); + uniNavbar.style.paddingTop = '${state.headerHeight - 44}px'; + `) } else if (this.src.indexOf('pages/template/scroll-fold-nav/scroll-fold-nav') > -1) { this.webviewContext?.evalJS(` - const heightSeat = document.querySelector('.height-seat'); - heightSeat.style.height = '125px'; - heightSeat.style.backgroundColor = '#f0f8ff'; - const topBox = document.querySelector('.top-box'); - topBox.style.top = '35px'; - `) + const heightSeat = document.querySelector('.height-seat'); + heightSeat.style.height = '125px'; + heightSeat.style.backgroundColor = '#f0f8ff'; + const topBox = document.querySelector('.top-box'); + topBox.style.top = '35px'; + `) + } else if (this.src.indexOf('pages/template/pull-zoom-image/pull-zoom-image') > -1) { + return } else { this.webviewContext?.evalJS(` - const hasWebHeadPlaceholder = document.querySelector('.web-head-placeholder-for-screenshot-comparison'); - if (hasWebHeadPlaceholder) { - return; - } - const webHeadPlaceholder = document.createElement('div'); - webHeadPlaceholder.style.height = '${state.headerHeight - 44}px'; - webHeadPlaceholder.style.backgroundColor = '#007aff'; - webHeadPlaceholder.classList.add('web-head-placeholder-for-screenshot-comparison'); - const uniPage = document.querySelector('uni-page'); - const uniPageHead = document.querySelector('uni-page-head'); - uniPage.insertBefore(webHeadPlaceholder, uniPageHead); - `); +const hasWebHeadPlaceholder = document.querySelector('.web-head-placeholder-for-screenshot-comparison'); +if (hasWebHeadPlaceholder) { + return; +} +const webHeadPlaceholder = document.createElement('div'); +webHeadPlaceholder.style.height = '${state.headerHeight - 44}px'; +webHeadPlaceholder.style.backgroundColor = '#007aff'; +webHeadPlaceholder.classList.add('web-head-placeholder-for-screenshot-comparison'); +const uniPage = document.querySelector('uni-page'); +const uniPageHead = document.querySelector('uni-page-head'); +uniPage.insertBefore(webHeadPlaceholder, uniPageHead); +`); } }, loaded() { @@ -66,7 +68,7 @@ } -- GitLab