Skip to content

EXP & Points Mock API

源码: web/src/mock/modules/user/exp-points.ts

接口列表

方法路径说明
GET/api/v1/users/me/exp获取当前经验值
POST/api/v1/users/me/exp增加经验值
GET/api/v1/users/me/points获取当前积分
POST/api/v1/users/me/points增加积分(自动记录日志)

请求参数

GET /api/v1/users/me/exp

无请求参数。

POST /api/v1/users/me/exp

参数类型必填说明
amountnumber增加的经验值(必须 > 0)

GET /api/v1/users/me/points

无请求参数。

POST /api/v1/users/me/points

参数类型必填说明
amountnumber增加的积分(必须 > 0)
sourcestring积分来源标识
sourceIdstring关联资源ID
descstring描述信息

POST 积分时会自动在 pointLog 中追加一条记录(包含 id、type、amount、balance、source、sourceId、desc、time)。

响应格式

GET /api/v1/users/me/exp

json
{ "code": 0, "msg": "ok", "data": { "totalEXP": 1200 } }

POST /api/v1/users/me/exp

json
{ "code": 0, "msg": "ok", "data": { "totalEXP": 1210, "added": 10 } }

GET /api/v1/users/me/points

json
{ "code": 0, "msg": "ok", "data": { "shopPoints": 150 } }

POST /api/v1/users/me/points

json
{ "code": 0, "msg": "ok", "data": { "shopPoints": 155, "added": 5 } }

被哪个 Store 调用

  • UserStore (web/src/stores/user.ts)
    • addEXP(amount)POST /api/v1/users/me/exp
    • addPoints(amount, source, sourceId, desc)POST /api/v1/users/me/points
  • AchievementStore (web/src/stores/achievement.ts)
    • 通过 user.addEXP() / user.addPoints() 间接调用