跳转到内容

最近在弄物品数据库,不定期更新!有任何反馈欢迎私信站长B站或站长的qq1131370599

模板:角色信息:修订间差异

来自异环信息站
Mikosword留言 | 贡献
无编辑摘要
Mikosword留言 | 贡献
无编辑摘要
第1行: 第1行:
<!--
====================================================================
====================================================================
模板名称: 人物信息
模板名称: 人物信息 (无扩展依赖版)
说明: 用于在MediaWiki页面中展示人物角色信息,支持多图切换、自适应表格
说明: 无需 ParserFunctions 扩展,完全依靠前端 JS 控制显示隐藏。
使用方法: {{人物信息|参数1=值1|参数2=值2|...}}
使用方法: {{人物信息|参数1=值1|参数2=值2|...}}
参数列表:
参数: 姓名, 性别, 配音, 能力, 所属势力, 图片1~图片6, 标签1~标签6
  - 姓名, 性别, 配音, 能力, 所属势力: 人物基本信息
  - 图片1~图片6: 图片URL (至少填写图片1,最多6张)
  - 标签1~标签6: 对应图片的选项卡标签 (可选,默认显示"图1"~"图6")
注意: 需要ParserFunctions扩展支持 (MediaWiki默认安装)
====================================================================
====================================================================
-->
-->
<includeonly>
<includeonly>
<div class="character-info-wrapper" style="max-width:720px;margin:0 auto;font-family:'Microsoft YaHei','PingFang SC',sans-serif;">
<div class="ci-wrapper" style="max-width:720px;margin:0 auto;font-family:system-ui,'Microsoft YaHei',sans-serif;">
    <!-- ========== 样式定义 ========== -->
     <style>
     <style>
         .character-info-wrapper * {
         .ci-wrapper * { box-sizing: border-box; }
            box-sizing: border-box;
         .ci-wrapper .ci-container {
        }
         .character-info-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);
            transition: all 0.2s;
        }
        /* ---- 图片区域 ---- */
        .character-info-wrapper .ci-image-section {
            margin-bottom: 18px;
        }
        .character-info-wrapper .ci-image-tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 10px;
         }
         }
         .character-info-wrapper .ci-tab-btn {
         /* 图片区 */
             padding: 6px 18px;
        .ci-wrapper .ci-image-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
            border: 1px solid #d0d0d0;
        .ci-wrapper .ci-tab-btn {
            border-radius: 20px;
             padding: 6px 18px; border: 1px solid #d0d0d0; border-radius: 20px;
             background: #f5f5f5;
             background: #f5f5f5; color: #555; font-size: 14px; cursor: pointer;
            color: #555;
             transition: all 0.2s; user-select: none; font-weight: 500;
            font-size: 14px;
            cursor: pointer;
             transition: all 0.25s;
            user-select: none;
            font-weight: 500;
            letter-spacing: 0.3px;
         }
         }
         .character-info-wrapper .ci-tab-btn:hover {
         .ci-wrapper .ci-tab-btn.active { background: #2c3e50; border-color: #2c3e50; color: #fff; }
             background: #e8e8e8;
        .ci-wrapper .ci-image-display {
             border-color: #b0b0b0;
            border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden;
             background: #fff; min-height: 120px; display: flex;
             align-items: center; justify-content: center; position: relative;
         }
         }
         .character-info-wrapper .ci-tab-btn.active {
         .ci-wrapper .ci-img-item { display: none; width: 100%; text-align: center; padding: 8px; }
             background: #2c3e50;
        .ci-wrapper .ci-img-item.active { display: block; }
            border-color: #2c3e50;
        .ci-wrapper .ci-img-item img {
             color: #fff;
             max-width: 100%; max-height: 400px; height: auto;
            box-shadow: 0 2px 6px rgba(44, 62, 80, 0.25);
             display: block; margin: 0 auto; border-radius: 4px;
         }
         }
         .character-info-wrapper .ci-image-display {
         .ci-wrapper .ci-no-image { color: #aaa; font-size: 15px; padding: 30px 0; display: block; }
             border: 1px solid #e0e0e0;
        /* 表格区 */
            border-radius: 8px;
        .ci-wrapper .ci-info-table {
            overflow: hidden;
            width: 100%; border-collapse: collapse;
             background: #fff;
             border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden;
            min-height: 160px;
             background: #fff; margin-top: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
         }
         }
         .character-info-wrapper .ci-image-display .ci-img-item {
         .ci-wrapper .ci-info-table tr { border-bottom: 1px solid #f0f0f0; }
             display: none;
        .ci-wrapper .ci-info-table tr:last-child { border-bottom: none; }
            width: 100%;
        .ci-wrapper .ci-info-table td {
             text-align: center;
             padding: 12px 16px; vertical-align: top; line-height: 1.6;
            padding: 8px;
             font-size: 15px; word-break: break-word;
         }
         }
         .character-info-wrapper .ci-image-display .ci-img-item.active {
         .ci-wrapper .ci-info-table .ci-label {
             display: block;
            width: 20%; min-width: 80px; background: #f7f7f7;
            font-weight: 600; color: #333; text-align: center;
             border-right: 1px solid #eee; vertical-align: middle;
         }
         }
         .character-info-wrapper .ci-image-display .ci-img-item img {
         .ci-wrapper .ci-info-table .ci-value { width: 80%; color: #222; background: #fff; }
            max-width: 100%;
         .ci-wrapper .ci-empty-row td { color: #bbb; font-style: italic; text-align: center; background: #fafafa; }
            max-height: 420px;
            height: auto;
            border-radius: 4px;
            display: block;
            margin: 0 auto;
            object-fit: contain;
        }
        .character-info-wrapper .ci-image-display .ci-no-image {
            color: #aaa;
            font-size: 15px;
            padding: 30px 0;
            text-align: center;
            letter-spacing: 1px;
        }
        /* ---- 信息表格 ---- */
        .character-info-wrapper .ci-info-table {
            width: 100%;
            border-collapse: collapse;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            overflow: hidden;
            background: #fff;
        }
         .character-info-wrapper .ci-info-table tr {
            border-bottom: 1px solid #f0f0f0;
        }
        .character-info-wrapper .ci-info-table tr:last-child {
            border-bottom: none;
        }
        .character-info-wrapper .ci-info-table td {
            padding: 12px 16px;
            vertical-align: top;
            line-height: 1.6;
            font-size: 15px;
            word-break: break-word;
        }
        /* 左侧标签列: 占 20% */
        .character-info-wrapper .ci-info-table .ci-label {
            width: 20%;
            min-width: 80px;
            background: #f7f7f7;
            font-weight: 600;
            color: #333;
            letter-spacing: 0.5px;
            border-right: 1px solid #eee;
            text-align: center;
            vertical-align: middle;
        }
        /* 右侧内容列: 占 80% */
        .character-info-wrapper .ci-info-table .ci-value {
            width: 80%;
            color: #222;
            background: #fff;
        }
        /* 空值占位 */
        .character-info-wrapper .ci-info-table .ci-empty {
            color: #bbb;
            font-style: italic;
        }
        /* ---- 响应式 ---- */
         @media (max-width: 600px) {
         @media (max-width: 600px) {
             .character-info-wrapper .ci-container {
             .ci-wrapper .ci-container { padding: 14px 12px; }
                padding: 14px 12px 18px 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; }
             .character-info-wrapper .ci-info-table td {
                padding: 10px 12px;
                font-size: 14px;
            }
             .character-info-wrapper .ci-info-table .ci-label {
                min-width: 60px;
                font-size: 13px;
            }
            .character-info-wrapper .ci-tab-btn {
                padding: 5px 14px;
                font-size: 13px;
            }
            .character-info-wrapper .ci-image-display .ci-img-item img {
                max-height: 280px;
            }
        }
        @media (max-width: 400px) {
            .character-info-wrapper .ci-info-table td {
                padding: 8px 8px;
                font-size: 13px;
            }
            .character-info-wrapper .ci-info-table .ci-label {
                min-width: 48px;
                font-size: 12px;
            }
            .character-info-wrapper .ci-tab-btn {
                padding: 4px 10px;
                font-size: 12px;
            }
         }
         }
     </style>
     </style>


    <!-- ========== HTML 结构 ========== -->
     <div class="ci-container">
     <div class="ci-container">
 
         <!-- ========== 图片区域 ========== -->
         <!-- ====== 图片区域 ====== -->
         <div class="ci-image-section">
         <div class="ci-image-section">
             {{#if:{{{图片1|}}}|
             <div class="ci-image-tabs" id="ci-tabs-{{PAGEID}}">
                <!-- 有图片 → 显示选项卡 + 图片 -->
                <button class="ci-tab-btn" data-ci-index="0">{{{标签1|图1}}}</button>
                <div class="ci-image-tabs" role="tablist">
                <button class="ci-tab-btn" data-ci-index="1">{{{标签2|图2}}}</button>
                    {{#if:{{{图片1|}}}|<button class="ci-tab-btn active" data-ci-index="0" role="tab">{{{标签1|图1}}}</button>}}
                <button class="ci-tab-btn" data-ci-index="2">{{{标签3|图3}}}</button>
                    {{#if:{{{图片2|}}}|<button class="ci-tab-btn" data-ci-index="1" role="tab">{{{标签2|图2}}}</button>}}
                <button class="ci-tab-btn" data-ci-index="3">{{{标签4|图4}}}</button>
                    {{#if:{{{图片3|}}}|<button class="ci-tab-btn" data-ci-index="2" role="tab">{{{标签3|图3}}}</button>}}
                <button class="ci-tab-btn" data-ci-index="4">{{{标签5|图5}}}</button>
                    {{#if:{{{图片4|}}}|<button class="ci-tab-btn" data-ci-index="3" role="tab">{{{标签4|图4}}}</button>}}
                <button class="ci-tab-btn" data-ci-index="5">{{{标签6|图6}}}</button>
                    {{#if:{{{图片5|}}}|<button class="ci-tab-btn" data-ci-index="4" role="tab">{{{标签5|图5}}}</button>}}
            </div>
                    {{#if:{{{图片6|}}}|<button class="ci-tab-btn" data-ci-index="5" role="tab">{{{标签6|图6}}}</button>}}
            <div class="ci-image-display">
                </div>
                <div class="ci-img-item" data-ci-index="0"><img src="{{{图片1|}}}" alt="人物图片" loading="lazy" /></div>
                <div class="ci-image-display">
                <div class="ci-img-item" data-ci-index="1"><img src="{{{图片2|}}}" alt="人物图片" loading="lazy" /></div>
                    {{#if:{{{图片1|}}}|<div class="ci-img-item active" data-ci-index="0"><img src="{{{图片1}}}" alt="人物图片" loading="lazy" /></div>}}
                <div class="ci-img-item" data-ci-index="2"><img src="{{{图片3|}}}" alt="人物图片" loading="lazy" /></div>
                    {{#if:{{{图片2|}}}|<div class="ci-img-item" data-ci-index="1"><img src="{{{图片2}}}" alt="人物图片" loading="lazy" /></div>}}
                <div class="ci-img-item" data-ci-index="3"><img src="{{{图片4|}}}" alt="人物图片" loading="lazy" /></div>
                    {{#if:{{{图片3|}}}|<div class="ci-img-item" data-ci-index="2"><img src="{{{图片3}}}" alt="人物图片" loading="lazy" /></div>}}
                <div class="ci-img-item" data-ci-index="4"><img src="{{{图片5|}}}" alt="人物图片" loading="lazy" /></div>
                    {{#if:{{{图片4|}}}|<div class="ci-img-item" data-ci-index="3"><img src="{{{图片4}}}" alt="人物图片" loading="lazy" /></div>}}
                <div class="ci-img-item" data-ci-index="5"><img src="{{{图片6|}}}" alt="人物图片" loading="lazy" /></div>
                    {{#if:{{{图片5|}}}|<div class="ci-img-item" data-ci-index="4"><img src="{{{图片5}}}" alt="人物图片" loading="lazy" /></div>}}
                 <div class="ci-no-image">📷 暂无图片</div>
                    {{#if:{{{图片6|}}}|<div class="ci-img-item" data-ci-index="5"><img src="{{{图片6}}}" alt="人物图片" loading="lazy" /></div>}}
            </div>
                </div>
            |
                <!-- 无图片 → 显示占位 -->
                 <div class="ci-image-display">
                    <div class="ci-no-image">📷 暂无图片</div>
                </div>
            }}
         </div>
         </div>


         <!-- ====== 信息表格 ====== -->
         <!-- ========== 信息表格 ========== -->
         <table class="ci-info-table">
         <table class="ci-info-table">
            {{#if:{{{姓名|}}}|
             <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>
                <td class="ci-label">姓名</td>
             <tr class="ci-row"><td class="ci-label">配音</td><td class="ci-value">{{{配音|}}}</td></tr>
                <td class="ci-value">{{{姓名}}}</td>
             <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>
            }}
            {{#if:{{{性别|}}}|
             <tr>
                <td class="ci-label">性别</td>
                <td class="ci-value">{{{性别}}}</td>
            </tr>
            }}
            {{#if:{{{配音|}}}|
             <tr>
                <td class="ci-label">配音</td>
                <td class="ci-value">{{{配音}}}</td>
            </tr>
            }}
            {{#if:{{{能力|}}}|
             <tr>
                <td class="ci-label">能力</td>
                <td class="ci-value">{{{能力}}}</td>
            </tr>
            }}
            {{#if:{{{所属势力|}}}|
             <tr>
                <td class="ci-label">所属势力</td>
                <td class="ci-value">{{{所属势力}}}</td>
            </tr>
            }}
            <!-- 如果所有信息都为空,显示提示行 -->
            {{#ifeq:{{#if:{{{姓名|}}}|1|0}}{{#if:{{{性别|}}}|1|0}}{{#if:{{{配音|}}}|1|0}}{{#if:{{{能力|}}}|1|0}}{{#if:{{{所属势力|}}}|1|0}}|00000|
            <tr>
                <td class="ci-label" style="text-align:center;color:#999;" colspan="2">暂无信息</td>
            </tr>
            }}
         </table>
         </table>
     </div>
     </div>


     <!-- ========== JavaScript ========== -->
     <!-- ========== 纯前端控制脚本 ========== -->
     <script>
     <script>
        (function() {
    (function() {
            // 使用 IIFE 避免全局污染
        // 使用 IIFE 隔离作用域
            var containers = document.querySelectorAll('.character-info-wrapper .ci-container');
        var container = document.querySelector('.ci-wrapper .ci-container');
            containers.forEach(function(container) {
        if (!container) return;
                var tabs = container.querySelectorAll('.ci-tab-btn');
 
                var items = container.querySelectorAll('.ci-img-item');
        // 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;


                // 如果没有选项卡或图片项,直接返回
        // 收集有效的图片
                if (tabs.length === 0 || items.length === 0) return;
        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';
            }
        });


                 // 初始化: 确保第一个选项卡和图片是激活状态
        // 如果没有有效图片,显示占位,隐藏选项卡容器
                 var foundActive = false;
        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 === 0 && !foundActive) {
                     if (idx === firstValid) {
                         tab.classList.add('active');
                         tab.classList.add('active');
                        foundActive = true;
                     } else {
                     } else {
                         tab.classList.remove('active');
                         tab.classList.remove('active');
                     }
                     }
                 });
                 });
                items.forEach(function(item, idx) {
            }
                    if (idx === 0) {
                        item.classList.add('active');
                    } else {
                        item.classList.remove('active');
                    }
                });


                // 点击切换
            // 绑定点击切换事件
                tabs.forEach(function(tab) {
            tabs.forEach(function(tab) {
                    tab.addEventListener('click', function(e) {
                tab.addEventListener('click', function(e) {
                        var index = parseInt(this.getAttribute('data-ci-index'), 10);
                    var index = parseInt(this.getAttribute('data-ci-index'), 10);
                        if (isNaN(index)) return;
                    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) {
                    tabs.forEach(function(t) { t.classList.remove('active'); });
                            t.classList.remove('active');
                    this.classList.add('active');
                        });
                        this.classList.add('active');


                        // 切换图片
                    // 更新图片显示
                        items.forEach(function(item) {
                    items.forEach(function(item) {
                            var itemIndex = parseInt(item.getAttribute('data-ci-index'), 10);
                        item.classList.remove('active');
                            if (itemIndex === index) {
                        item.style.display = 'none';
                                item.classList.add('active');
                            } else {
                                item.classList.remove('active');
                            }
                        });
                     });
                     });
                    targetItem.style.display = 'block';
                    targetItem.classList.add('active');
                 });
                 });
            });
        }


                // 如果只有一张图片,隐藏选项卡(但保留,视觉上不显示)
        // 2. 处理表格空行隐藏
                if (tabs.length <= 1) {
        var rows = container.querySelectorAll('.ci-info-table .ci-row');
                    var tabContainer = container.querySelector('.ci-image-tabs');
        var allEmpty = true;
                    if (tabContainer) {
        rows.forEach(function(row) {
                        tabContainer.style.display = 'none';
            var valueTd = row.querySelector('.ci-value');
                    }
            if (valueTd) {
                    // 但确保图片显示
                var text = valueTd.textContent.trim();
                    if (items.length === 1) {
                if (text === '') {
                        items[0].classList.add('active');
                    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

========================================================

-->


粤ICP备2026112474号-1  |  公安备案图标 粤公网安备44030002015967号
本站所有内容及素材均来自苏州幻塔Hotta Studio旗下游戏《异环》