提交 b87d746c 编写于 作者: D DCloud_LXH

fix(h5): getSystemInfo(system platform)

上级 75ac1977
...@@ -4,6 +4,12 @@ export const isAndroid = /android/i.test(ua) ...@@ -4,6 +4,12 @@ export const isAndroid = /android/i.test(ua)
export const isIOS = /iphone|ipad|ipod/i.test(ua) export const isIOS = /iphone|ipad|ipod/i.test(ua)
export const isWindows = ua.match(/Windows NT ([\d|\d.\d]*)/i)
export const isMac = /Macintosh|Mac/i.test(ua)
export const isLinux = /Linux|X11/i.test(ua)
export function getScreenFix() { export function getScreenFix() {
return ( return (
/^Apple/.test(navigator.vendor) && typeof window.orientation === 'number' /^Apple/.test(navigator.vendor) && typeof window.orientation === 'number'
......
...@@ -8,6 +8,9 @@ import { ...@@ -8,6 +8,9 @@ import {
ua, ua,
isIOS, isIOS,
isAndroid, isAndroid,
isWindows,
isMac,
isLinux,
isLandscape, isLandscape,
getScreenFix, getScreenFix,
getScreenWidth, getScreenWidth,
...@@ -85,6 +88,65 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>( ...@@ -85,6 +88,65 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
break break
} }
} }
} else if (isWindows || isMac || isLinux) {
model = 'PC'
osname = 'PC'
osversion = '0'
let osversionFind = ua.match(/\((.+?)\)/)![1]
if (isWindows) {
osname = 'Windows'
switch (isWindows[1]) {
case '5.1':
osversion = 'XP'
break
case '6.0':
osversion = 'Vista'
break
case '6.1':
osversion = '7'
break
case '6.2':
osversion = '8'
break
case '6.3':
osversion = '8.1'
break
case '10.0':
osversion = '10'
break
}
const framework =
osversionFind && osversionFind.match(/[Win|WOW]([\d]+)/)
if (framework) {
osversion += ` x${framework[1]}`
}
} else if (isMac) {
osname = 'Mac'
osversion =
(osversionFind && osversionFind.match(/Mac OS X (.+)/)) || ''
if (osversion) {
osversion = osversion[1].replace(/_/g, '.')
// '10_15_7' or '10.16; rv:86.0'
if (osversion.indexOf(';') !== -1) {
osversion = osversion.split(';')[0]
}
}
} else if (isLinux) {
osname = 'Linux'
osversion = (osversionFind && osversionFind.match(/Linux (.*)/)) || ''
if (osversion) {
osversion = osversion[1]
// 'x86_64' or 'x86_64; rv:79.0'
if (osversion.indexOf(';') !== -1) {
osversion = osversion.split(';')[0]
}
}
}
} 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.
先完成此消息的编辑!
想要评论请 注册