@shed/platform

小游戏跨平台API

Usage no npm install needed!

<script type="module">
  import shedPlatform from 'https://cdn.skypack.dev/@shed/platform';
</script>

README

@shed/platform

:hammer: 以微信小游戏为基准,统一各小游戏平台提供的API,并 Promise

各个小游戏平台均实现了 IPlatform 接口

当使用 @shed/cli 编译到某个平台时,会利用 rolluptree shaking 自动将其他无关平台的代码删掉。

安装

npm install @shed/platform

或使用 yarn

yarn add @shed/platform

用法

let api:IPlatform = Platform.get();
api.xxx();

如果在微信平台,上边的代码经过 @shed/cli 编译后相当于

wx.xxx();

环境判断

let platform = Platform.get();

if(platform.isWX){ 
    console.log('是微信平台'); 
}

if(platform.isH5){
    console.log('是Web平台');
}

Contributors

License

The MIT License