From 0afab4b3ea801a9d011e7573b0565ec33fe38ca5 Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Thu, 21 Nov 2024 11:43:36 +0800
Subject: [PATCH] =?UTF-8?q?feat(getCurrentPages):=20=E8=A1=A5=E5=85=85=20U?=
=?UTF-8?q?niPage=20=E6=96=B9=E6=B3=95=E7=A4=BA=E4=BE=8B=E5=8F=8A=E6=B5=8B?=
=?UTF-8?q?=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../get-current-pages.test.js | 9 +++++++
.../get-current-pages/get-current-pages.uvue | 26 +++++++++++++++++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/pages/API/get-current-pages/get-current-pages.test.js b/pages/API/get-current-pages/get-current-pages.test.js
index 5e749c42..c7ac703d 100644
--- a/pages/API/get-current-pages/get-current-pages.test.js
+++ b/pages/API/get-current-pages/get-current-pages.test.js
@@ -2,6 +2,7 @@ const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
+const isWeb = platformInfo.startsWith('web')
describe('getCurrentPages', () => {
let page
@@ -100,4 +101,12 @@ describe('getCurrentPages', () => {
const res = await page.callMethod('checkGetAndroidView')
expect(res).toBe(isAndroid)
})
+ it('getIOSView', async () => {
+ const res = await page.callMethod('checkGetIOSView')
+ expect(res).toBe(false)
+ })
+ it('getHTMLElement', async () => {
+ const res = await page.callMethod('checkGetHTMLElement')
+ expect(res).toBe(isWeb)
+ })
})
diff --git a/pages/API/get-current-pages/get-current-pages.uvue b/pages/API/get-current-pages/get-current-pages.uvue
index da350afc..62a3b3ee 100644
--- a/pages/API/get-current-pages/get-current-pages.uvue
+++ b/pages/API/get-current-pages/get-current-pages.uvue
@@ -25,7 +25,13 @@
-
+
+
+
@@ -55,7 +61,7 @@
+
@@ -214,6 +220,22 @@
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
+ checkGetIOSView() : boolean {
+ const page = this.getCurrentPage()
+ const IOSView = page.getIOSView()
+ const res = IOSView != null
+ console.log('check getIOSView', res)
+ uni.showToast(res ? { title: 'check success' } : { title: '仅 IOS uts 插件环境支持', icon: 'error' })
+ return res
+ },
+ checkGetHTMLElement() : boolean {
+ const page = this.getCurrentPage()
+ const HTMLView = page.getHTMLElement()
+ const res = HTMLView != null
+ console.log('check getHTMLElement', res)
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ return res
+ },
},
}
--
GitLab