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

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

上级 e17a1545
...@@ -41,8 +41,26 @@ export function getSystemInfoSync () { ...@@ -41,8 +41,26 @@ export function getSystemInfoSync () {
if (osversionFind) { if (osversionFind) {
osversion = osversionFind[1] osversion = osversionFind[1]
} }
model = ua.split(')')[0].split(';') let infos = ua.match(/\((.+?)\)/)[1].split(';')
model = model[model.length - 1].split('Build')[0].replace(/^\s(.+)\s$/, '$1') 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 { } else {
osname = 'Other' osname = 'Other'
osversion = '0' osversion = '0'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册