src/Platform.ts
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/**
* 平台数据接口。
* 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息
* 通过这种方式封装平台逻辑,以保证整体结构的稳定
* 由于不同平台的接口形式各有不同,将所有接口封装为基于 Promise 的异步形式
*/
declare interface Platform {
getUserInfo(): Promise<any>;
login(): Promise<any>
}
class DebugPlatform implements Platform {
async getUserInfo() {
//微信的接口
var userID = decodeURI(egret.getOption("openid"));
var userName = decodeURI(egret.getOption("nickname"));
//渠道ID
var canalID = decodeURI(egret.getOption("canalID"));
var appid = decodeURI(egret.getOption("AppID"));
var token = decodeURI(egret.getOption("token"));
if (userID == "") {
userID = "10010"
}
return { nickName: userName, nickID: userID, canalID: canalID, appid: appid ,token:token}
}
async login() {
}
}
if (!window.platform) {
window.platform = new DebugPlatform();
}
declare let platform: Platform;
declare interface Window {
platform: Platform
}
后面还有 1 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
