提交 555262a2 编写于 作者: 雪洛's avatar 雪洛

update: lint & 精简代码

上级 e39764aa
......@@ -127,9 +127,8 @@ export function initWebview (webview, routeOptions) {
on,
emit
} = UniServiceJSBridge
// TODO subNVues
initSubNVues(routeOptions,webview)
initSubNVues(routeOptions, webview)
// TODO 优化相关依赖性
// webview.addEventListener('popGesture', e => {
......@@ -154,17 +153,16 @@ export function initWebview (webview, routeOptions) {
// })
webview.addEventListener('close', () => {
if (this.popupSubNVueWebviews) { // 移除所有 popupSubNVueWebview
Object.keys(this.popupSubNVueWebviews).forEach(id => {
if (webview.popupSubNVueWebviews) { // 移除所有 popupSubNVueWebview
Object.keys(webview.popupSubNVueWebviews).forEach(id => {
if (process.env.NODE_ENV !== 'production') {
console.log(
`UNIAPP[webview][${this.id}]:popupSubNVueWebview[${id}].close`
`UNIAPP[webview][${webview.id}]:popupSubNVueWebview[${id}].close`
)
}
this.popupSubNVueWebviews[id].close('none')
webview.popupSubNVueWebviews[id].close('none')
})
}
typeof this.closeCallback === 'function' && this.closeCallback()
})
Object.keys(WEBVIEW_LISTENERS).forEach(name => {
......@@ -179,7 +177,6 @@ export function initWebview (webview, routeOptions) {
onWebviewRecovery(webview, routeOptions)
}
// TODO 应该结束之前未完成的下拉刷新
on(webview.id + '.startPullDownRefresh', () => {
webview.beginPullToRefresh()
})
......
......@@ -2,7 +2,7 @@ import {
transformCSS
} from '../../upx'
export function parseStyleUnit(styles) {
export function parseStyleUnit (styles) {
let newStyles = {}
const stylesStr = JSON.stringify(styles)
if (~stylesStr.indexOf('upx') || ~stylesStr.indexOf('rpx')) {
......
......@@ -10,15 +10,9 @@ import {
isTabBarPage
} from '../../../bridge'
function getDefaultFontSize(width) {
return Math.round((width || plus.screen.resolutionWidth) / 20)
}
function getDefaultViewport() {
return plus.screen.resolutionWidth
}
import tabBar from '../../tab-bar'
function initPopupSubNVue(subNVueWebview, style, maskWebview) {
function initPopupSubNVue (subNVueWebview, style, maskWebview) {
if (!maskWebview.popupSubNVueWebviews) {
maskWebview.popupSubNVueWebviews = {}
}
......@@ -63,15 +57,15 @@ function initPopupSubNVue(subNVueWebview, style, maskWebview) {
})
}
function initNormalSubNVue(subNVueWebview, style, webview) {
function initNormalSubNVue (subNVueWebview, style, webview) {
webview.append(subNVueWebview)
}
function initSubNVue(subNVue,routeOptions,webview) {
function initSubNVue (subNVue, routeOptions, webview) {
if (!subNVue.path) {
return
}
const style = subNVue.style || {} // 格式化
const style = subNVue.style || {}
const isNavigationBar = subNVue.type === 'navigationBar'
const isPopup = subNVue.type === 'popup'
......@@ -84,8 +78,8 @@ function initSubNVue(subNVue,routeOptions,webview) {
style.uniNView = {
path: subNVue.path.replace('.nvue', '.js'),
defaultFontSize: getDefaultFontSize(),
viewport: getDefaultViewport()
defaultFontSize: __uniConfig.defaultFontSize,
viewport: __uniConfig.viewport
}
const extras = {
......@@ -109,7 +103,7 @@ function initSubNVue(subNVue,routeOptions,webview) {
delete style.margin
} else if (isPopup) {
style.position = 'absolute'
console.log(isTabBarPage(routeOptions.path));
console.log(isTabBarPage(routeOptions.path))
if (isTabBarPage(routeOptions.path)) {
maskWebview = tabBar
} else {
......@@ -133,12 +127,12 @@ function initSubNVue(subNVue,routeOptions,webview) {
}
}
export function initSubNVues(routeOptions,webview) {
export function initSubNVues (routeOptions, webview) {
const subNVues = routeOptions.window.subNVues
if (!subNVues || !subNVues.length) {
return
}
subNVues.forEach(subNVue => {
initSubNVue(subNVue,routeOptions,webview)
initSubNVue(subNVue, routeOptions, webview)
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册