import Taro from '@tarojs/api' ; import MobileDetect from 'mobile-detect' ; import { MethodHandler } from '../../utils/handler' ; export const getSystemInfoSync = ( ) => { const md = new MobileDetect ( navigator . userAgent ) ; const info = { brand : md . mobile ( ) || '' , model : md . mobile ( ) || '' , system : md . os ( ) , pixelRatio : window . devicePixelRatio , screenWidth : window . screen . width , screenHeight : window . screen . height , windowWidth : document . documentElement . clientWidth , windowHeight : document . documentElement . clientHeight , version : '' , statusBarHeight : NaN , platform : navigator . platform , language : navigator . language , fontSizeSetting : NaN , SDKVersion : '' , albumAuthorized : false , benchmarkLevel : 0 , bluetoothEnabled : false , cameraAuthorized : false , enableDebug : false , locationAuthorized : false , locationEnabled : false , microphoneAuthorized : false , notificationAlertAuthorized : false , notificationAuthorized : false , notificationBadgeAuthorized : false , notificationSoundAuthorized : false , safeArea : { bottom : 0 , height : 0 , left : 0 , right : 0 , top : 0 , width : 0 } , wifiEnabled : false } ; return info ; } ; export const getSystemInfo = async ( options = { } ) => { const { success , fail , complete } = options ; const handle = new MethodHandler ( { name : 'getSystemInfo' , success , fail , complete } ) ; try { const info = await getSystemInfoSync ( ) ; return handle . success ( info ) ; } catch ( error ) { return handle . fail ( { errMsg : error } ) ; } } ;