utils.jq(() => { $(function () { const el = document.querySelector('.ds-twikoo'); utils.onLoading(el); // 加载动画 const api = el.getAttribute('api'); const limit = parseInt(el.getAttribute('limit')) || 10; const reply = el.getAttribute('hide') !== 'reply'; if (!api) return; fetch(api, { method: "POST", body: JSON.stringify({ "event": "GET_RECENT_COMMENTS", "envId": api, "pageSize": limit, "includeReply": reply }), headers: { 'Content-Type': 'application/json' } }) .then(res => res.json()) .then(({ data }) => { utils.onLoadSuccess(el); // 移除动画 data.forEach((comment, j) => { let commentText = comment.commentText; if (!commentText || commentText.trim() === '') return; // 跳过空评论 // 转义字符 commentText = commentText.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); commentText = commentText.length > 50 ? commentText.substring(0, 50) + '...' : commentText; var cell = '