Skip to content

Commit

Permalink
feat(core): add wxa.platform, indicate which platform app running at
Browse files Browse the repository at this point in the history
  • Loading branch information
Genuifx committed Mar 3, 2020
1 parent 61862e5 commit fd9214e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/wxa-core/src/wxa.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
import './polyfill/bind';

import debounce from 'lodash/debounce';
Expand Down Expand Up @@ -60,6 +61,9 @@ export class Wxa {

// enable automatic embed app instance
this.enableAppEmbed = true;

this.__WXA_PLATFORM__ = void(0);
this.platform = this.getWxaPlatform();
}

setDebugMode(val) {
Expand Down Expand Up @@ -205,6 +209,16 @@ export class Wxa {
disabledAppEmbed() {
this.enableAppEmbed = false;
}

/**
* @return {String}
* return mini-program platform.
*/
getWxaPlatform() {
if (typeof this.__WXA_PLATFORM__ !== 'undefined') return this.__WXA_PLATFORM__;
else if (typeof tt !== 'undefined') return 'tt';
else return 'wechat';
}
}

export const wxa = new Wxa();

0 comments on commit fd9214e

Please sign in to comment.