npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wwd-cocos-network

v1.0.2

Published

推币机 Cocos 项目的网络请求模块

Readme

wwd-cocos-network

推币机 Cocos 项目的 TypeScript 网络请求库,封装 API 路径、请求头、响应模型与各业务模块接口。

安装

本地路径引用(推荐开发阶段)

在 Cocos 游戏项目的 package.json 中添加:

{
  "dependencies": {
    "wwd-cocos-network": "file:../WwdCocosNetwork"
  }
}
cd /path/to/YourCocosGame
npm install

每次修改本库源码后,在本库目录执行:

npm run build

npm 安装

npm install wwd-cocos-network

快速开始

import {
  wwdNetwork,
  WwdNetworkConfig,
  WwdHeader,
  NetworkUser,
  NetworkGame,
  Completion,
  LoginParam,
} from 'wwd-cocos-network';

// 1. 初始化
const config = new WwdNetworkConfig('https://api.example.com', 30000);
const head = new WwdHeader()
  .setUid(0)
  .setLoginKey('')
  .setAppCode('your-app-code')
  .setChannel('applestore')
  .setOsType(1)
  .setImei('device-id');

wwdNetwork.init(config, head);

// 2. 登录
const param = new LoginParam();
param.number = '13800138000';
param.pwd = 'password';

try {
  const result = await NetworkUser.login(param);
  if (Completion.isSuccess(result)) {
    console.log('登录成功', result.data.user);
  } else if (Completion.isOther(result)) {
    console.log('需要验证码', result.data.url, result.data.msg);
  }
} catch (err) {
  console.error('登录失败', (err as Error).message);
}

// 3. 申请上机
try {
  const result = await NetworkGame.apply(busId, 0);
  if (Completion.isSuccess(result)) {
    console.log('上机成功', result.data.optId);
  } else if (Completion.isOther(result)) {
    console.log('已在其他机器', result.data.doll, result.data.msg);
  }
} catch (err) {
  console.error('上机失败', (err as Error).message);
}

模块说明

| 导出 | 说明 | |------|------| | wwdNetwork | 网络单例,负责 init() 与全局配置 | | WwdNetworkConfig | baseUrl、请求超时(毫秒) | | WwdHeader | 请求头,链式 setXxx() | | NetworkTool | 底层 POST / arrayBuffer | | API | 各模块接口路径 | | NetworkUser / NetworkGame / … | 业务接口类 | | Completion | 成功 / 其他 结果包装,isSuccess / isOther 类型守卫 |

开发

npm install
npm run build

build 会先清理 dist 再编译,避免残留旧文件。

License

MIT