模板:角色信息:修订间差异
外观
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
==================================================================== | ==================================================================== | ||
模板名称: 人物信息 | 模板名称: 人物信息 (无扩展依赖版) | ||
说明: | 说明: 无需 ParserFunctions 扩展,完全依靠前端 JS 控制显示隐藏。 | ||
使用方法: {{人物信息|参数1=值1|参数2=值2|...}} | 使用方法: {{人物信息|参数1=值1|参数2=值2|...}} | ||
参数: 姓名, 性别, 配音, 能力, 所属势力, 图片1~图片6, 标签1~标签6 | |||
==================================================================== | ==================================================================== | ||
--> | --> | ||
<includeonly> | <includeonly> | ||
<div class=" | <div class="ci-wrapper" style="max-width:720px;margin:0 auto;font-family:system-ui,'Microsoft YaHei',sans-serif;"> | ||
<style> | <style> | ||
. | .ci-wrapper * { box-sizing: border-box; } | ||
.ci-wrapper .ci-container { | |||
. | |||
border: 1px solid #e0e0e0; | border: 1px solid #e0e0e0; | ||
border-radius: 12px; | border-radius: 12px; | ||
padding: 20px 24px 24px 24px; | padding: 20px 24px 24px 24px; | ||
background: #fafafa; | background: #fafafa; | ||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) | box-shadow: 0 2px 8px rgba(0,0,0,0.06); | ||
} | } | ||
. | /* 图片区 */ | ||
padding: 6px 18px; | .ci-wrapper .ci-image-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; } | ||
.ci-wrapper .ci-tab-btn { | |||
padding: 6px 18px; border: 1px solid #d0d0d0; border-radius: 20px; | |||
background: #f5f5f5; | background: #f5f5f5; color: #555; font-size: 14px; cursor: pointer; | ||
transition: all 0.2s; user-select: none; font-weight: 500; | |||
transition: all 0. | |||
} | } | ||
. | .ci-wrapper .ci-tab-btn.active { background: #2c3e50; border-color: #2c3e50; color: #fff; } | ||
background: # | .ci-wrapper .ci-image-display { | ||
border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; | |||
background: #fff; min-height: 120px; display: flex; | |||
align-items: center; justify-content: center; position: relative; | |||
} | } | ||
. | .ci-wrapper .ci-img-item { display: none; width: 100%; text-align: center; padding: 8px; } | ||
.ci-wrapper .ci-img-item.active { display: block; } | |||
.ci-wrapper .ci-img-item img { | |||
max-width: 100%; max-height: 400px; height: auto; | |||
display: block; margin: 0 auto; border-radius: 4px; | |||
} | } | ||
. | .ci-wrapper .ci-no-image { color: #aaa; font-size: 15px; padding: 30px 0; display: block; } | ||
border: 1px solid #e0e0e0; | /* 表格区 */ | ||
.ci-wrapper .ci-info-table { | |||
width: 100%; border-collapse: collapse; | |||
background: #fff; | border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; | ||
background: #fff; margin-top: 18px; | |||
} | } | ||
. | .ci-wrapper .ci-info-table tr { border-bottom: 1px solid #f0f0f0; } | ||
.ci-wrapper .ci-info-table tr:last-child { border-bottom: none; } | |||
.ci-wrapper .ci-info-table td { | |||
padding: 12px 16px; vertical-align: top; line-height: 1.6; | |||
font-size: 15px; word-break: break-word; | |||
} | } | ||
. | .ci-wrapper .ci-info-table .ci-label { | ||
width: 20%; min-width: 80px; background: #f7f7f7; | |||
font-weight: 600; color: #333; text-align: center; | |||
border-right: 1px solid #eee; vertical-align: middle; | |||
} | } | ||
.ci-wrapper .ci-info-table .ci-value { width: 80%; color: #222; background: #fff; } | |||
.ci-wrapper .ci-empty-row td { color: #bbb; font-style: italic; text-align: center; background: #fafafa; } | |||
@media (max-width: 600px) { | @media (max-width: 600px) { | ||
. | .ci-wrapper .ci-container { padding: 14px 12px; } | ||
.ci-wrapper .ci-info-table td { padding: 10px 12px; font-size: 14px; } | |||
.ci-wrapper .ci-info-table .ci-label { min-width: 60px; font-size: 13px; } | |||
. | |||
. | |||
} | } | ||
</style> | </style> | ||
<div class="ci-container"> | <div class="ci-container"> | ||
<!-- ========== 图片区域 ========== --> | |||
<!-- ====== 图片区域 ====== --> | |||
<div class="ci-image-section"> | <div class="ci-image-section"> | ||
<div class="ci-image-tabs" id="ci-tabs-{{PAGEID}}"> | |||
<button class="ci-tab-btn" data-ci-index="0">{{{标签1|图1}}}</button> | |||
<button class="ci-tab-btn" data-ci-index="1">{{{标签2|图2}}}</button> | |||
<button class="ci-tab-btn" data-ci-index="2">{{{标签3|图3}}}</button> | |||
<button class="ci-tab-btn" data-ci-index="3">{{{标签4|图4}}}</button> | |||
<button class="ci-tab-btn" data-ci-index="4">{{{标签5|图5}}}</button> | |||
<button class="ci-tab-btn" data-ci-index="5">{{{标签6|图6}}}</button> | |||
</div> | |||
<div class="ci-image-display"> | |||
<div class="ci-img-item" data-ci-index="0"><img src="{{{图片1|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-img-item" data-ci-index="1"><img src="{{{图片2|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-img-item" data-ci-index="2"><img src="{{{图片3|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-img-item" data-ci-index="3"><img src="{{{图片4|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-img-item" data-ci-index="4"><img src="{{{图片5|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-img-item" data-ci-index="5"><img src="{{{图片6|}}}" alt="人物图片" loading="lazy" /></div> | |||
<div class="ci-no-image">📷 暂无图片</div> | |||
</div> | |||
</div> | </div> | ||
<!-- ====== 信息表格 ====== --> | <!-- ========== 信息表格 ========== --> | ||
<table class="ci-info-table"> | <table class="ci-info-table"> | ||
<tr class="ci-row"><td class="ci-label">姓名</td><td class="ci-value">{{{姓名|}}}</td></tr> | |||
<tr> | <tr class="ci-row"><td class="ci-label">性别</td><td class="ci-value">{{{性别|}}}</td></tr> | ||
<tr class="ci-row"><td class="ci-label">配音</td><td class="ci-value">{{{配音|}}}</td></tr> | |||
<tr class="ci-row"><td class="ci-label">能力</td><td class="ci-value">{{{能力|}}}</td></tr> | |||
<tr class="ci-row"><td class="ci-label">所属势力</td><td class="ci-value">{{{所属势力|}}}</td></tr> | |||
<tr> | |||
<tr> | |||
<tr> | |||
<tr> | |||
</table> | </table> | ||
</div> | </div> | ||
<!-- ========== | <!-- ========== 纯前端控制脚本 ========== --> | ||
<script> | <script> | ||
(function() { | |||
// 使用 IIFE 隔离作用域 | |||
var container = document.querySelector('.ci-wrapper .ci-container'); | |||
if (!container) return; | |||
// 1. 处理图片显示与选项卡 | |||
var tabs = container.querySelectorAll('.ci-tab-btn'); | |||
var items = container.querySelectorAll('.ci-img-item'); | |||
var noImageDiv = container.querySelector('.ci-no-image'); | |||
var hasImage = false; | |||
// 收集有效的图片 | |||
var validItems = []; | |||
items.forEach(function(item, index) { | |||
var img = item.querySelector('img'); | |||
var src = img ? img.getAttribute('src') : ''; | |||
// 如果图片链接为空或者只是占位符,视为无效 | |||
if (src && src.trim() !== '') { | |||
hasImage = true; | |||
validItems.push(index); | |||
item.style.display = 'block'; // 暂时显示,后续由 active 控制 | |||
} else { | |||
item.style.display = 'none'; | |||
if (tabs[index]) tabs[index].style.display = 'none'; | |||
} | |||
}); | |||
// | // 如果没有有效图片,显示占位,隐藏选项卡容器 | ||
if (!hasImage) { | |||
if (noImageDiv) noImageDiv.style.display = 'block'; | |||
var tabContainer = container.querySelector('.ci-image-tabs'); | |||
if (tabContainer) tabContainer.style.display = 'none'; | |||
// 隐藏所有图片项 | |||
items.forEach(function(item) { item.style.display = 'none'; }); | |||
} else { | |||
if (noImageDiv) noImageDiv.style.display = 'none'; | |||
// 默认激活第一个有效图片 | |||
var firstValid = validItems[0]; | |||
if (firstValid !== undefined) { | |||
// 激活对应的图片和选项卡 | |||
items.forEach(function(item, idx) { | |||
if (idx === firstValid) { | |||
item.style.display = 'block'; | |||
item.classList.add('active'); | |||
} else { | |||
item.style.display = 'none'; | |||
item.classList.remove('active'); | |||
} | |||
}); | |||
tabs.forEach(function(tab, idx) { | tabs.forEach(function(tab, idx) { | ||
if (idx === | if (idx === firstValid) { | ||
tab.classList.add('active'); | tab.classList.add('active'); | ||
} else { | } else { | ||
tab.classList.remove('active'); | tab.classList.remove('active'); | ||
} | } | ||
}); | }); | ||
} | |||
// 绑定点击切换事件 | |||
tabs.forEach(function(tab) { | |||
tab.addEventListener('click', function(e) { | |||
var index = parseInt(this.getAttribute('data-ci-index'), 10); | |||
if (isNaN(index)) return; | |||
// 只切换有效的图片 | |||
var targetItem = null; | |||
items.forEach(function(item) { | |||
var idx = parseInt(item.getAttribute('data-ci-index'), 10); | |||
if (idx === index) { | |||
targetItem = item; | |||
} | |||
}); | |||
if (!targetItem || targetItem.style.display === 'none') return; | |||
// 更新选项卡样式 | |||
tabs.forEach(function(t) { t.classList.remove('active'); }); | |||
this.classList.add('active'); | |||
// 更新图片显示 | |||
items.forEach(function(item) { | |||
item.classList.remove('active'); | |||
item.style.display = 'none'; | |||
}); | }); | ||
targetItem.style.display = 'block'; | |||
targetItem.classList.add('active'); | |||
}); | }); | ||
}); | |||
} | |||
// 2. 处理表格空行隐藏 | |||
var rows = container.querySelectorAll('.ci-info-table .ci-row'); | |||
var allEmpty = true; | |||
rows.forEach(function(row) { | |||
var valueTd = row.querySelector('.ci-value'); | |||
if (valueTd) { | |||
var text = valueTd.textContent.trim(); | |||
if (text === '') { | |||
row.style.display = 'none'; // 空行隐藏 | |||
} else { | |||
allEmpty = false; | |||
} | } | ||
}); | } | ||
})(); | }); | ||
// 如果所有信息都为空,在表格末尾追加一行提示 | |||
if (allEmpty) { | |||
var table = container.querySelector('.ci-info-table'); | |||
if (table) { | |||
var tr = document.createElement('tr'); | |||
tr.className = 'ci-empty-row'; | |||
var td = document.createElement('td'); | |||
td.setAttribute('colspan', '2'); | |||
td.textContent = '暂无人物信息'; | |||
td.style.textAlign = 'center'; | |||
td.style.color = '#999'; | |||
td.style.padding = '16px'; | |||
tr.appendChild(td); | |||
table.appendChild(tr); | |||
} | |||
} | |||
})(); | |||
</script> | </script> | ||
</div> | </div> | ||
</includeonly> | </includeonly> | ||
<noinclude> | <noinclude> | ||
2026年7月29日 (三) 15:40的版本
========================================================
模板名称: 人物信息 (无扩展依赖版) 说明: 无需 ParserFunctions 扩展,完全依靠前端 JS 控制显示隐藏。 使用方法: 模板:人物信息 参数: 姓名, 性别, 配音, 能力, 所属势力, 图片1~图片6, 标签1~标签6
========================================================
-->
粤公网安备44030002015967号