Returns if this app is using right-to-left language direction or not.
We recommend the app's index.html file already has the correct dir
attribute value set, such as <html dir="ltr"> or <html dir="rtl">.
W3C: Structural markup and right-to-left text in HTML
Returns app's language direction.
We recommend the app's index.html file already has the correct dir
attribute value set, such as <html dir="ltr"> or <html dir="rtl">.
W3C: Structural markup and right-to-left text in HTML
获取带有私有前缀的url参数对象
Get the query string parameter
Gets the height of the platform's viewport using window.innerHeight.
Using this method is preferred since the dimension is a cached value,
which reduces the chance of multiple and expensive DOM reads.
returns true/false based on platform.
Returns true if the app is in landscape mode.
Returns true if the app is in portait mode.
Returns app's language and optional country code.
We recommend the app's index.html file already has the correct lang
attribute value set, such as <html lang="en">.
W3C: Declaring language in HTML
the array of platforms
Returns a promise when the platform is ready and native functionality
can be called. If the app is running from within a web browser, then
the promise will resolve when the DOM is ready. When the app is running
from an hybrid application such as Cordova/Electron/Weichat/Alipay,
then the promise will resolve when hybrid application execute the
triggerReady function.
The resolved value is the readySource, which states which platform
ready was used. For example, when Cordova is ready, the resolved ready
source is cordova. The default ready source value will be dom. The
readySource is useful if different logic should run depending on the
platform the app is running from. For example, only Cordova can execute
the status bar plugin, so the web should not run status bar plugin logic.
import { setupPlatform } from 'tp-platform';
const plt = setupPlatform({});
plt.ready().then(function (readySource) {
switch (readySource) {
case 'dom':
console.log('web env');
break;
case 'cordova':
console.log('cordova env');
break;
case 'electron':
console.log('electron env');
break;
case 'alipay':
console.log('alipay env');
break;
case 'dingtalk':
console.log('dingtalk env');
break;
case 'wechat':
console.log('wechat env');
break;
default:
console.log(readySource + ' not found!');
}
}, function (reason) {
console.error('ready error', reason)
});
Set the app's language direction, which will update the dir attribute
on the app's root <html> element. We recommend the app's index.html
file already has the correct dir attribute value set, such as
<html dir="ltr"> or <html dir="rtl">. This method is useful if the
direction needs to be dynamically changed per user/session.
W3C: Structural markup and right-to-left text in HTML
Examples: rtl, ltr
Set the app's language and optionally the country code, which will update
the lang attribute on the app's root <html> element.
We recommend the app's index.html file already has the correct lang
attribute value set, such as <html lang="en">. This method is useful if
the language needs to be dynamically changed per user/session.
W3C: Declaring language in HTML
Examples: en-US, en-GB, ar, de, zh, es-MX
Specifies whether the lang attribute of <html> should be updated
Get the final configuration for the matching platform.
Get the current url.
Returns an object containing version information about all of the platforms.
import { setupPlatform } from 'tp-platform';
const plt = setupPlatform({});
plt.versions(); // {ios: {str: "10.3.0", num: 10.3, major: 10, minor: 3, patch: 0}}.
An object containing all of the platforms and their versions.
Gets the width of the platform's viewport using window.innerWidth.
Using this method is preferred since the dimension is a cached value,
which reduces the chance of multiple and expensive DOM reads.
Generated using TypeDoc
Platform
The Platform service can be used to get information about your current device. You can get all of the platforms associated with the device using the platforms method, including whether the app is being viewed from a mobile/tablet/desktop, if it's on a mobile device or browser, and the exact System (iOS, Android, Windows etc). You can also get the orientation of the device, if it uses right-to-left language direction, and much much more. With this information you can completely customize your app to fit any device.
import { Platform } from 'tp-platform'; const plt = new Platform({});