dna-api 0.2.9 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +563 -0
- package/dist/TimeBasicResponse.d.ts +16 -0
- package/dist/index.d.ts +250 -1078
- package/dist/index.js +4 -4
- package/dist/index.js.map +16 -4
- package/dist/modules/base.d.ts +57 -0
- package/dist/modules/game.d.ts +14 -0
- package/dist/modules/h5.d.ts +99 -0
- package/dist/modules/home.d.ts +120 -0
- package/dist/modules/profile.d.ts +40 -0
- package/dist/modules/setting.d.ts +24 -0
- package/dist/modules/trend.d.ts +22 -0
- package/dist/modules/types.d.ts +14 -0
- package/dist/modules/user.d.ts +40 -0
- package/dist/modules/usergrowing.d.ts +30 -0
- package/dist/modules/utils.d.ts +36 -0
- package/dist/type-generated.d.ts +1611 -0
- package/package.json +8 -3
- package/build.ts +0 -10
- package/src/api.test.ts +0 -12
- package/src/index.ts +0 -1910
- package/tsconfig.build.json +0 -109
- package/tsconfig.json +0 -103
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 pa001024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
# dna-api
|
|
2
|
+
|
|
3
|
+
> DNA BBS API - 用于游戏《Duet Night Abyss》的官方论坛 API 客户端
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dna-api)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## 目录
|
|
9
|
+
|
|
10
|
+
- [简介](#简介)
|
|
11
|
+
- [安装](#安装)
|
|
12
|
+
- [快速开始](#快速开始)
|
|
13
|
+
- [核心功能](#核心功能)
|
|
14
|
+
- [API 文档](#api-文档)
|
|
15
|
+
- [DNAAPI 类](#dnaapi-类)
|
|
16
|
+
- [GameAPI 模块](#gameapi-模块)
|
|
17
|
+
- [HomeAPI 模块](#homeapi-模块)
|
|
18
|
+
- [ProfileAPI 模块](#profileapi-模块)
|
|
19
|
+
- [SettingAPI 模块](#settingapi-模块)
|
|
20
|
+
- [TrendAPI 模块](#trendapi-模块)
|
|
21
|
+
- [UserAPI 模块](#userapi-模块)
|
|
22
|
+
- [UserGrowingAPI 模块](#usergrowingapi-模块)
|
|
23
|
+
- [H5API 模块](#h5api-模块)
|
|
24
|
+
- [类型定义](#类型定义)
|
|
25
|
+
- [配置选项](#配置选项)
|
|
26
|
+
- [开发与构建](#开发与构建)
|
|
27
|
+
- [测试](#测试)
|
|
28
|
+
- [许可证](#许可证)
|
|
29
|
+
|
|
30
|
+
## 简介
|
|
31
|
+
|
|
32
|
+
`dna-api` 是一个 TypeScript 编写的 API 客户端库,用于与《Duet Night Abyss》游戏的官方论坛服务器进行交互。该库提供了完整的 API 封装,包括用户认证、帖子发布、评论管理、角色管理等功能。
|
|
33
|
+
|
|
34
|
+
### 特性
|
|
35
|
+
|
|
36
|
+
- ✅ **完整的 TypeScript 类型支持** - 提供完整的类型定义,享受类型检查和智能提示
|
|
37
|
+
- ✅ **自动签名机制** - 内置 RSA 签名和 MD5 加密,无需手动处理签名
|
|
38
|
+
- ✅ **自动重试机制** - 请求失败时自动重试(最多 3 次)
|
|
39
|
+
- ✅ **超时控制** - 默认 10 秒超时,可配置
|
|
40
|
+
- ✅ **模块化设计** - 按功能模块划分,易于维护和扩展
|
|
41
|
+
- ✅ **浏览器和 Node.js 兼容** - 支持在浏览器和 Node.js 环境中使用
|
|
42
|
+
|
|
43
|
+
## 安装
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm install dna-api
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
或使用 npm/yarn/bun:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install dna-api
|
|
53
|
+
yarn add dna-api
|
|
54
|
+
bun add dna-api
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 快速开始
|
|
58
|
+
|
|
59
|
+
### 基础使用
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { DNAAPI } from "dna-api"
|
|
63
|
+
|
|
64
|
+
// 初始化 API 客户端
|
|
65
|
+
const api = new DNAAPI({
|
|
66
|
+
dev_code: "", // 开发者代码(可选)
|
|
67
|
+
token: "", // 用户令牌(登录后获取)
|
|
68
|
+
// 可选配置
|
|
69
|
+
// fetchFn: fetch, // 自定义 fetch 函数
|
|
70
|
+
// is_h5: false, // 是否为 H5 环境
|
|
71
|
+
// rsa_public_key: "", // 自定义 RSA 公钥
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// 获取基础配置
|
|
75
|
+
async function getCommonConfig() {
|
|
76
|
+
const config = await api.user.getCommonConfig()
|
|
77
|
+
if (config.success) {
|
|
78
|
+
console.log("配置获取成功:", config.data)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getCommonConfig()
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 用户登录
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { DNAAPI } from "dna-api"
|
|
89
|
+
|
|
90
|
+
const api = new DNAAPI()
|
|
91
|
+
|
|
92
|
+
async function loginUser(mobile: string) {
|
|
93
|
+
// 1. 获取验证码
|
|
94
|
+
const smsRes = await api.user.sendSms(mobile, "阿里验证码vJson...")
|
|
95
|
+
if (!smsRes.success) {
|
|
96
|
+
console.error("验证码发送失败")
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 2. 用户输入验证码后登录
|
|
101
|
+
const loginRes = await api.login(mobile, "123456")
|
|
102
|
+
if (loginRes.success && loginRes.data?.token) {
|
|
103
|
+
// 保存 token
|
|
104
|
+
api.token = loginRes.data.token
|
|
105
|
+
console.log("登录成功")
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 获取帖子列表
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
async function getPosts() {
|
|
114
|
+
const posts = await api.getPostList(48, 1, 20)
|
|
115
|
+
if (posts.success && posts.data) {
|
|
116
|
+
console.log("帖子列表:", posts.data.postList)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 核心功能
|
|
122
|
+
|
|
123
|
+
### 1. 用户认证
|
|
124
|
+
|
|
125
|
+
- 手机号验证码登录
|
|
126
|
+
- 用户注册
|
|
127
|
+
- Token 刷新
|
|
128
|
+
- 用户信息管理
|
|
129
|
+
|
|
130
|
+
### 2. 论坛功能
|
|
131
|
+
|
|
132
|
+
- 发布帖子
|
|
133
|
+
- 评论和回复
|
|
134
|
+
- 点赞和收藏
|
|
135
|
+
- 帖子搜索
|
|
136
|
+
|
|
137
|
+
### 3. 游戏角色管理
|
|
138
|
+
|
|
139
|
+
- 获取角色详情
|
|
140
|
+
- 获取武器详情
|
|
141
|
+
- 角色绑定和管理
|
|
142
|
+
- 魂印任务
|
|
143
|
+
|
|
144
|
+
### 4. 个人中心
|
|
145
|
+
|
|
146
|
+
- 个人资料管理
|
|
147
|
+
- 粉丝和关注
|
|
148
|
+
- 历史记录
|
|
149
|
+
- 黑名单管理
|
|
150
|
+
|
|
151
|
+
### 5. 用户成长
|
|
152
|
+
|
|
153
|
+
- 签到系统
|
|
154
|
+
- 任务系统
|
|
155
|
+
- 等级系统
|
|
156
|
+
- 商城和抽奖
|
|
157
|
+
|
|
158
|
+
## API 文档
|
|
159
|
+
|
|
160
|
+
### DNAAPI 类
|
|
161
|
+
|
|
162
|
+
主要的 API 客户端类,包含所有 API 模块的便捷方法。
|
|
163
|
+
|
|
164
|
+
#### 构造函数
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
new DNAAPI(options: {
|
|
168
|
+
dev_code?: string; // 设备代码, 留空自动生成
|
|
169
|
+
token?: string; // 用户令牌
|
|
170
|
+
fetchFn?: typeof fetch; // 自定义 fetch 函数
|
|
171
|
+
is_h5?: boolean; // 是否为 H5 环境
|
|
172
|
+
rsa_public_key?: string; // 自定义 RSA 公钥
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### 属性
|
|
177
|
+
|
|
178
|
+
| 属性 | 类型 | 描述 |
|
|
179
|
+
| ------------- | ---------------- | --------------------- |
|
|
180
|
+
| `GAME_ID` | `number` | 游戏 ID(固定为 268) |
|
|
181
|
+
| `token` | `string` | 用户访问令牌 |
|
|
182
|
+
| `dev_code` | `string` | 开发者代码 |
|
|
183
|
+
| `BASE_URL` | `string` | API 基础地址 |
|
|
184
|
+
| `game` | `GameAPI` | 游戏相关 API 模块 |
|
|
185
|
+
| `home` | `HomeAPI` | 首页/论坛 API 模块 |
|
|
186
|
+
| `profile` | `ProfileAPI` | 个人中心 API 模块 |
|
|
187
|
+
| `setting` | `SettingAPI` | 设置 API 模块 |
|
|
188
|
+
| `trend` | `TrendAPI` | 动态/帖子 API 模块 |
|
|
189
|
+
| `user` | `UserAPI` | 用户 API 模块 |
|
|
190
|
+
| `userGrowing` | `UserGrowingAPI` | 用户成长 API 模块 |
|
|
191
|
+
| `h5` | `H5API` | H5 游戏相关 API 模块 |
|
|
192
|
+
|
|
193
|
+
#### 方法
|
|
194
|
+
|
|
195
|
+
##### 初始化
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
async initialize(): Promise<void>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
手动初始化 API 配置(获取签名配置等)。
|
|
202
|
+
|
|
203
|
+
### GameAPI 模块
|
|
204
|
+
|
|
205
|
+
游戏相关的 API 方法。
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// 获取默认角色(用于工具)
|
|
209
|
+
api.game.defaultRoleForTool(otherUserId?: string, type?: number)
|
|
210
|
+
|
|
211
|
+
// 获取角色详情
|
|
212
|
+
api.game.getRoleDetail(char_id: string, char_eid: string, otherUserId?: string)
|
|
213
|
+
|
|
214
|
+
// 获取武器详情
|
|
215
|
+
api.game.getWeaponDetail(weapon_id: string, weapon_eid: string, otherUserId?: string)
|
|
216
|
+
|
|
217
|
+
// 获取简短笔记信息
|
|
218
|
+
api.game.getShortNoteInfo()
|
|
219
|
+
|
|
220
|
+
// 获取魂印任务
|
|
221
|
+
api.game.soulTask()
|
|
222
|
+
|
|
223
|
+
// 获取/更新推送开关状态
|
|
224
|
+
api.game.getMhSwitchStatus()
|
|
225
|
+
api.game.updateMhSwitchStatus(config: string)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### HomeAPI 模块
|
|
229
|
+
|
|
230
|
+
首页和论坛相关的 API 方法。
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// 获取帖子列表
|
|
234
|
+
api.getPostList(forumId?: number, pageIndex?: number, pageSize?: number, searchType?: number, timeType?: number)
|
|
235
|
+
|
|
236
|
+
// 获取帖子详情
|
|
237
|
+
api.getPostDetail(postId: string)
|
|
238
|
+
|
|
239
|
+
// 按主题获取帖子
|
|
240
|
+
api.getPostByTopic(topicId?: number, pageIndex?: number, pageSize?: number, searchType?: number, timeType?: number)
|
|
241
|
+
|
|
242
|
+
// 获取推荐帖子
|
|
243
|
+
api.getRecommendPosts(gameId?: number, pageIndex?: number, pageSize?: number)
|
|
244
|
+
|
|
245
|
+
// 获取游戏横幅
|
|
246
|
+
api.getGameBanner(gameId?: number)
|
|
247
|
+
|
|
248
|
+
// 获取帖子评论列表
|
|
249
|
+
api.getPostCommentList(postId: number, pageIndex?: number, pageSize?: number, isOnlyPublisher?: number)
|
|
250
|
+
|
|
251
|
+
// 创建评论
|
|
252
|
+
api.createComment(post: {...}, content: string)
|
|
253
|
+
|
|
254
|
+
// 创建回复
|
|
255
|
+
api.createReply(post: {...}, content: string)
|
|
256
|
+
|
|
257
|
+
// 点赞帖子
|
|
258
|
+
api.likePost(post: {...})
|
|
259
|
+
|
|
260
|
+
// 搜索帖子/主题/用户
|
|
261
|
+
api.searchPost(keyword: string, pageIndex: number, pageSize: number, gameId?: number, searchType?: number)
|
|
262
|
+
api.searchTopic(keyword: string, pageIndex: number, pageSize?: number, gameId?: number)
|
|
263
|
+
api.searchUser(keyword: string, pageIndex: number, pageSize: number)
|
|
264
|
+
|
|
265
|
+
// 签到
|
|
266
|
+
api.haveSignIn()
|
|
267
|
+
api.signCalendar()
|
|
268
|
+
api.gameSign(dayAwardId: number, period: number)
|
|
269
|
+
api.bbsSign()
|
|
270
|
+
|
|
271
|
+
// 管理员功能
|
|
272
|
+
api.adminAdjustScore(postId: number, gameForumId: number, weight: string)
|
|
273
|
+
api.adminDelete(post: {...}, content: string, reasonCode: number)
|
|
274
|
+
api.adminMovePost(post: {...}, newGameId: number, newForumId: number, newTopicIdStr: string)
|
|
275
|
+
api.adminRefreshTime(post: {...}, refresh: number)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### ProfileAPI 模块
|
|
279
|
+
|
|
280
|
+
个人中心相关的 API 方法。
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
// 获取个人信息
|
|
284
|
+
api.getMine()
|
|
285
|
+
api.getOtherMine(userId?: string)
|
|
286
|
+
|
|
287
|
+
// 获取角色列表
|
|
288
|
+
api.getRoleList()
|
|
289
|
+
|
|
290
|
+
// 默认角色
|
|
291
|
+
api.profile.defaultRole(otherUserId?: string, type?: number)
|
|
292
|
+
|
|
293
|
+
// 粉丝/关注
|
|
294
|
+
api.profile.fans(otherUserId: string, pageNo: number, pageSize: number, type: number)
|
|
295
|
+
api.profile.follow(otherUserId: string, pageNo: number, pageSize: number, type: number)
|
|
296
|
+
|
|
297
|
+
// 获取草稿列表
|
|
298
|
+
api.profile.getDraftList(pageIndex: number, pageSize: number)
|
|
299
|
+
|
|
300
|
+
// 删除角色
|
|
301
|
+
api.profile.deleteRole(roleBoundId: string)
|
|
302
|
+
|
|
303
|
+
// 黑名单用户
|
|
304
|
+
api.profile.blackUser(toUserId: string, type: number)
|
|
305
|
+
|
|
306
|
+
// 重置默认角色
|
|
307
|
+
api.profile.resetDefault(roleBoundId: string)
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### SettingAPI 模块
|
|
311
|
+
|
|
312
|
+
设置相关的 API 方法。
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
// 地址管理
|
|
316
|
+
api.addAddress(receiverName: string, receiverMobile: string, receiverAddress: string)
|
|
317
|
+
api.editAddress(addressId: number, receiverName: string, receiverMobile: string, receiverAddress: string)
|
|
318
|
+
api.deleteAddress(addressId: number)
|
|
319
|
+
api.getUserAddress(userId: number, type: number)
|
|
320
|
+
api.setDefaultAddress(addressId: number)
|
|
321
|
+
|
|
322
|
+
// 反馈
|
|
323
|
+
api.feedback(listPic: string, proDesc: string, mobile: string, isLogin: number)
|
|
324
|
+
|
|
325
|
+
// 黑名单
|
|
326
|
+
api.getUserBlackList(pageIndex: number, pageSize: number)
|
|
327
|
+
|
|
328
|
+
// 通知设置
|
|
329
|
+
api.setNotifySwitch(operateType: number, switchType: number)
|
|
330
|
+
api.setting.getNotifySwitch()
|
|
331
|
+
|
|
332
|
+
// 隐私设置
|
|
333
|
+
api.privateSet(operateType: number, option: number)
|
|
334
|
+
api.setting.getPrivateSet()
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### TrendAPI 模块
|
|
338
|
+
|
|
339
|
+
动态和帖子发布相关的 API 方法。
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
// 发布帖子
|
|
343
|
+
api.trend.postPublish(content: string, draftId: string, gameForumId: number, gameId: number, h5Content: string, postTitle: string, postType: number, topics: string)
|
|
344
|
+
|
|
345
|
+
// 编辑帖子
|
|
346
|
+
api.trend.postEdit(content: string, gameForumId: number, h5Content: string, postId: string, postTitle: string, topics: string, postType: number, videoReUpload: number)
|
|
347
|
+
|
|
348
|
+
// 保存草稿
|
|
349
|
+
api.trend.draftSave(content: string, draftId: string, h5Content: string, postTitle: string, postType: number, gameId: number, videoReUpload: number)
|
|
350
|
+
|
|
351
|
+
// 获取发布页面信息
|
|
352
|
+
api.trend.getPostPublishPage()
|
|
353
|
+
|
|
354
|
+
// 获取话题列表
|
|
355
|
+
api.trend.getConfigTopicByGameId(name: string, showType: number)
|
|
356
|
+
|
|
357
|
+
// 解析链接
|
|
358
|
+
api.trend.parseLink(link: string)
|
|
359
|
+
|
|
360
|
+
// 上传图片
|
|
361
|
+
api.trend.uploadImage(t: string, parts: FormData, type: string)
|
|
362
|
+
|
|
363
|
+
// 获取视频上传令牌
|
|
364
|
+
api.trend.getVodToken(fileName: string, title: string)
|
|
365
|
+
|
|
366
|
+
// 安全检查
|
|
367
|
+
api.trend.safeCheck(url: string)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### UserAPI 模块
|
|
371
|
+
|
|
372
|
+
用户认证和设置相关的 API 方法。
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
// 用户登录
|
|
376
|
+
api.user.login(loginType: number, sdkToken: string, code: string, gameList: string, mobile: string)
|
|
377
|
+
|
|
378
|
+
// 用户注册
|
|
379
|
+
api.user.register(code: string, devCode: string, gameList: string, mobile: string, password: string)
|
|
380
|
+
|
|
381
|
+
// 获取验证码
|
|
382
|
+
api.user.sendSms(mobile: string, vJson: string, isCaptcha: number | null)
|
|
383
|
+
|
|
384
|
+
// 刷新令牌
|
|
385
|
+
api.user.refreshToken(refreshToken: string)
|
|
386
|
+
|
|
387
|
+
// 用户信息管理
|
|
388
|
+
api.user.editNickName(userName: string)
|
|
389
|
+
api.user.canEditNickName()
|
|
390
|
+
api.user.editGender(gender: number)
|
|
391
|
+
api.user.saveUserInfo(gender: number | null, headCode: string, headUrl: string, userName: string)
|
|
392
|
+
|
|
393
|
+
// 头像管理
|
|
394
|
+
api.user.updateHeadCode(headCode: string)
|
|
395
|
+
api.user.updateHeadUrl(headUrl: string)
|
|
396
|
+
api.user.uploadImage(t: string, part: FormData)
|
|
397
|
+
|
|
398
|
+
// 个人签名
|
|
399
|
+
api.user.signature(newSignature: string)
|
|
400
|
+
|
|
401
|
+
// 获取配置
|
|
402
|
+
api.user.getConfig()
|
|
403
|
+
api.user.getCommonConfig()
|
|
404
|
+
api.user.getConfigSwitch()
|
|
405
|
+
api.user.getOpenScreen()
|
|
406
|
+
|
|
407
|
+
// 获取表情包
|
|
408
|
+
api.user.getEmoji()
|
|
409
|
+
|
|
410
|
+
// 获取游戏配置
|
|
411
|
+
api.user.getGameConfig()
|
|
412
|
+
api.user.getGameHeadCode()
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### UserGrowingAPI 模块
|
|
416
|
+
|
|
417
|
+
用户成长和奖励相关的 API 方法。
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
// 创作者申请
|
|
421
|
+
api.userGrowing.apply(type: number, id: number | null, concatWay: string, otherPlatform: string, otherPlatformUrl: string, otherPlatformFans: string, materialUrl: string, gameId: number | null)
|
|
422
|
+
|
|
423
|
+
// 抽奖
|
|
424
|
+
api.userGrowing.list(pageIndex: number, pageSize: number, queryType: number | null, gameId: number | null)
|
|
425
|
+
api.userGrowing.drawDetail(drawId: number)
|
|
426
|
+
api.userGrowing.buyGold(drawId: number, count: number)
|
|
427
|
+
api.userGrowing.awardList(drawId: number)
|
|
428
|
+
api.userGrowing.awardWin(drawId: number, fullName: string, mobile: string, address: string)
|
|
429
|
+
|
|
430
|
+
// 商城
|
|
431
|
+
api.userGrowing.getProductList(gameId: number | null, pageIndex: number, pageSize: number, storeType: number)
|
|
432
|
+
api.userGrowing.productDetail(productId: number)
|
|
433
|
+
api.userGrowing.buyProduct(address: string, fullName: string, mobile: string, productId: number)
|
|
434
|
+
api.userGrowing.getAliProductConfig()
|
|
435
|
+
api.userGrowing.getAliProductList(gameId: number | null, pageIndex: number, pageSize: number)
|
|
436
|
+
|
|
437
|
+
// 金币管理
|
|
438
|
+
api.userGrowing.getTotalGold(type?: number)
|
|
439
|
+
api.userGrowing.getGoldDetailList(pageIndex: number, pageSize: number, type: number, storeType: number)
|
|
440
|
+
|
|
441
|
+
// 等级和任务
|
|
442
|
+
api.userGrowing.getUserGameLevel(gameId: number | null, ifProcess: number, otherUserId: number | null)
|
|
443
|
+
api.userGrowing.getUserGameTaskProcess(gameId: number, userId: number)
|
|
444
|
+
api.userGrowing.getExpLogsList(gameId: number, pageIndex: number, pageSize: number)
|
|
445
|
+
|
|
446
|
+
// 创作者页面
|
|
447
|
+
api.userGrowing.page()
|
|
448
|
+
api.userGrowing.getApplyPage()
|
|
449
|
+
api.userGrowing.getGameCreator()
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### H5API 模块
|
|
453
|
+
|
|
454
|
+
H5 游戏相关的 API 方法。
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
// 地图相关
|
|
458
|
+
api.h5.getMapCategorizeList()
|
|
459
|
+
api.h5.getMapDetail(id: number)
|
|
460
|
+
api.h5.getMapSiteDetail(id: number)
|
|
461
|
+
api.h5.getMapMatterCategorizeOptions()
|
|
462
|
+
|
|
463
|
+
// 表情包
|
|
464
|
+
api.h5.getEmojiList()
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
## 类型定义
|
|
468
|
+
|
|
469
|
+
### TimeBasicResponse
|
|
470
|
+
|
|
471
|
+
API 响应的基础类。
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
class TimeBasicResponse<T = any> {
|
|
475
|
+
code: number // 响应码
|
|
476
|
+
msg: string // 响应消息
|
|
477
|
+
data?: T // 响应数据
|
|
478
|
+
|
|
479
|
+
get is_success(): boolean // 是否成功
|
|
480
|
+
get success(): boolean // 是否成功(别名)
|
|
481
|
+
|
|
482
|
+
static err<T = undefined>(msg: string, code?: number): TimeBasicResponse<T>
|
|
483
|
+
}
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### RespCode
|
|
487
|
+
|
|
488
|
+
响应码枚举。
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
enum RespCode {
|
|
492
|
+
ERROR = -999, // 错误
|
|
493
|
+
OK_ZERO = 0, // 成功(0)
|
|
494
|
+
OK_HTTP = 200, // 成功(200)
|
|
495
|
+
BAD_REQUEST = 400, // 请求错误
|
|
496
|
+
SERVER_ERROR = 500, // 服务器错误
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### DNASubModule
|
|
501
|
+
|
|
502
|
+
所有 API 子模块的基类。
|
|
503
|
+
|
|
504
|
+
```typescript
|
|
505
|
+
abstract class DNASubModule {
|
|
506
|
+
protected _base: DNABaseAPI
|
|
507
|
+
|
|
508
|
+
get dev_code(): string
|
|
509
|
+
get token(): string
|
|
510
|
+
get fetchFn(): typeof fetch | undefined
|
|
511
|
+
get is_h5(): boolean
|
|
512
|
+
get RSA_PUBLIC_KEY(): string
|
|
513
|
+
get BASE_URL(): string
|
|
514
|
+
|
|
515
|
+
async _dna_request<T>(url: string, data?: any, options?: RequestOptions): Promise<TimeBasicResponse<T>>
|
|
516
|
+
async _dna_request_h5<T>(url: string, data?: any, options?: RequestOptions): Promise<TimeBasicResponse<T>>
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### RequestOptions
|
|
521
|
+
|
|
522
|
+
请求选项接口。
|
|
523
|
+
|
|
524
|
+
```typescript
|
|
525
|
+
interface RequestOptions {
|
|
526
|
+
method?: "GET" | "POST" // HTTP 方法
|
|
527
|
+
sign?: boolean // 是否签名
|
|
528
|
+
file?: File // 文件
|
|
529
|
+
tokenSig?: boolean // 是否使用 token 签名
|
|
530
|
+
h5?: boolean // 是否为 H5 请求
|
|
531
|
+
token?: boolean // 是否使用 token
|
|
532
|
+
refer?: boolean // 是否添加 referer
|
|
533
|
+
params?: Record<string, any> // 额外参数
|
|
534
|
+
max_retries?: number // 最大重试次数(默认 3)
|
|
535
|
+
retry_delay?: number // 重试延迟(默认 1 秒)
|
|
536
|
+
timeout?: number // 超时时间(默认 10000 毫秒)
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
## 配置选项
|
|
541
|
+
|
|
542
|
+
### 初始化配置
|
|
543
|
+
|
|
544
|
+
```typescript
|
|
545
|
+
interface DNAAPIOptions {
|
|
546
|
+
dev_code?: string // 开发者代码
|
|
547
|
+
token?: string // 用户令牌
|
|
548
|
+
fetchFn?: typeof fetch // 自定义 fetch 函数
|
|
549
|
+
is_h5?: boolean // 是否为 H5 环境
|
|
550
|
+
rsa_public_key?: string // 自定义 RSA 公钥
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### 示例配置
|
|
555
|
+
|
|
556
|
+
```typescript
|
|
557
|
+
const api = new DNAAPI({
|
|
558
|
+
dev_code: "your_dev_code",
|
|
559
|
+
token: "your_token",
|
|
560
|
+
is_h5: true, // H5 环境
|
|
561
|
+
// fetchFn: customFetch, // 自定义 fetch 函数
|
|
562
|
+
})
|
|
563
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum RespCode {
|
|
2
|
+
ERROR = -999,
|
|
3
|
+
OK_ZERO = 0,
|
|
4
|
+
OK_HTTP = 200,
|
|
5
|
+
BAD_REQUEST = 400,
|
|
6
|
+
SERVER_ERROR = 500
|
|
7
|
+
}
|
|
8
|
+
export declare class TimeBasicResponse<T = any> {
|
|
9
|
+
code: number;
|
|
10
|
+
msg: string;
|
|
11
|
+
data?: T;
|
|
12
|
+
constructor(raw_data: any);
|
|
13
|
+
get is_success(): boolean;
|
|
14
|
+
get success(): boolean;
|
|
15
|
+
static err<T = undefined>(msg: string, code?: number): TimeBasicResponse<T>;
|
|
16
|
+
}
|