UNPKG

@megalo/api

Version:

重新封装各个端中的API,由 megalo 统一对外抛出方法名。目前微信小程序端提供的 API 最为丰富,所以 API 名称以微信小程序为准。

31 lines (25 loc) 638 B
export const ENV_TYPE = { WECHAT: 'wechat', WEB: 'web', SWAN: 'swan', ALIPAY: 'alipay', TOUTIAO: 'toutiao', }; export function getEnv() { if (typeof tt !== 'undefined' && tt.getSystemInfo) { return ENV_TYPE.TOUTIAO; } if (typeof wx !== 'undefined' && wx.getSystemInfo) { return ENV_TYPE.WECHAT; } if (typeof swan !== 'undefined' && swan.getSystemInfo) { return ENV_TYPE.SWAN; } if (typeof my !== 'undefined' && my.getSystemInfo) { return ENV_TYPE.ALIPAY; } if (typeof window !== 'undefined') { return ENV_TYPE.WEB; } return 'Unknown environment'; }