From 555262a2428c36ae3cf91ed04af26d221ed69c75 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 1 Nov 2019 19:53:26 +0800 Subject: [PATCH] =?UTF-8?q?update:=20lint=20&=20=E7=B2=BE=E7=AE=80?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/framework/webview/index.js | 15 +++++------ .../webview/parser/style-unit-parser.js | 2 +- .../webview/parser/sub-nvue-parser.js | 26 +++++++------------ 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/platforms/app-plus/service/framework/webview/index.js b/src/platforms/app-plus/service/framework/webview/index.js index b366e1e952..57d8a607ea 100644 --- a/src/platforms/app-plus/service/framework/webview/index.js +++ b/src/platforms/app-plus/service/framework/webview/index.js @@ -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() }) diff --git a/src/platforms/app-plus/service/framework/webview/parser/style-unit-parser.js b/src/platforms/app-plus/service/framework/webview/parser/style-unit-parser.js index 438f8806d2..1e50814774 100644 --- a/src/platforms/app-plus/service/framework/webview/parser/style-unit-parser.js +++ b/src/platforms/app-plus/service/framework/webview/parser/style-unit-parser.js @@ -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')) { diff --git a/src/platforms/app-plus/service/framework/webview/parser/sub-nvue-parser.js b/src/platforms/app-plus/service/framework/webview/parser/sub-nvue-parser.js index c269b7e3b3..ea207c0e14 100644 --- a/src/platforms/app-plus/service/framework/webview/parser/sub-nvue-parser.js +++ b/src/platforms/app-plus/service/framework/webview/parser/sub-nvue-parser.js @@ -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) }) } -- GitLab