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

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.
@@ -5,7 +5,7 @@ function getItem(key) {
5
5
  try {
6
6
  item = JSON.parse(localStorage.getItem(key) || '');
7
7
  }
8
- catch (e) { }
8
+ catch (e) { } // eslint-disable-line no-empty
9
9
  // 只返回使用 Taro.setStorage API 存储的数据
10
10
  if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
11
11
  return { result: true, data: item.data };
package/dist/api/taro.js CHANGED
@@ -28,9 +28,13 @@ const taro = {
28
28
  const initPxTransform = getInitPxTransform(taro);
29
29
  const requirePlugin = permanentlyNotSupport('requirePlugin');
30
30
  const pxTransform = function (size) {
31
- // @ts-ignore
32
- const { designWidth } = taro.config;
33
- return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem';
31
+ const options = taro.config;
32
+ const baseFontSize = options.baseFontSize || 20;
33
+ const designWidth = ((input = 0) => typeof options.designWidth === 'function'
34
+ ? options.designWidth(input)
35
+ : options.designWidth);
36
+ const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
37
+ return Math.ceil((parseInt(size, 10) / rootValue(size)) * 10000) / 10000 + 'rem';
34
38
  };
35
39
  const canIUseWebp = function () {
36
40
  const canvas = document.createElement('canvas');
package/dist/index.cjs.js CHANGED
@@ -1267,7 +1267,7 @@ function getItem(key) {
1267
1267
  try {
1268
1268
  item = JSON.parse(localStorage.getItem(key) || '');
1269
1269
  }
1270
- catch (e) { }
1270
+ catch (e) { } // eslint-disable-line no-empty
1271
1271
  // 只返回使用 Taro.setStorage API 存储的数据
1272
1272
  if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
1273
1273
  return { result: true, data: item.data };
@@ -5184,9 +5184,13 @@ const taro = {
5184
5184
  const initPxTransform = getInitPxTransform(taro);
5185
5185
  const requirePlugin = permanentlyNotSupport('requirePlugin');
5186
5186
  const pxTransform = function (size) {
5187
- // @ts-ignore
5188
- const { designWidth } = taro.config;
5189
- return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem';
5187
+ const options = taro.config;
5188
+ const baseFontSize = options.baseFontSize || 20;
5189
+ const designWidth = ((input = 0) => typeof options.designWidth === 'function'
5190
+ ? options.designWidth(input)
5191
+ : options.designWidth);
5192
+ const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
5193
+ return Math.ceil((parseInt(size, 10) / rootValue(size)) * 10000) / 10000 + 'rem';
5190
5194
  };
5191
5195
  const canIUseWebp = function () {
5192
5196
  const canvas = document.createElement('canvas');