From a0dc34d463e5157cc2a51a8151e420722dad058d Mon Sep 17 00:00:00 2001 From: dntzhang Date: Sun, 11 Nov 2018 20:28:10 +0800 Subject: [PATCH] omi-mp - using rpx of omi(v4.0.26+) --- packages/omi-mp/gulpfile.js | 8 ++++---- packages/omi-mp/src/mp/components/my-child/my-child.js | 4 ++-- packages/omi-mp/src/mp/components/my-ele/my-ele.js | 4 ++-- packages/omi-mp/src/mp/pages/index/index.js | 4 ++-- packages/omi-mp/src/mp/pages/logs/logs.js | 4 ++-- packages/omi-mp/src/utils/mp.js | 7 ------- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/packages/omi-mp/gulpfile.js b/packages/omi-mp/gulpfile.js index b095212a9..6a93c4159 100644 --- a/packages/omi-mp/gulpfile.js +++ b/packages/omi-mp/gulpfile.js @@ -22,7 +22,7 @@ gulp.task('components', ['copy'], () => { file.contents = Buffer.concat([ new Buffer( `${importStr}import componentCss from './${name}.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' ` @@ -74,7 +74,7 @@ Object.keys(mpOption.methods).forEach(key => { }) function css() { - return rpx2px(componentCss) + return rpx(componentCss) } ${hyperscript} @@ -109,7 +109,7 @@ gulp.task('pages', ['copy'], () => { new Buffer( `${importStr}import appCss from '../../app.wxss' import pageCss from './${name}.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' ` @@ -150,7 +150,7 @@ Object.keys(mpOption).forEach(key => { }) function css() { - return rpx2px(appCss + pageCss) + return rpx(appCss + pageCss) } ${hyperscript} diff --git a/packages/omi-mp/src/mp/components/my-child/my-child.js b/packages/omi-mp/src/mp/components/my-child/my-child.js index 80781f74c..9a65d6185 100644 --- a/packages/omi-mp/src/mp/components/my-child/my-child.js +++ b/packages/omi-mp/src/mp/components/my-child/my-child.js @@ -1,6 +1,6 @@ import componentCss from './my-child.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' // components/my-child/my-child.js @@ -68,7 +68,7 @@ Object.keys(mpOption.methods).forEach(key => { }) function css() { - return rpx2px(componentCss) + return rpx(componentCss) } function render() { diff --git a/packages/omi-mp/src/mp/components/my-ele/my-ele.js b/packages/omi-mp/src/mp/components/my-ele/my-ele.js index baaaf8ecb..aca779807 100644 --- a/packages/omi-mp/src/mp/components/my-ele/my-ele.js +++ b/packages/omi-mp/src/mp/components/my-ele/my-ele.js @@ -1,6 +1,6 @@ import '../my-child/my-child' import componentCss from './my-ele.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' // components/my-ele/my-ele.js @@ -70,7 +70,7 @@ Object.keys(mpOption.methods).forEach(key => { }) function css() { - return rpx2px(componentCss) + return rpx(componentCss) } function render() { diff --git a/packages/omi-mp/src/mp/pages/index/index.js b/packages/omi-mp/src/mp/pages/index/index.js index a77056ceb..694f6a266 100644 --- a/packages/omi-mp/src/mp/pages/index/index.js +++ b/packages/omi-mp/src/mp/pages/index/index.js @@ -1,7 +1,7 @@ import appCss from '../../app.wxss' import pageCss from './index.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' //index.js @@ -93,7 +93,7 @@ Object.keys(mpOption).forEach(key => { }) function css() { - return rpx2px(appCss + pageCss) + return rpx(appCss + pageCss) } function render() { diff --git a/packages/omi-mp/src/mp/pages/logs/logs.js b/packages/omi-mp/src/mp/pages/logs/logs.js index a8c8210ce..9f7e20911 100644 --- a/packages/omi-mp/src/mp/pages/logs/logs.js +++ b/packages/omi-mp/src/mp/pages/logs/logs.js @@ -1,7 +1,7 @@ import '../../components/my-ele/my-ele' import appCss from '../../app.wxss' import pageCss from './logs.wxss' -import { h, WeElement } from 'omi' +import { h, WeElement, rpx } from 'omi' import { setData } from '../../../utils/set-data' //logs.js @@ -56,7 +56,7 @@ Object.keys(mpOption).forEach(key => { }) function css() { - return rpx2px(appCss + pageCss) + return rpx(appCss + pageCss) } function render() { diff --git a/packages/omi-mp/src/utils/mp.js b/packages/omi-mp/src/utils/mp.js index 52f1126fa..cf65e9a7c 100644 --- a/packages/omi-mp/src/utils/mp.js +++ b/packages/omi-mp/src/utils/mp.js @@ -32,13 +32,6 @@ wx.getSystemInfoSync = function() { wx.getUserInfo = function() {} -//用户可以有个开关不转 -window.rpx2px = function(str) { - return str.replace(/([1-9]\d*|0)(\.\d*)*rpx/g, (a, b) => { - return (window.innerWidth * Number(b)) / 750 + 'px' - }) -} - wx.navigateTo = function(option) { route.query = getUrlParams(option.url) route.to(option.url)