提交 3f7a430e 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into dev

...@@ -154,9 +154,7 @@ const PLATFORMS = { ...@@ -154,9 +154,7 @@ const PLATFORMS = {
megalo: false, megalo: false,
filterTag: 'wxs', filterTag: 'wxs',
subPackages: false, subPackages: false,
cssVars: { cssVars: {},
'--window-top': '0px'
},
copyWebpackOptions ({ copyWebpackOptions ({
assetsDir, assetsDir,
vueOptions vueOptions
......
...@@ -19,7 +19,7 @@ function hasOwn (obj, key) { ...@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key) return hasOwnProperty.call(obj, key)
} }
function noop () { } function noop () {}
/** /**
* Create a cached version of a pure function. * Create a cached version of a pure function.
...@@ -385,11 +385,28 @@ var previewImage = { ...@@ -385,11 +385,28 @@ var previewImage = {
} }
}; };
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
const protocols = { const protocols = {
previewImage previewImage,
getSystemInfo: {
returnValue: addSafeAreaInsets
},
getSystemInfoSync: {
returnValue: addSafeAreaInsets
}
}; };
const todos = [ const todos = [
'vibrate' 'vibrate'
]; ];
const canIUses = []; const canIUses = [];
......
...@@ -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()
......
...@@ -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
......
import { import {
callApiSync, callApiSync,
isTabBarPage, isTabBarPage,
getLastWebview getLastWebview,
getStatusbarHeight,
getScreenInfo
} from '../util' } from '../util'
import { import {
...@@ -17,48 +19,55 @@ export function getSystemInfoSync () { ...@@ -17,48 +19,55 @@ export function getSystemInfoSync () {
export function getSystemInfo () { export function getSystemInfo () {
const platform = plus.os.name.toLowerCase() const platform = plus.os.name.toLowerCase()
const ios = platform === 'ios' const ios = platform === 'ios'
// 安卓 plus 接口获取的屏幕大小值不为整数,iOS js 获取的屏幕大小横屏时颠倒 const {
const screenWidth = plus.screen.resolutionWidth screenWidth,
const screenHeight = plus.screen.resolutionHeight screenHeight
// 横屏时 iOS 获取的状态栏高度错误,进行纠正 } = getScreenInfo()
var landscape = Math.abs(plus.navigator.getOrientation()) === 90 const statusBarHeight = getStatusbarHeight()
var statusBarHeight = Math.round(plus.navigator.getStatusbarHeight())
if (ios && landscape) { let safeAreaInsets
statusBarHeight = Math.min(20, statusBarHeight) const titleNView = {
} height: 0,
var safeAreaInsets cover: false
function getSafeAreaInsets () {
return {
left: 0,
right: 0,
top: titleNView ? 0 : statusBarHeight,
bottom: 0
}
} }
// 判断是否存在 titleNView const webview = getLastWebview()
var titleNView
var webview = getLastWebview()
if (webview) { if (webview) {
let style = webview.getStyle() let style = webview.getStyle()
if (style) { style = style && style.titleNView
titleNView = style && style.titleNView if (style && style.type && style.type !== 'none') {
titleNView = titleNView && titleNView.type === 'default' titleNView.height = style.type === 'transparent' ? 0 : (statusBarHeight + TITLEBAR_HEIGHT)
titleNView.cover = style.type === 'transparent' || style.type === 'float'
} }
safeAreaInsets = ios ? webview.getSafeAreaInsets() : getSafeAreaInsets() safeAreaInsets = webview.getSafeAreaInsets()
} else { } else {
safeAreaInsets = ios ? plus.navigator.getSafeAreaInsets() : getSafeAreaInsets() safeAreaInsets = plus.navigator.getSafeAreaInsets()
} }
var windowBottom = isTabBarPage() && tabBar.visible && tabBar.cover ? tabBar.height : 0 const tabBarView = {
var windowHeight = Math.min(screenHeight - (titleNView ? (statusBarHeight + TITLEBAR_HEIGHT) height: 0,
: 0) - windowBottom, screenHeight) cover: false
var windowWidth = screenWidth }
var safeArea = { if (isTabBarPage()) {
tabBarView.height = tabBar.visible ? tabBar.height : 0
tabBarView.cover = tabBar.cover
}
const windowTop = titleNView.cover ? titleNView.height : 0
const windowBottom = tabBarView.cover ? tabBarView.height : 0
const windowHeight = screenHeight - titleNView.height - tabBarView.height
const windowHeightReal = screenHeight - (titleNView.cover ? 0 : titleNView.height) - (tabBarView.cover ? 0 : tabBarView.height)
const windowWidth = screenWidth
safeAreaInsets = ios ? safeAreaInsets : {
left: 0,
right: 0,
top: titleNView.height && !titleNView.cover ? 0 : statusBarHeight,
bottom: 0
}
const safeArea = {
left: safeAreaInsets.left, left: safeAreaInsets.left,
right: windowWidth - safeAreaInsets.right, right: windowWidth - safeAreaInsets.right,
top: safeAreaInsets.top, top: safeAreaInsets.top,
bottom: windowHeight - safeAreaInsets.bottom, bottom: windowHeightReal - safeAreaInsets.bottom,
width: windowWidth - safeAreaInsets.left - safeAreaInsets.right, width: windowWidth - safeAreaInsets.left - safeAreaInsets.right,
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom height: windowHeightReal - safeAreaInsets.top - safeAreaInsets.bottom
} }
return { return {
...@@ -77,8 +86,14 @@ export function getSystemInfo () { ...@@ -77,8 +86,14 @@ export function getSystemInfo () {
fontSizeSetting: '', fontSizeSetting: '',
platform, platform,
SDKVersion: '', SDKVersion: '',
windowTop: 0, windowTop,
windowBottom, windowBottom,
safeArea safeArea,
safeAreaInsets: {
top: safeAreaInsets.top,
right: safeAreaInsets.right,
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
}
} }
} }
export { export {
isTabBarPage isTabBarPage
} from '../bridge' } from '../bridge'
export function callApiSync (api, args, name, alias) { export function callApiSync (api, args, name, alias) {
const ret = api(args) const ret = api(args)
if (ret && ret.errMsg) { if (ret && ret.errMsg) {
...@@ -148,4 +148,22 @@ const _transformlng = function (lng, lat) { ...@@ -148,4 +148,22 @@ const _transformlng = function (lng, lat) {
const outOfChina = function (lng, lat) { const outOfChina = function (lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false) return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false)
} }
export function getStatusbarHeight () {
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return plus.navigator.isImmersedStatusbar() ? Math.round(plus.os.name === 'iOS' ? plus.navigator.getSafeAreaInsets().top : plus.navigator.getStatusbarHeight()) : 0
}
export function getScreenInfo () {
const orientation = plus.navigator.getOrientation()
const landscape = Math.abs(orientation) === 90
// 安卓 plus 接口获取的屏幕大小值不为整数
const width = plus.screen.resolutionWidth
const height = plus.screen.resolutionHeight
// 根据方向纠正宽高
return {
screenWidth: Math[landscape ? 'max' : 'min'](width, height),
screenHeight: Math[landscape ? 'min' : 'max'](width, height)
}
}
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
const isAndroid = plus.os.name.toLowerCase() === 'android' const isAndroid = plus.os.name.toLowerCase() === 'android'
const FOCUS_TIMEOUT = isAndroid ? 300 : 700 const FOCUS_TIMEOUT = isAndroid ? 300 : 700
const HIDE_TIMEOUT = 300 const HIDE_TIMEOUT = 800
let keyboardHeight = 0 let keyboardHeight = 0
let onKeyboardShow let onKeyboardShow
let focusTimer let focusTimer
......
...@@ -16,12 +16,17 @@ import { ...@@ -16,12 +16,17 @@ import {
from 'uni-core/service/plugins/lifecycle' from 'uni-core/service/plugins/lifecycle'
import { import {
ON_REACH_BOTTOM_DISTANCE ON_REACH_BOTTOM_DISTANCE,
TITLEBAR_HEIGHT
} }
from '../../constants' from '../../constants'
import tabBar from '../tab-bar' import tabBar from '../tab-bar'
import {
getStatusbarHeight
} from '../../api/util'
function parsePageCreateOptions (vm, route) { function parsePageCreateOptions (vm, route) {
const pagePath = '/' + route const pagePath = '/' + route
const routeOptions = __uniRoutes.find(route => route.path === pagePath) const routeOptions = __uniRoutes.find(route => route.path === pagePath)
...@@ -34,13 +39,15 @@ function parsePageCreateOptions (vm, route) { ...@@ -34,13 +39,15 @@ function parsePageCreateOptions (vm, route) {
const onPageScroll = hasLifecycleHook(vm.$options, 'onPageScroll') ? 1 : 0 const onPageScroll = hasLifecycleHook(vm.$options, 'onPageScroll') ? 1 : 0
const onPageReachBottom = hasLifecycleHook(vm.$options, 'onReachBottom') ? 1 : 0 const onPageReachBottom = hasLifecycleHook(vm.$options, 'onReachBottom') ? 1 : 0
const statusbarHeight = getStatusbarHeight()
return { return {
disableScroll, disableScroll,
onPageScroll, onPageScroll,
onPageReachBottom, onPageReachBottom,
onReachBottomDistance, onReachBottomDistance,
windowTop: 0, // TODO statusbarHeight,
windowTop: windowOptions.titleNView && windowOptions.titleNView.type === 'float' ? (statusbarHeight + TITLEBAR_HEIGHT) : 0,
windowBottom: (tabBar.indexOf(route) >= 0 && tabBar.cover) ? tabBar.height : 0 windowBottom: (tabBar.indexOf(route) >= 0 && tabBar.cover) ? tabBar.height : 0
} }
} }
...@@ -88,4 +95,4 @@ export function initLifecycle (Vue) { ...@@ -88,4 +95,4 @@ export function initLifecycle (Vue) {
} }
} }
}) })
} }
...@@ -10,6 +10,10 @@ import { ...@@ -10,6 +10,10 @@ import {
isTabBarPage isTabBarPage
} from '../../../bridge' } from '../../../bridge'
import {
getStatusbarHeight
} from '../../../api/util'
import tabBar from '../../tab-bar' import tabBar from '../../tab-bar'
function initPopupSubNVue (subNVueWebview, style, maskWebview) { function initPopupSubNVue (subNVueWebview, style, maskWebview) {
...@@ -96,7 +100,7 @@ function initSubNVue (subNVue, routeOptions, webview) { ...@@ -96,7 +100,7 @@ function initSubNVue (subNVue, routeOptions, webview) {
style.dock = 'top' style.dock = 'top'
style.top = 0 style.top = 0
style.width = '100%' style.width = '100%'
style.height = TITLEBAR_HEIGHT + plus.navigator.getStatusbarHeight() style.height = TITLEBAR_HEIGHT + getStatusbarHeight()
delete style.left delete style.left
delete style.right delete style.right
delete style.bottom delete style.bottom
......
...@@ -20,6 +20,7 @@ const passiveOptions = supportsPassive ? { ...@@ -20,6 +20,7 @@ const passiveOptions = supportsPassive ? {
} : false } : false
function onCssVar ({ function onCssVar ({
statusbarHeight,
windowTop, windowTop,
windowBottom windowBottom
}) { }) {
...@@ -29,8 +30,9 @@ function onCssVar ({ ...@@ -29,8 +30,9 @@ function onCssVar ({
const style = document.documentElement.style const style = document.documentElement.style
style.setProperty('--window-top', windowTop + 'px') style.setProperty('--window-top', windowTop + 'px')
style.setProperty('--window-bottom', windowBottom + 'px') style.setProperty('--window-bottom', windowBottom + 'px')
style.setProperty('--status-bar-height', plus.navigator.getStatusbarHeight() + 'px') style.setProperty('--status-bar-height', statusbarHeight + 'px')
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
console.log(`--status-bar-height=${statusbarHeight}`)
console.log(`--window-top=${windowTop}`) console.log(`--window-top=${windowTop}`)
console.log(`--window-bottom=${windowBottom}`) console.log(`--window-bottom=${windowBottom}`)
} }
...@@ -38,6 +40,7 @@ function onCssVar ({ ...@@ -38,6 +40,7 @@ function onCssVar ({
} }
function onPageCreate ({ function onPageCreate ({
statusbarHeight,
windowTop, windowTop,
windowBottom, windowBottom,
disableScroll, disableScroll,
...@@ -46,6 +49,7 @@ function onPageCreate ({ ...@@ -46,6 +49,7 @@ function onPageCreate ({
onReachBottomDistance onReachBottomDistance
}, pageId) { }, pageId) {
onCssVar({ onCssVar({
statusbarHeight,
windowTop, windowTop,
windowBottom windowBottom
}) })
...@@ -70,4 +74,4 @@ function onWebviewReady () { // service 主动发起检测 ...@@ -70,4 +74,4 @@ function onWebviewReady () { // service 主动发起检测
export default function initSubscribe (subscribe) { export default function initSubscribe (subscribe) {
subscribe(WEBVIEW_READY, onWebviewReady) subscribe(WEBVIEW_READY, onWebviewReady)
subscribe(ON_PAGE_CREATE, onPageCreate) subscribe(ON_PAGE_CREATE, onPageCreate)
} }
...@@ -162,12 +162,8 @@ export default { ...@@ -162,12 +162,8 @@ export default {
this.map && this.map[val ? 'hide' : 'show']() this.map && this.map[val ? 'hide' : 'show']()
} }
}, },
listeners: {
'@view-update': '_requestUpdate'
},
mounted () { mounted () {
this._updateStyle() let mapStyle = Object.assign({}, this.attrs, this.position)
let mapStyle = Object.assign({}, this.attrs, this.style)
if (this.latitude && this.longitude) { if (this.latitude && this.longitude) {
mapStyle.center = new plus.maps.Point(this.longitude, this.latitude) mapStyle.center = new plus.maps.Point(this.longitude, this.latitude)
} }
...@@ -180,12 +176,18 @@ export default { ...@@ -180,12 +176,18 @@ export default {
map.hide() map.hide()
} }
this.$watch('attrs', () => { this.$watch('attrs', () => {
this.map && this.map.setStyles(this.attrs) if (this.map) {
this.map.setStyles(this.attrs)
// TODO 临时处理更新 longitude, latitude 无效问题
this.map.setStyles({
center: new plus.maps.Point(this.longitude, this.latitude)
})
}
}, { }, {
deep: true deep: true
}) })
this.$watch('style', () => { this.$watch('position', () => {
this.map && this.map.setStyles(this.style) this.map && this.map.setStyles(this.position)
}, { }, {
deep: true deep: true
}) })
...@@ -213,35 +215,8 @@ export default { ...@@ -213,35 +215,8 @@ export default {
this.map && this[type](data) this.map && this[type](data)
}, },
getRegion () { getRegion () {
// TODO
// const region = this.map.getBounds()
}, },
getScale () { getScale () {
// TODO
// const zoom = this.map.getZoom()
},
_updateStyle () {
const rect = this.$refs.container.getBoundingClientRect()
this.hidden = false;
['top', 'left', 'width', 'height'].forEach(key => {
let val = rect[key]
val = key === 'top' ? val + (document.documentElement.scrollTop || document.body.scrollTop || 0) : val
if (!val && (key === 'width' || key === 'height')) {
this.hidden = true
}
this.style[key] = val + 'px'
})
},
_requestUpdate () {
if (this._animationFrame) {
cancelAnimationFrame(this._animationFrame)
}
if (this.video) {
this._animationFrame = requestAnimationFrame(() => {
delete this._animationFrame
this._updateStyle()
})
}
}, },
controlclick (e) { controlclick (e) {
this.$trigger('controltap', {}, { id: e.id }) this.$trigger('controltap', {}, { id: e.id })
......
<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
} }
......
...@@ -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 {
......
...@@ -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 () {
......
...@@ -52,7 +52,7 @@ export default { ...@@ -52,7 +52,7 @@ export default {
borderRadiusElemStyle.backgroundColor = `rgba(${rgba})` borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`
}) })
}) })
} else if (this.transparentTitle === 'always') { } else if (this.type === '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,
......
...@@ -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) {
......
...@@ -21,7 +21,7 @@ export function getSystemInfoSync () { ...@@ -21,7 +21,7 @@ export function getSystemInfoSync () {
var screenWidth = screen.width var screenWidth = screen.width
var screenHeight = screen.height var screenHeight = screen.height
var language = navigator.language var language = navigator.language
var statusBarHeight = 0 var statusBarHeight = safeAreaInsets.top
var osname var osname
var osversion var osversion
var model var model
...@@ -84,7 +84,7 @@ export function getSystemInfoSync () { ...@@ -84,7 +84,7 @@ export function getSystemInfoSync () {
const { const {
top: windowTop, top: windowTop,
bottom: windowBottom bottom: windowBottom
} = getWindowOffset(false, true) } = getWindowOffset()
windowHeight -= windowTop windowHeight -= windowTop
windowHeight -= windowBottom windowHeight -= windowBottom
...@@ -102,7 +102,13 @@ export function getSystemInfoSync () { ...@@ -102,7 +102,13 @@ export function getSystemInfoSync () {
system, system,
platform, platform,
model, model,
safeArea safeArea,
safeAreaInsets: {
top: safeAreaInsets.top,
right: safeAreaInsets.right,
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
}
} }
} }
/** /**
......
...@@ -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)
}) })
} }
}) })
} }
...@@ -498,7 +498,11 @@ export default { ...@@ -498,7 +498,11 @@ export default {
} }
} else { } else {
if (document.fullscreenEnabled || document.webkitFullscreenEnabled) { if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
document[document.fullscreenEnabled ? 'exitFullscreen' : 'webkitExitFullscreen']() if (document.fullscreenElement) {
document.exitFullscreen()
} else if (document.webkitFullscreenElement) {
document.webkitExitFullscreen()
}
} else if (video.webkitExitFullScreen) { } else if (video.webkitExitFullScreen) {
video.webkitExitFullScreen() video.webkitExitFullScreen()
} else { } else {
......
import previewImage from '../../helpers/normalize-preview-image' import previewImage from '../../helpers/normalize-preview-image'
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
}
}
}
export const protocols = { export const protocols = {
previewImage previewImage,
getSystemInfo: {
returnValue: addSafeAreaInsets
},
getSystemInfoSync: {
returnValue: addSafeAreaInsets
}
} }
export const todos = [ export const todos = [
'vibrate' 'vibrate'
] ]
export const canIUses = [] export const canIUses = []
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册