提交 5c7766a3 编写于 作者: fxy060608's avatar fxy060608

fix: upx2px 内调用不到 uni.getSystemInfoSync 的问题

上级 b292e96a
......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = my.getSystemInfoSync(); // runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -406,6 +406,18 @@ const protocols = { // 需要做转换的 API 列表
args: {
orderInfo: 'orderStr'
}
},
getBLEDeviceServices: {
returnValue (result) {
result.services.forEach((item) => {
item.uuid = item.serviceId;
});
}
},
makePhoneCall: {
args: {
phoneNumber: 'number'
}
}
};
......@@ -578,10 +590,10 @@ var api = /*#__PURE__*/Object.freeze({
removeStorageSync: removeStorageSync
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -602,27 +614,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(my).forEach(name => {
if (hasOwn(my, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, my[name]));
uni[name] = promisify(name, wrapper(name, my[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.5",
"version": "0.0.6",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
......
......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = swan.getSystemInfoSync(); // uni=>swan runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -332,10 +332,10 @@ var api = /*#__PURE__*/Object.freeze({
requestPayment: requestPayment
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -356,27 +356,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(swan).forEach(name => {
if (hasOwn(swan, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, swan[name]));
uni[name] = promisify(name, wrapper(name, swan[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-baidu",
"version": "0.0.4",
"version": "0.0.5",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
......
......@@ -89,14 +89,14 @@ function checkDeviceWidth () {
platform,
pixelRatio,
windowWidth
} = uni.getSystemInfoSync();
} = wx.getSystemInfoSync(); // uni=>wx runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth;
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px (number, newDeviceWidth) {
function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -261,10 +261,10 @@ var api = /*#__PURE__*/Object.freeze({
});
let uni$1 = {};
let uni = {};
if (typeof Proxy !== 'undefined') {
uni$1 = new Proxy({}, {
uni = new Proxy({}, {
get (target, name) {
if (name === 'upx2px') {
return upx2px
......@@ -285,27 +285,27 @@ if (typeof Proxy !== 'undefined') {
}
});
} else {
uni$1.upx2px = upx2px;
uni.upx2px = upx2px;
Object.keys(todoApis).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni$1[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(api).forEach(name => {
uni$1[name] = promisify(name, api[name]);
uni[name] = promisify(name, api[name]);
});
Object.keys(wx).forEach(name => {
if (hasOwn(wx, name) || hasOwn(protocols, name)) {
uni$1[name] = promisify(name, wrapper(name, wx[name]));
uni[name] = promisify(name, wrapper(name, wx[name]));
}
});
}
var uni$2 = uni$1;
var uni$1 = uni;
export default uni$2;
export default uni$1;
{
"name": "@dcloudio/uni-mp-weixin",
"version": "0.0.3",
"version": "0.0.4",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
......
......@@ -8,7 +8,7 @@ import {
import {
upx2px
} from '../service/api/upx2px'
} from './upx2px'
import wrapper from './wrapper'
......
const EPS = 1e-4
const BASE_DEVICE_WIDTH = 750
let isIOS = false
let deviceWidth = 0
let deviceDPR = 0
export function checkDeviceWidth () {
const {
platform,
pixelRatio,
windowWidth
} = __GLOBAL__.getSystemInfoSync() // uni=>__GLOBAL__ runtime 编译目标是 uni 对象,内部不允许直接使用 uni
deviceWidth = windowWidth
deviceDPR = pixelRatio
isIOS = platform === 'ios'
}
export function upx2px (number, newDeviceWidth) {
if (deviceWidth === 0) {
checkDeviceWidth()
}
number = Number(number)
if (number === 0) {
return 0
}
number = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth)
number = Math.floor(number + EPS)
if (number === 0) {
if (deviceDPR === 1 || !isIOS) {
return 1
} else {
return 0.5
}
}
return number
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册