import { AppBaseInfoDeviceUtil } from './device/AppBaseInfoDeviceUtil.uts'; import { UTSiOS } from "DCloudUTSFoundation"; import { GetAppBaseInfoOptions, GetAppBaseInfo, GetAppBaseInfoResult } from '../interface.uts' export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions | null) : GetAppBaseInfoResult => { let filter : Array = []; if (config != null && config!.filter != null) { filter = config!.filter; } if (config == null || filter.length == 0) { const defaultFilter = [ "appId", "appName", "appVersion", "appVersionCode", "appLanguage", "language", "version", "appWgtVersion", "hostLanguage", "hostVersion", "hostName", "hostPackageName", "hostSDKVersion", "hostTheme", ]; filter = defaultFilter; } return getBaseInfo(filter); } function getBaseInfo(filterArray : Array) : GetAppBaseInfoResult { let result : GetAppBaseInfoResult = {}; if (filterArray.indexOf("appId") != -1) { result.appId = AppBaseInfoDeviceUtil.getAppID(); } if (filterArray.indexOf("appName") != -1) { result.appName = AppBaseInfoDeviceUtil.getAppName(); } if (UTSiOS.isUniMp()) { if (filterArray.indexOf("hostPackageName") != -1) { result.hostPackageName = AppBaseInfoDeviceUtil.getHostPackageName(); } if (filterArray.indexOf("hostVersion") != -1) { result.hostVersion = AppBaseInfoDeviceUtil.getHostVersion(); } if (filterArray.indexOf("hostName") != -1) { result.hostName = AppBaseInfoDeviceUtil.getHostName(); } if (filterArray.indexOf("hostTheme") != -1) { result.hostTheme = AppBaseInfoDeviceUtil.getHostTheme(); } if (filterArray.indexOf("hostLanguage") != -1) { result.hostLanguage = AppBaseInfoDeviceUtil.getHostLanguage(); } } if (filterArray.indexOf("appVersion") != -1) { result.appVersion = AppBaseInfoDeviceUtil.getAppVersion(); } if (filterArray.indexOf("appVersionCode") != -1) { result.appVersionCode = AppBaseInfoDeviceUtil.getAppVersionCode(); } if (filterArray.indexOf("appLanguage") != -1) { result.appLanguage = AppBaseInfoDeviceUtil.getOsLanguageNormal(); } if (filterArray.indexOf("language") != -1) { result.language = AppBaseInfoDeviceUtil.getOsLanguage(); } if (filterArray.indexOf("version") != -1) { result.version = AppBaseInfoDeviceUtil.getAppInnerVersion(); } if (filterArray.indexOf("appWgtVersion") != -1) { result.appWgtVersion = AppBaseInfoDeviceUtil.getAppWgtVersion(); } return result; }