灏天阁

Node/Koa2[67]:@和回复功能

· Yin灏

GITHUB 查询并使用 At.js

  • 插件链接:https://github.com/ichord/At.js

处理@接口

// src/routes/api/user.js
// 获取 at 列表,即关注人列表
const { getFollowers } = require("../../controller/user-relation");
router.get("/getAtList", loginCheck, async (ctx, next) => {
  const { id: userId } = ctx.session.userInfo;
  const result = await getFollowers(userId);
  const { followersList } = result.data;
  const list = followersList.map((user) => {
    return `${user.nickName} - ${user.userName}`;
  });
  ctx.body = list;
});

- Book Lists -