MediaWiki:Common.js:修订间差异

来自Mindustry中文wiki
无编辑摘要
无编辑摘要
第12行: 第12行:
     });
     });
});
});
/* ========== 自定义顶部菜单样式 ========== */
/* Mindustry 顶部导航栏 - 暴力插入版 */
#custom-top-nav {
$(document).ready(function() {
     display: flex;
     // 1. 定义菜单内容 (直接写死白色字体,防止看不见)
    align-items: center;
    var myMenu = `
    height: 100%;
    <div id="mindustry-nav" style="display: flex; align-items: center; height: 100%; margin-left: 20px; z-index: 999;">
    margin-left: 20px; /* 距离 Logo 的距离 */
        <a href="/index.php/首页" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">首页</a>
    flex-grow: 1;     /* 让它占据中间的空间 */
        <a href="/index.php/单位" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">单位</a>
}
        <a href="/index.php/建筑" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">建筑</a>
        <a href="/index.php/逻辑" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">逻辑</a>
    </div>
    `;


#custom-top-nav a {
     // 2. 尝试插入到 Logo 所在的容器中
     color: #333;      /* 文字颜色 (如果是深色背景改为 #fff) */
     // Vector 2022 的 Logo 容器通常叫 .vector-header-start
     font-size: 15px;
     var target = $('.vector-header-start');
     font-weight: bold;
      
     text-decoration: none;
     // 如果找不到,尝试找 .mw-logo (旧版兼容)
     padding: 0 15px;  /* 按钮左右间距 */
     if (target.length === 0) {
    line-height: 50px; /* 垂直居中 */
        target = $('.mw-logo').parent();
     transition: 0.3s;
     }
     border-radius: 4px;
}


#custom-top-nav a:hover {
    // 执行插入
     background-color: #eee; /* 鼠标悬停背景色 (深色模式改为 #444) */
     target.append(myMenu);
     color: #000;           /* 鼠标悬停文字色 */
   
}
    // 3. 调试信息 (按F12看控制台用)
     console.log("Mindustry 导航栏脚本已执行");
});

2025年11月29日 (六) 19:53的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 点击按钮复制内容的脚本 */
$(function() {
    $('.copy-button').click(function() {
        var text = $(this).attr('data-text');
        var $temp = $("<textarea>");
        $("body").append($temp);
        $temp.val(text).select();
        document.execCommand("copy");
        $temp.remove();
        alert("复制成功!");
    });
});
/* Mindustry 顶部导航栏 - 暴力插入版 */
$(document).ready(function() {
    // 1. 定义菜单内容 (直接写死白色字体,防止看不见)
    var myMenu = `
    <div id="mindustry-nav" style="display: flex; align-items: center; height: 100%; margin-left: 20px; z-index: 999;">
        <a href="/index.php/首页" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">首页</a>
        <a href="/index.php/单位" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">单位</a>
        <a href="/index.php/建筑" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">建筑</a>
        <a href="/index.php/逻辑" style="color: #fff !important; font-weight: bold; font-size: 16px; margin-right: 20px; text-decoration: none;">逻辑</a>
    </div>
    `;

    // 2. 尝试插入到 Logo 所在的容器中
    // Vector 2022 的 Logo 容器通常叫 .vector-header-start
    var target = $('.vector-header-start');
    
    // 如果找不到,尝试找 .mw-logo (旧版兼容)
    if (target.length === 0) {
        target = $('.mw-logo').parent();
    }

    // 执行插入
    target.append(myMenu);
    
    // 3. 调试信息 (按F12看控制台用)
    console.log("Mindustry 导航栏脚本已执行");
});