提交 3cd4b6b0 编写于 作者: X xzs02

fix: 解决某些情况获取安卓手机型号出错的问题 #134

上级 e17a1545
......@@ -41,8 +41,26 @@ export function getSystemInfoSync () {
if (osversionFind) {
osversion = osversionFind[1]
}
model = ua.split(')')[0].split(';')
model = model[model.length - 1].split('Build')[0].replace(/^\s(.+)\s$/, '$1')
let infos = ua.match(/\((.+?)\)/)[1].split(';')
const otherInfo = [/^\s?Android/i, /^\s?Linux/i, /^\s?U/i, /^\s?[a-z][a-z]$/i, /^\s?[a-z][a-z]-[a-z][a-z]$/i, /^\s?wv/i]
for (let i = 0; i < infos.length; i++) {
const info = infos[i]
if (info.indexOf('Build') > 0) {
model = info.split('Build')[0].trim()
break
}
let other
for (let o = 0; o < otherInfo.length; o++) {
if (otherInfo[o].test(info)) {
other = true
break
}
}
if (!other) {
model = info.trim()
break
}
}
} else {
osname = 'Other'
osversion = '0'
......@@ -59,11 +77,11 @@ export function getSystemInfoSync () {
windowHeight -= windowTop
windowHeight -= windowBottom
return {
windowTop,
return {
windowTop,
windowBottom,
windowWidth,
windowHeight,
windowHeight,
pixelRatio,
screenWidth,
screenHeight,
......@@ -79,4 +97,4 @@ export function getSystemInfoSync () {
*/
export function getSystemInfo () {
return getSystemInfoSync()
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册