Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
良好的行为成为习惯
uni-app
提交
f7094833
U
uni-app
项目概览
良好的行为成为习惯
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f7094833
编写于
1月 03, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: h5 windowTop
上级
6b30f3ed
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
137 addition
and
118 deletion
+137
-118
packages/vue-cli-plugin-uni/packages/h5-vue-style-loader/lib/addStylesClient.js
...n-uni/packages/h5-vue-style-loader/lib/addStylesClient.js
+0
-8
packages/webpack-uni-pages-loader/lib/platforms/h5.js
packages/webpack-uni-pages-loader/lib/platforms/h5.js
+17
-4
src/platforms/h5/components/page/index.vue
src/platforms/h5/components/page/index.vue
+52
-45
src/platforms/h5/components/page/pageBody.vue
src/platforms/h5/components/page/pageBody.vue
+4
-2
src/platforms/h5/components/page/pageHead.vue
src/platforms/h5/components/page/pageHead.vue
+46
-45
src/platforms/h5/components/page/transparent.js
src/platforms/h5/components/page/transparent.js
+3
-3
src/platforms/h5/helpers/get-window-offset.js
src/platforms/h5/helpers/get-window-offset.js
+6
-3
src/platforms/h5/view/bridge/subscribe/index.js
src/platforms/h5/view/bridge/subscribe/index.js
+9
-8
未找到文件。
packages/vue-cli-plugin-uni/packages/h5-vue-style-loader/lib/addStylesClient.js
浏览文件 @
f7094833
...
@@ -239,14 +239,6 @@ var VAR_WINDOW_BOTTOM = /var\(--window-bottom\)/gi
...
@@ -239,14 +239,6 @@ var VAR_WINDOW_BOTTOM = /var\(--window-bottom\)/gi
function
processCss
(
css
)
{
function
processCss
(
css
)
{
var
envMethod
=
''
envMethod
=
uni
.
canIUse
(
'
css.constant
'
)
?
'
constant
'
:
envMethod
envMethod
=
uni
.
canIUse
(
'
css.env
'
)
?
'
env
'
:
envMethod
if
(
envMethod
)
{
css
=
css
.
replace
(
VAR_STATUS_BAR_HEIGHT
,
envMethod
+
'
(safe-area-inset-top)
'
)
.
replace
(
VAR_WINDOW_TOP
,
'
calc(var(--window-top) +
'
+
envMethod
+
'
(safe-area-inset-top))
'
)
.
replace
(
VAR_WINDOW_BOTTOM
,
'
calc(var(--window-bottom) +
'
+
envMethod
+
'
(safe-area-inset-bottom))
'
)
}
var
page
=
getPage
()
var
page
=
getPage
()
if
(
!
uni
.
canIUse
(
'
css.var
'
))
{
//不支持 css 变量
if
(
!
uni
.
canIUse
(
'
css.var
'
))
{
//不支持 css 变量
var
offset
=
getWindowOffset
()
var
offset
=
getWindowOffset
()
...
...
packages/webpack-uni-pages-loader/lib/platforms/h5.js
浏览文件 @
f7094833
...
@@ -96,9 +96,22 @@ const getPageComponents = function (inputDir, pagesJson) {
...
@@ -96,9 +96,22 @@ const getPageComponents = function (inputDir, pagesJson) {
}
}
let
windowTop
=
44
let
windowTop
=
44
let
pageStyle
=
Object
.
assign
({},
globalStyle
,
props
)
const
pageStyle
=
Object
.
assign
({},
globalStyle
,
props
)
if
(
pageStyle
.
navigationStyle
===
'
custom
'
||
(
'
titleNView
'
in
pageStyle
&&
(
!
pageStyle
.
titleNView
||
pageStyle
.
titleNView
.
type
===
const
titleNViewTypeList
=
{
'
transparent
'
||
pageStyle
.
titleNView
.
type
===
'
float
'
)))
{
'
none
'
:
'
default
'
,
'
auto
'
:
'
transparent
'
,
'
always
'
:
'
float
'
}
let
titleNView
=
pageStyle
.
titleNView
titleNView
=
Object
.
assign
({},
{
type
:
pageStyle
.
navigationStyle
===
'
custom
'
?
'
none
'
:
'
default
'
},
pageStyle
.
transparentTitle
in
titleNViewTypeList
?
{
type
:
titleNViewTypeList
[
pageStyle
.
transparentTitle
],
backgroundColor
:
'
rgba(0,0,0,0)
'
}
:
null
,
typeof
titleNView
===
'
object
'
?
titleNView
:
(
typeof
titleNView
===
'
boolean
'
?
{
type
:
titleNView
?
'
default
'
:
'
none
'
}
:
null
))
if
(
titleNView
.
type
===
'
none
'
||
titleNView
.
type
===
'
transparent
'
)
{
windowTop
=
0
windowTop
=
0
}
}
...
@@ -300,7 +313,7 @@ module.exports = function (pagesJson, manifestJson) {
...
@@ -300,7 +313,7 @@ module.exports = function (pagesJson, manifestJson) {
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
const
pageComponents
=
getPageComponents
(
inputDir
,
pagesJson
)
const
pageComponents
=
getPageComponents
(
inputDir
,
pagesJson
)
pagesJson
.
globalStyle
=
process
.
UNI_H5_PAGES_JSON
.
globalStyle
pagesJson
.
globalStyle
=
process
.
UNI_H5_PAGES_JSON
.
globalStyle
delete
pagesJson
.
pages
delete
pagesJson
.
pages
delete
pagesJson
.
subPackages
delete
pagesJson
.
subPackages
...
...
src/platforms/h5/components/page/index.vue
浏览文件 @
f7094833
<
template
>
<
template
>
<uni-page
:data-page=
"$route.meta.pagePath"
>
<uni-page
:data-page=
"$route.meta.pagePath"
>
<page-head
<page-head
v-if=
"
showNavigationBar
"
v-if=
"
navigationBar.type!=='none'
"
v-bind=
"navigationBar"
/>
v-bind=
"navigationBar"
/>
<page-refresh
<page-refresh
v-if=
"enablePullDownRefresh"
v-if=
"enablePullDownRefresh"
ref=
"refresh"
ref=
"refresh"
:color=
"refreshOptions.color"
:color=
"refreshOptions.color"
:offset=
"refreshOptions.offset"
/>
:offset=
"refreshOptions.offset"
/>
<page-body
<page-body
v-if=
"enablePullDownRefresh"
v-if=
"enablePullDownRefresh"
@
touchstart.native=
"_touchstart"
@
touchstart.native=
"_touchstart"
@
touchmove.native=
"_touchmove"
@
touchmove.native=
"_touchmove"
@
touchend.native=
"_touchend"
@
touchend.native=
"_touchend"
@
touchcancel.native=
"_touchend"
>
@
touchcancel.native=
"_touchend"
>
<slot
name=
"page"
/>
<slot
name=
"page"
/>
</page-body>
</page-body>
<page-body
v-else
>
<page-body
v-else
>
...
@@ -22,11 +24,11 @@
...
@@ -22,11 +24,11 @@
</uni-page>
</uni-page>
</
template
>
</
template
>
<
style
>
<
style
>
uni-page
{
uni-page
{
display
:
block
;
display
:
block
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
}
}
</
style
>
</
style
>
<
script
>
<
script
>
import
{
import
{
...
@@ -47,6 +49,8 @@ import PageRefresh from './pageRefresh'
...
@@ -47,6 +49,8 @@ import PageRefresh from './pageRefresh'
import
pullToRefresh
from
'
./pull-to-refresh
'
import
pullToRefresh
from
'
./pull-to-refresh
'
import
safeAreaInsets
from
'
safe-area-insets
'
export
default
{
export
default
{
name
:
'
Page
'
,
name
:
'
Page
'
,
mpType
:
'
page
'
,
mpType
:
'
page
'
,
...
@@ -124,55 +128,61 @@ export default {
...
@@ -124,55 +128,61 @@ export default {
default
:
false
default
:
false
},
},
titleNView
:
{
titleNView
:
{
type
:
[
Boolean
,
Object
],
type
:
[
Boolean
,
Object
,
String
],
default
:
true
default
:
''
},
},
pullToRefresh
:
{
pullToRefresh
:
{
type
:
Object
,
type
:
Object
,
default
()
{
default
()
{
return
{}
return
{}
}
}
},
},
titleImage
:
{
titleImage
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
''
},
},
transparentTitle
:
{
transparentTitle
:
{
type
:
String
,
type
:
String
,
default
:
'
none
'
default
:
'
'
},
},
titlePenetrate
:
{
titlePenetrate
:
{
type
:
String
,
type
:
String
,
default
:
'
NO
'
default
:
'
NO
'
}
}
},
},
data
()
{
data
()
{
const
titleNViewTypeList
=
{
const
titleNViewTypeList
=
{
'
none
'
:
'
default
'
,
'
none
'
:
'
default
'
,
'
auto
'
:
'
transparent
'
,
'
auto
'
:
'
transparent
'
,
'
always
'
:
'
float
'
'
always
'
:
'
float
'
}
}
// 将 navigationStyle 和 transparentTitle 都合并到 titleNView
const
yesNoParseList
=
{
let
titleNView
=
this
.
titleNView
'
YES
'
:
true
,
titleNView
=
Object
.
assign
({},
{
'
NO
'
:
false
type
:
this
.
navigationStyle
===
'
custom
'
?
'
none
'
:
'
default
'
}
},
this
.
transparentTitle
in
titleNViewTypeList
?
{
type
:
titleNViewTypeList
[
this
.
transparentTitle
],
backgroundColor
:
'
rgba(0,0,0,0)
'
}
:
null
,
typeof
titleNView
===
'
object
'
?
titleNView
:
(
typeof
titleNView
===
'
boolean
'
?
{
type
:
titleNView
?
'
default
'
:
'
none
'
}
:
null
))
const
yesNoParseList
=
{
'
YES
'
:
true
,
'
NO
'
:
false
}
const
navigationBar
=
mergeTitleNView
({
const
navigationBar
=
mergeTitleNView
({
loading
:
false
,
loading
:
false
,
backButton
:
!
this
.
isQuit
&&
!
this
.
$route
.
meta
.
isQuit
,
// redirectTo,reLaunch时可能动态修改 meta.isQuit
backButton
:
!
this
.
isQuit
&&
!
this
.
$route
.
meta
.
isQuit
,
// redirectTo,reLaunch时可能动态修改 meta.isQuit
backgroundColor
:
this
.
navigationBarBackgroundColor
,
backgroundColor
:
this
.
navigationBarBackgroundColor
,
textColor
:
this
.
navigationBarTextStyle
===
'
black
'
?
'
#000
'
:
'
#fff
'
,
textColor
:
this
.
navigationBarTextStyle
===
'
black
'
?
'
#000
'
:
'
#fff
'
,
titleText
:
this
.
navigationBarTitleText
,
titleText
:
this
.
navigationBarTitleText
,
titleImage
:
this
.
titleImage
,
titleImage
:
this
.
titleImage
,
duration
:
'
0
'
,
duration
:
'
0
'
,
timingFunc
:
''
,
timingFunc
:
''
,
type
:
titleNViewTypeList
[
this
.
transparentTitle
],
transparentTitle
:
this
.
transparentTitle
,
titlePenetrate
:
yesNoParseList
[
this
.
titlePenetrate
]
titlePenetrate
:
yesNoParseList
[
this
.
titlePenetrate
]
},
this
.
titleNView
)
},
titleNView
)
const
showNavigationBar
=
this
.
navigationStyle
===
'
default
'
&&
this
.
titleNView
const
refreshOptions
=
Object
.
assign
({
const
refreshOptions
=
Object
.
assign
({
support
:
true
,
support
:
true
,
...
@@ -185,10 +195,8 @@ export default {
...
@@ -185,10 +195,8 @@ export default {
let
offset
=
upx2px
(
refreshOptions
.
offset
)
let
offset
=
upx2px
(
refreshOptions
.
offset
)
if
(
showNavigationBar
)
{
if
(
titleNView
.
type
!==
'
transparent
'
)
{
if
(
!
(
this
.
titleNView
&&
this
.
titleNView
.
type
===
'
transparent
'
))
{
offset
+=
NAVBAR_HEIGHT
+
safeAreaInsets
.
top
offset
+=
NAVBAR_HEIGHT
}
}
}
refreshOptions
.
offset
=
offset
refreshOptions
.
offset
=
offset
...
@@ -196,7 +204,6 @@ export default {
...
@@ -196,7 +204,6 @@ export default {
refreshOptions
.
range
=
upx2px
(
refreshOptions
.
range
)
refreshOptions
.
range
=
upx2px
(
refreshOptions
.
range
)
return
{
return
{
showNavigationBar
,
navigationBar
,
navigationBar
,
refreshOptions
refreshOptions
}
}
...
...
src/platforms/h5/components/page/pageBody.vue
浏览文件 @
f7094833
...
@@ -14,6 +14,8 @@ uni-page-wrapper {
...
@@ -14,6 +14,8 @@ uni-page-wrapper {
uni-page-head
[
uni-page-head-type
=
"default"
]
~
uni-page-wrapper
{
uni-page-head
[
uni-page-head-type
=
"default"
]
~
uni-page-wrapper
{
height
:
calc
(
100%
-
44px
);
height
:
calc
(
100%
-
44px
);
height
:
calc
(
100%
-
44px
-
constant
(
safe-area-inset-top
));
height
:
calc
(
100%
-
44px
-
env
(
safe-area-inset-top
));
}
}
.uni-app--showtabbar
uni-page-wrapper
{
.uni-app--showtabbar
uni-page-wrapper
{
...
@@ -34,8 +36,8 @@ uni-page-head[uni-page-head-type="default"] ~ uni-page-wrapper {
...
@@ -34,8 +36,8 @@ uni-page-head[uni-page-head-type="default"] ~ uni-page-wrapper {
.uni-app--showtabbar
uni-page-head
[
uni-page-head-type
=
"default"
]
~
uni-page-wrapper
{
.uni-app--showtabbar
uni-page-head
[
uni-page-head-type
=
"default"
]
~
uni-page-wrapper
{
height
:
calc
(
100%
-
44px
-
50px
);
height
:
calc
(
100%
-
44px
-
50px
);
height
:
calc
(
100%
-
44px
-
50px
-
constant
(
safe-area-inset-bottom
));
height
:
calc
(
100%
-
44px
-
constant
(
safe-area-inset-top
)
-
50px
-
constant
(
safe-area-inset-bottom
));
height
:
calc
(
100%
-
44px
-
50px
-
env
(
safe-area-inset-bottom
));
height
:
calc
(
100%
-
44px
-
env
(
safe-area-inset-top
)
-
50px
-
env
(
safe-area-inset-bottom
));
}
}
uni-page-body
{
uni-page-body
{
...
...
src/platforms/h5/components/page/pageHead.vue
浏览文件 @
f7094833
...
@@ -41,14 +41,12 @@
...
@@ -41,14 +41,12 @@
>
>
<i
<i
v-if=
"loading"
v-if=
"loading"
class=
"uni-loading"
/>
class=
"uni-loading"
/>
<img
<img
v-if=
"titleImage!==''"
v-if=
"titleImage!==''"
:src=
"titleImage"
:src=
"titleImage"
class=
"uni-page-head__title_image"
>
class=
"uni-page-head__title_image"
>
<
template
v-else
>
<
template
v-else
>
{{
titleText
}}
</
template
>
{{
titleText
}}
</
template
>
</div>
</div>
</div>
</div>
<div
<div
...
@@ -95,10 +93,11 @@
...
@@ -95,10 +93,11 @@
</
template
>
</
template
>
</div>
</div>
</div>
</div>
<div
<div
v-if=
"type!=='transparent'&&type!=='float'"
v-if=
"type!=='transparent'&&type!=='float'"
:class=
"{'uni-placeholder-titlePenetrate': titlePenetrate}"
:class=
"{'uni-placeholder-titlePenetrate': titlePenetrate}"
class=
"uni-placeholder"
/>
class=
"uni-placeholder"
/>
</uni-page-head>
</uni-page-head>
</template>
</template>
<
style
>
<
style
>
...
@@ -112,7 +111,11 @@ uni-page-head .uni-page-head {
...
@@ -112,7 +111,11 @@ uni-page-head .uni-page-head {
left
:
0
;
left
:
0
;
width
:
100%
;
width
:
100%
;
height
:
44px
;
height
:
44px
;
height
:
calc
(
44px
+
constant
(
safe-area-inset-top
));
height
:
calc
(
44px
+
env
(
safe-area-inset-top
));
padding
:
7px
3px
;
padding
:
7px
3px
;
padding-top
:
calc
(
7px
+
constant
(
safe-area-inset-top
));
padding-top
:
calc
(
7px
+
env
(
safe-area-inset-top
));
display
:
flex
;
display
:
flex
;
overflow
:
hidden
;
overflow
:
hidden
;
justify-content
:
space-between
;
justify-content
:
space-between
;
...
@@ -121,16 +124,16 @@ uni-page-head .uni-page-head {
...
@@ -121,16 +124,16 @@ uni-page-head .uni-page-head {
color
:
#fff
;
color
:
#fff
;
background-color
:
#000
;
background-color
:
#000
;
transition-property
:
all
;
transition-property
:
all
;
}
}
uni-page-head
.uni-page-head-titlePenetrate
,
uni-page-head
.uni-page-head-titlePenetrate
,
uni-page-head
.uni-page-head-titlePenetrate
.uni-page-head-bd
,
uni-page-head
.uni-page-head-titlePenetrate
.uni-page-head-bd
,
uni-page-head
.uni-page-head-titlePenetrate
.uni-page-head-bd
*
{
uni-page-head
.uni-page-head-titlePenetrate
.uni-page-head-bd
*
{
pointer-events
:
none
;
pointer-events
:
none
;
}
}
uni-page-head
.uni-page-head-titlePenetrate
*
{
uni-page-head
.uni-page-head-titlePenetrate
*
{
pointer-events
:
auto
;
pointer-events
:
auto
;
}
}
uni-page-head
.uni-page-head.uni-page-head-transparent
.uni-page-head-ft
>
div
{
uni-page-head
.uni-page-head.uni-page-head-transparent
.uni-page-head-ft
>
div
{
...
@@ -140,10 +143,12 @@ uni-page-head .uni-page-head.uni-page-head-transparent .uni-page-head-ft > div {
...
@@ -140,10 +143,12 @@ uni-page-head .uni-page-head.uni-page-head-transparent .uni-page-head-ft > div {
uni-page-head
.uni-page-head
~
.uni-placeholder
{
uni-page-head
.uni-page-head
~
.uni-placeholder
{
width
:
100%
;
width
:
100%
;
height
:
44px
;
height
:
44px
;
}
height
:
calc
(
44px
+
constant
(
safe-area-inset-top
));
height
:
calc
(
44px
+
env
(
safe-area-inset-top
));
uni-page-head
.uni-placeholder-titlePenetrate
{
}
pointer-events
:
none
;
uni-page-head
.uni-placeholder-titlePenetrate
{
pointer-events
:
none
;
}
}
uni-page-head
.uni-page-head
*
{
uni-page-head
.uni-page-head
*
{
...
@@ -288,12 +293,12 @@ uni-page-head .uni-page-head__title .uni-loading {
...
@@ -288,12 +293,12 @@ uni-page-head .uni-page-head__title .uni-loading {
width
:
16px
;
width
:
16px
;
height
:
16px
;
height
:
16px
;
margin-top
:
-3px
;
margin-top
:
-3px
;
}
}
uni-page-head
.uni-page-head__title
.uni-page-head__title_image
{
uni-page-head
.uni-page-head__title
.uni-page-head__title_image
{
width
:
auto
;
width
:
auto
;
height
:
26px
;
height
:
26px
;
vertical-align
:
middle
;
vertical-align
:
middle
;
}
}
</
style
>
</
style
>
<
script
>
<
script
>
...
@@ -321,7 +326,9 @@ export default {
...
@@ -321,7 +326,9 @@ export default {
},
},
backgroundColor
:
{
backgroundColor
:
{
type
:
String
,
type
:
String
,
default
:
'
#000
'
default
()
{
return
this
.
type
===
'
transparent
'
?
'
#000
'
:
'
#F8F8F8
'
}
},
},
textColor
:
{
textColor
:
{
type
:
String
,
type
:
String
,
...
@@ -368,20 +375,14 @@ export default {
...
@@ -368,20 +375,14 @@ export default {
default
()
{
default
()
{
return
false
return
false
}
}
},
},
titleImage
:
{
titleImage
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
''
},
},
transparentTitle
:
{
titlePenetrate
:
{
default
:
'
none
'
,
type
:
Boolean
,
validator
(
value
)
{
default
:
false
return
[
'
none
'
,
'
auto
'
,
'
always
'
].
indexOf
(
value
)
!==
-
1
}
},
titlePenetrate
:
{
type
:
Boolean
,
default
:
false
}
}
},
},
data
()
{
data
()
{
...
...
src/platforms/h5/components/page/transparent.js
浏览文件 @
f7094833
...
@@ -52,7 +52,7 @@ export default {
...
@@ -52,7 +52,7 @@ export default {
borderRadiusElemStyle
.
backgroundColor
=
`rgba(
${
rgba
}
)`
borderRadiusElemStyle
.
backgroundColor
=
`rgba(
${
rgba
}
)`
})
})
})
})
}
else
if
(
this
.
t
ransparentTitle
===
'
always
'
)
{
}
else
if
(
this
.
t
ype
===
'
float
'
)
{
const
iconElems
=
this
.
$el
.
querySelectorAll
(
'
.uni-btn-icon
'
)
const
iconElems
=
this
.
$el
.
querySelectorAll
(
'
.uni-btn-icon
'
)
const
iconElemsStyles
=
[]
const
iconElemsStyles
=
[]
for
(
let
i
=
0
;
i
<
iconElems
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
iconElems
.
length
;
i
++
)
{
...
@@ -70,13 +70,13 @@ export default {
...
@@ -70,13 +70,13 @@ export default {
},
},
computed
:
{
computed
:
{
color
()
{
color
()
{
return
this
.
type
===
'
transparent
'
||
this
.
transparentTitle
===
'
always
'
?
'
#fff
'
:
this
.
textColor
return
this
.
type
===
'
transparent
'
?
'
#fff
'
:
this
.
textColor
},
},
offset
()
{
offset
()
{
return
parseInt
(
this
.
coverage
)
return
parseInt
(
this
.
coverage
)
},
},
bgColor
()
{
bgColor
()
{
if
(
this
.
type
===
'
transparent
'
||
this
.
transparentTitle
===
'
always
'
)
{
if
(
this
.
type
===
'
transparent
'
)
{
const
{
const
{
r
,
r
,
g
,
g
,
...
...
src/platforms/h5/helpers/get-window-offset.js
浏览文件 @
f7094833
...
@@ -7,9 +7,11 @@ import safeAreaInsets from 'safe-area-insets'
...
@@ -7,9 +7,11 @@ import safeAreaInsets from 'safe-area-insets'
export
default
function
getWindowOffset
()
{
export
default
function
getWindowOffset
()
{
if
(
uni
.
canIUse
(
'
css.var
'
))
{
if
(
uni
.
canIUse
(
'
css.var
'
))
{
const
style
=
document
.
documentElement
.
style
const
style
=
document
.
documentElement
.
style
const
top
=
parseInt
((
style
.
getPropertyValue
(
'
--window-top
'
).
match
(
/
\d
+/
)
||
[
'
0
'
])[
0
])
const
bottom
=
parseInt
((
style
.
getPropertyValue
(
'
--window-bottom
'
).
match
(
/
\d
+/
)
||
[
'
0
'
])[
0
])
return
{
return
{
top
:
(
parseInt
(
style
.
getPropertyValue
(
'
--window-top
'
))
||
0
)
+
safeAreaInsets
.
top
,
top
:
top
?
(
top
+
safeAreaInsets
.
top
)
:
0
,
bottom
:
(
parseInt
(
style
.
getPropertyValue
(
'
--window-bottom
'
))
||
0
)
+
safeAreaInsets
.
bottom
bottom
:
bottom
?
(
bottom
+
safeAreaInsets
.
bottom
)
:
0
}
}
}
}
...
@@ -18,7 +20,8 @@ export default function getWindowOffset () {
...
@@ -18,7 +20,8 @@ export default function getWindowOffset () {
const
pages
=
getCurrentPages
()
const
pages
=
getCurrentPages
()
if
(
pages
.
length
)
{
if
(
pages
.
length
)
{
const
pageVm
=
pages
[
pages
.
length
-
1
].
$parent
.
$parent
const
pageVm
=
pages
[
pages
.
length
-
1
].
$parent
.
$parent
top
=
pageVm
.
showNavigationBar
&&
(
pageVm
.
navigationBar
.
type
!==
'
transparent
'
||
pageVm
.
navigationBar
.
type
!==
'
float
'
)
?
NAVBAR_HEIGHT
:
0
const
navigationBarType
=
pageVm
.
navigationBar
.
type
top
=
navigationBarType
===
'
default
'
||
navigationBarType
===
'
float
'
?
NAVBAR_HEIGHT
:
0
}
}
const
app
=
getApp
()
const
app
=
getApp
()
if
(
app
)
{
if
(
app
)
{
...
...
src/platforms/h5/view/bridge/subscribe/index.js
浏览文件 @
f7094833
...
@@ -24,11 +24,12 @@ const passiveOptions = supportsPassive ? {
...
@@ -24,11 +24,12 @@ const passiveOptions = supportsPassive ? {
function
updateCssVar
(
vm
)
{
function
updateCssVar
(
vm
)
{
if
(
uni
.
canIUse
(
'
css.var
'
))
{
if
(
uni
.
canIUse
(
'
css.var
'
))
{
const
pageVm
=
vm
.
$parent
.
$parent
const
pageVm
=
vm
.
$parent
.
$parent
const
windowTop
=
pageVm
.
showNavigationBar
&&
pageVm
.
navigationBar
.
type
!==
'
transparent
'
&&
pageVm
.
navigationBar
.
type
!==
const
navigationBarType
=
pageVm
.
navigationBar
.
type
'
float
'
?
(
NAVBAR_HEIGHT
+
const
windowTopValue
=
navigationBarType
===
'
default
'
||
navigationBarType
===
'
float
'
?
NAVBAR_HEIGHT
:
0
'
px
'
)
const
windowBottomValue
=
getApp
().
$children
[
0
].
showTabBar
?
TABBAR_HEIGHT
:
0
:
'
0px
'
const
envMethod
=
uni
.
canIUse
(
'
css.env
'
)
?
'
env
'
:
(
uni
.
canIUse
(
'
css.constant
'
)
?
'
constant
'
:
''
)
const
windowBottom
=
getApp
().
$children
[
0
].
showTabBar
?
(
TABBAR_HEIGHT
+
'
px
'
)
:
'
0px
'
const
windowTop
=
windowTopValue
&&
envMethod
?
`calc(
${
windowTopValue
}
px +
${
envMethod
}
(safe-area-inset-top))`
:
'
0px
'
const
windowBottom
=
windowBottomValue
&&
envMethod
?
`calc(
${
windowBottomValue
}
px +
${
envMethod
}
(safe-area-inset-bottom))`
:
'
0px
'
const
style
=
document
.
documentElement
.
style
const
style
=
document
.
documentElement
.
style
style
.
setProperty
(
'
--window-top
'
,
windowTop
)
style
.
setProperty
(
'
--window-top
'
,
windowTop
)
style
.
setProperty
(
'
--window-bottom
'
,
windowBottom
)
style
.
setProperty
(
'
--window-bottom
'
,
windowBottom
)
...
@@ -37,7 +38,7 @@ function updateCssVar (vm) {
...
@@ -37,7 +38,7 @@ function updateCssVar (vm) {
}
}
}
}
export
default
function
initSubscribe
(
subscribe
)
{
export
default
function
initSubscribe
(
subscribe
)
{
let
scrollListener
=
false
let
scrollListener
=
false
let
disableScrollListener
=
false
let
disableScrollListener
=
false
...
@@ -83,5 +84,5 @@ export default function initSubscribe (subscribe) {
...
@@ -83,5 +84,5 @@ export default function initSubscribe (subscribe) {
document
.
addEventListener
(
'
scroll
'
,
scrollListener
)
document
.
addEventListener
(
'
scroll
'
,
scrollListener
)
})
})
}
}
})
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录