打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

赞助会员:修订间差异

来自方块乐事
创建页面,内容为“<div id="contributor-container"> <div class="jiazai">数据加载中...</div> </div> <style> .grid-container { display: grid; grid-template-columns: repeat( auto-fill, minmax(100px, 1fr) ); 自动填充网格列,每列最小200px,最大1fr:​ gap: 20px; 设置网格项之间的间距:​ padding: 20px;:​ margin-bottom: 1em; } .card { display: flex; flex-direction: column; 设置项目垂直排列:​ align-items: cen…”
 
页面内容被替换为“{{widget:afd}}”
第1行: 第1行:
<div id="contributor-container">
{{widget:afd}}
  <div class="jiazai">数据加载中...</div>
</div>
 
<style>
.grid-container {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(100px, 1fr)
  ); /* 自动填充网格列,每列最小200px,最大1fr */
  gap: 20px; /* 设置网格项之间的间距 */
  /* padding: 20px; */
  margin-bottom: 1em;
}
 
.card {
  display: flex;
  flex-direction: column; /* 设置项目垂直排列 */
  align-items: center; /* 水平居中对齐项目 */
  background: #f9f9f9; /* 浅灰色背景 */
  border-radius: 10px; /* 圆角 */
  padding: 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 盒子阴影 */
}
 
.avatar {
  width: 60px; /* 头像宽度 */
  height: 60px; /* 头像高度 */
  border-radius: 50%; /* 圆形头像 */
  margin-bottom: 10px; /* 头像与下面文本的间距 */
}
 
.info {
  text-align: center; /* 文本居中 */
  width: 100%;
}
 
.name {
  font-size: 16px; /* 字体大小 */
  color: #333; /* 字体颜色 */
  margin-bottom: 5px; /* 与金额间距 */
  word-wrap: break-word;
}
 
.amount {
  font-size: 14px;
  color: #666;
}
 
.jiazai {
    min-height: 101vh;
}
</style>
 
<script>
// 等待页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
  const container = document.getElementById('contributor-container');
 
  // 发起请求(和原 React 代码的 /afd.php 接口一致)
  fetch('/afd.php')
    .then(response => {
      if (!response.ok) throw new Error('接口请求失败');
      return response.json();
    })
    .then(data => {
      if (data.length === 0) {
        container.innerHTML = '<div class="jiazai">暂无贡献伙伴数据~</div>';
        return;
      }
 
      // 渲染贡献伙伴列表
      let html = '<div class="grid-container">';
      data.forEach((sponsor, index) => {
        // 避免空头像/空名称导致的显示异常
        const avatarSrc = sponsor.avatar || 'https://via.placeholder.com/80'; // 占位图
        const sponsorName = sponsor.name || '匿名伙伴';
       
        html += `
          <div class="card" key="${index}">
            <img src="${avatarSrc}" alt="${sponsorName}" class="avatar" />
            <div class="info">
              <div class="name">${sponsorName}</div>
              <!-- 如需显示金额,取消下面注释: -->
              <!-- <div class="amount">¥${sponsor.amount || '0'}</div> -->
            </div>
          </div>
        `;
      });
      html += '</div>';
     
      container.innerHTML = html;
    })
    .catch(error => {
      console.error('加载失败:', error);
      container.innerHTML = '<div class="jiazai">数据加载失败,请稍后重试~</div>';
    });
});
</script>

2025年12月1日 (一) 13:24的版本