From d4dc1f247a080903a08cc50814dfb9a48cc70602 Mon Sep 17 00:00:00 2001 From: binaryify Date: Sat, 12 Sep 2020 15:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 33 +++++++++++++++++++++++++++++++++ docs/README.md | 9 +++++++++ module_example/test.ts | 9 +++++++++ 3 files changed, 51 insertions(+) create mode 100644 module_example/test.ts diff --git a/README.MD b/README.MD index 020a669..70a5c95 100644 --- a/README.MD +++ b/README.MD @@ -57,6 +57,39 @@ windows 下使用 git-bash 或者 cmder 等终端执行以下命令: $ set PORT=4000 && node app.js ``` +## 可以在Node.js调用 +v3.31.0后支持Node.js调用,导入的方法为`module`内的文件名,返回内容包含`status`和`body`,`status`为状态码,`body`为请求返回内容,参考`module_example` 文件夹下的 `test.js` +```js +const { login_cellphone, user_cloud } = require('NeteaseCloudMusicApi') +async function main() { + try { + const result = await login_cellphone({ + phone: '手机号', + password: '密码' + }) + console.log(result) + const result2 = await user_cloud({ + cookie: result.body.cookie // 凭证 + }) + console.log(result2.body) + + } catch (error) { + console.log(error) + } +} +main() +``` + +## 支持 TypeScript +```ts +// test.ts +import { banner } from 'NeteaseCloudMusicApi' +banner({ type:0 }).then(res=>{ + console.log(res) +}) +``` + + ## 使用文档 [文档地址](https://binaryify.github.io/NeteaseCloudMusicApi) diff --git a/docs/README.md b/docs/README.md index 143efa2..48a0ccc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -258,6 +258,15 @@ async function main() { main() ``` +## 支持 TypeScript +```ts +// test.ts +import { banner } from 'NeteaseCloudMusicApi' +banner({ type:0 }).then(res=>{ + console.log(res) +}) +``` + ## 更新到 v3.0 说明 !>2018.10.14 更新到 3.0.0,使用了模块化机制,因为部分接口参数和 url 做了调整,如还不想升级到 3.0.0,请查看 [v2 的文档](http://binaryify.github.io/NeteaseCloudMusicApi/#/v2), [更新日志](https://github.com/Binaryify/NeteaseCloudMusicApi/blob/master/CHANGELOG.MD), [2.0+下载地址](https://github.com/Binaryify/NeteaseCloudMusicApi/releases/tag/v2.20.5), 同时 2.0+ 将不再维护 diff --git a/module_example/test.ts b/module_example/test.ts new file mode 100644 index 0000000..47ad7dd --- /dev/null +++ b/module_example/test.ts @@ -0,0 +1,9 @@ +import { banner,lyric } from '../main' +banner({ type:0 }).then(res=>{ + console.log(res) +}) +lyric({ + id:"33894312" +}).then(res=>{ + console.log(res) +})