const getToken = require('./token'); const getIllusts = require('./api/getIllusts'); const config = require('@/config').value; module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { throw 'pixiv RSS is disabled due to the lack of relevant config'; } const id = ctx.params.id; if (!getToken()) { throw 'pixiv not login'; } const response = await getIllusts(id, getToken()); const illusts = response.data.illusts; const username = illusts[0].user.name; ctx.state.data = { title: `${username} 的 pixiv 动态`, link: `https://www.pixiv.net/users/${id}`, description: `${username} 的 pixiv 最新动态`, item: illusts.map((illust) => { const images = []; if (illust.page_count === 1) { images.push(`


画师:${username} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}
${images.join('')}`, link: `https://www.pixiv.net/artworks/${illust.id}`, }; }), }; };