// ============================================================
// 📋 帖子列表
// ============================================================
let currentSort = 'latest';
let currentPage = 1;
let totalPages = 1;
const PAGE_SIZE = 20;
function renderFeed() {
const container = document.getElementById('postList');
container.innerHTML = '
加载中...
';
API.getPosts(currentSort, currentPage, PAGE_SIZE).then(result => {
const posts = result.data || [];
const pagination = result.pagination || { total: 0, totalPages: 1, page: 1 };
totalPages = pagination.totalPages || 1;
currentPage = pagination.page || 1;
if (posts.length === 0 && currentPage === 1) {
container.innerHTML =
'';
p.images.forEach(img => {
imagesHtml += '

';
});
imagesHtml += '
';
}
const replyCount = p.reply_count || 0;
html += `
${p.title || '无标题'}
${(p.content || '').replace(/\n/g, '
')}
${imagesHtml}
${replyCount}
${currentUser && currentUser.id === p.user_id ? `
` : ''}
`;
});
container.innerHTML = html;
// ============================================================
// 完整分页控件
// ============================================================
if (totalPages > 1) {
let paginationHtml = `