Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
6485d0bd
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
369
Star
3
Fork
8
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6485d0bd
编写于
1月 31, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 优化截图对比测试例
上级
5a024040
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
106 addition
and
124 deletion
+106
-124
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
...reenshot-comparison/webview-screenshot-comparison.test.js
+55
-55
pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue
...-screenshot-comparison/webview-screenshot-comparison.uvue
+1
-19
pages/webview-screenshot/webview-screenshot.test.js
pages/webview-screenshot/webview-screenshot.test.js
+49
-49
pages/webview-screenshot/webview-screenshot.uvue
pages/webview-screenshot/webview-screenshot.uvue
+1
-1
未找到文件。
pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js
浏览文件 @
6485d0bd
...
@@ -159,7 +159,7 @@ describe("shot-compare", () => {
...
@@ -159,7 +159,7 @@ describe("shot-compare", () => {
// set webview-screenshot-comparison page baseSrc
// set webview-screenshot-comparison page baseSrc
baseSrc
=
baseSrc
=
process
.
env
.
UNI_WEB_SERVICE_URL
?
`
${
process
.
env
.
UNI_WEB_SERVICE_URL
}
/#/`
:
process
.
env
.
UNI_WEB_SERVICE_URL
?
`
${
process
.
env
.
UNI_WEB_SERVICE_URL
}
/#/`
:
"
http://
192.168.31.223:5173
/#/
"
;
"
http://
test.dcloud.io/unix_h5_build/98_dev_hello-uvue
/#/
"
;
page
.
setData
({
page
.
setData
({
baseSrc
,
baseSrc
,
});
});
...
@@ -215,7 +215,7 @@ describe("shot-compare", () => {
...
@@ -215,7 +215,7 @@ describe("shot-compare", () => {
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
});
});
await
page
.
waitFor
(
30
00
);
await
page
.
waitFor
(
8
00
);
// web 端非 adb 截图时设置 offsetY 移除导航栏
// web 端非 adb 截图时设置 offsetY 移除导航栏
const
webSnapshot
=
await
program
.
screenshot
({
const
webSnapshot
=
await
program
.
screenshot
({
...
...
pages/webview-screenshot-comparison/webview-screenshot-comparison.uvue
浏览文件 @
6485d0bd
...
@@ -27,33 +27,15 @@
...
@@ -27,33 +27,15 @@
this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this)
this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this)
},
},
methods: {
methods: {
customNavigationBarPageAppendWebHeadPlaceholder() {
if (this.src.indexOf('pages/template/navbar-lite/navbar-lite') > -1) {
this.webviewContext?.evalJS(`
const uniNavbar = document.querySelector('.uni-navbar');
uniNavbar.style.paddingTop = '${this.statusBarHeight}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';
`)
}
},
loaded() {
loaded() {
this.isLoaded = true
this.isLoaded = true
this.customNavigationBarPageAppendWebHeadPlaceholder();
},
},
error(event : WebViewErrorEvent) {
error(event : WebViewErrorEvent) {
console.log('webview load error', JSON.stringify(event.detail));
console.log('webview load error', JSON.stringify(event.detail));
},
},
getWindowInfo() {
getWindowInfo() {
const res = uni.getWindowInfo();
const res = uni.getWindowInfo();
// 获取状态栏
+导航栏高度
, 供截图对比使用
// 获取状态栏, 供截图对比使用
this.statusBarHeight = res.statusBarHeight;
this.statusBarHeight = res.statusBarHeight;
},
},
getDeviceInfo: function () {
getDeviceInfo: function () {
...
...
pages/webview-screenshot/webview-screenshot.test.js
浏览文件 @
6485d0bd
...
@@ -156,7 +156,7 @@ describe("shot-compare", () => {
...
@@ -156,7 +156,7 @@ describe("shot-compare", () => {
// set webview-screenshot page baseSrc
// set webview-screenshot page baseSrc
baseSrc
=
baseSrc
=
process
.
env
.
UNI_WEB_SERVICE_URL
?
`
${
process
.
env
.
UNI_WEB_SERVICE_URL
}
/#/`
:
process
.
env
.
UNI_WEB_SERVICE_URL
?
`
${
process
.
env
.
UNI_WEB_SERVICE_URL
}
/#/`
:
"
http://
192.168.31.223:5173
/#/
"
;
"
http://
test.dcloud.io/unix_h5_build/98_dev_hello-uvue
/#/
"
;
page
.
setData
({
page
.
setData
({
baseSrc
,
baseSrc
,
});
});
...
@@ -212,7 +212,7 @@ describe("shot-compare", () => {
...
@@ -212,7 +212,7 @@ describe("shot-compare", () => {
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
const
isLoaded
=
await
page
.
data
(
"
isLoaded
"
);
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
return
isLoaded
||
Date
.
now
()
-
startTime
>
3000
;
});
});
await
page
.
waitFor
(
40
00
);
await
page
.
waitFor
(
8
00
);
// web 端非 adb 截图时设置 offsetY 移除导航栏
// web 端非 adb 截图时设置 offsetY 移除导航栏
const
webSnapshot
=
await
program
.
screenshot
({
const
webSnapshot
=
await
program
.
screenshot
({
...
...
pages/webview-screenshot/webview-screenshot.uvue
浏览文件 @
6485d0bd
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
},
},
getWindowInfo() {
getWindowInfo() {
const res = uni.getWindowInfo();
const res = uni.getWindowInfo();
// 获取状态栏
+导航栏高度
, 供截图对比使用
// 获取状态栏, 供截图对比使用
this.headerHeight = res.statusBarHeight;
this.headerHeight = res.statusBarHeight;
},
},
getDeviceInfo: function () {
getDeviceInfo: function () {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录