@tarojs/taro-h5 3.5.5 → 3.5.6-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1259,7 +1259,7 @@ function getItem(key) {
1259
1259
  try {
1260
1260
  item = JSON.parse(localStorage.getItem(key) || '');
1261
1261
  }
1262
- catch (e) { }
1262
+ catch (e) { } // eslint-disable-line no-empty
1263
1263
  // 只返回使用 Taro.setStorage API 存储的数据
1264
1264
  if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
1265
1265
  return { result: true, data: item.data };
@@ -5176,9 +5176,13 @@ const taro = {
5176
5176
  const initPxTransform = getInitPxTransform(taro);
5177
5177
  const requirePlugin = permanentlyNotSupport('requirePlugin');
5178
5178
  const pxTransform = function (size) {
5179
- // @ts-ignore
5180
- const { designWidth } = taro.config;
5181
- return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem';
5179
+ const options = taro.config;
5180
+ const baseFontSize = options.baseFontSize || 20;
5181
+ const designWidth = ((input = 0) => typeof options.designWidth === 'function'
5182
+ ? options.designWidth(input)
5183
+ : options.designWidth);
5184
+ const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
5185
+ return Math.ceil((parseInt(size, 10) / rootValue(size)) * 10000) / 10000 + 'rem';
5182
5186
  };
5183
5187
  const canIUseWebp = function () {
5184
5188
  const canvas = document.createElement('canvas');