const got = require('@/utils/got'); const date = require('@/utils/date'); module.exports = async (ctx) => { const topic = ctx.params.topic || ''; const type = ctx.params.type || 'true'; const rootUrl = 'https://www.dedao.cn'; const detailUrl = `${rootUrl}/pc/ledgers/topic/detail`; const currentUrl = `${rootUrl}/knowledge${topic === '' ? '' : '/topic/' + topic}`; const apiUrl = `${rootUrl}/pc/ledgers/${topic === '' ? 'notes/friends_timeline' : 'topic/notes/list'}`; let title = '', description = ''; if (topic !== '') { const detailResponse = await got({ method: 'post', url: detailUrl, json: { incr_view_count: false, topic_id_hazy: topic, }, }); title = detailResponse.data.c.name; description = detailResponse.data.c.intro; } const response = await got({ method: 'post', url: apiUrl, json: { count: 20, load_chain: true, is_elected: type === 'true', page_id: 0, topic_id_hazy: topic, version: 2, }, }); const items = (topic === '' ? response.data.c.notes : response.data.c.note_detail_list).map((item) => { let s_part = ''; if (item.s_part) { const s_author = `
引用 ${item.s_part.nick_name} (${item.s_part.v_info}):
`; const s_content = `${item.s_part.note.replace(/\n\n/g, '
')}
[查看原文]`; let s_images = '${item.f_part.note.replace(/\n\n/g, '
')}
${f_images}