<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>解析失败</title>
    <style>
        /* 1. 页面整体清新暗黑风 */
        body {
            background-color: #0f172a; /* 深邃护眼的深蓝灰色 */
            margin: 0;
            padding: 0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            color: #f8fafc;
        }

        #player-shade {
            width: 100%;
            height: 100vh;
            position: fixed;
            opacity: 0;
            z-index: 10000;
            display: none;
        }

        #box {
            display: flex;
            width: 100%;
            height: 100vh;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            padding: 20px;
            box-sizing: border-box;
            text-align: center;
        }

        /* 2. 主提示文字美化 */
        #text {
            font-size: 1.25rem;
            font-weight: 600;
            color: #f1f5f9;
            margin-bottom: 25px;
            line-height: 1.6;
        }

        /* 注入的副标题说明文字样式 */
        .sub-text {
            display: block;
            font-size: 0.95rem;
            color: #94a3b8; /* 较暗的灰色，拉开层级 */
            margin-top: 12px;
            font-weight: normal;
            line-height: 1.8;
        }

        /* 3. 清新现代风按钮（去除厚重3D感，采用轻量渐变+微光阴影） */
        #route-text {
            display: none; /* JS控制显示 */
            cursor: pointer;
            font-weight: 500;
            color: #ffffff;
            font-size: 16px;
            background: linear-gradient(135deg, #38bdf8, #0ea5e9); /* 清新明亮的蓝 */
            padding: 12px 36px;
            border-radius: 50px; /* 优雅的胶囊形 */
            box-shadow: 0 4px 15px rgba(14, 165, 233, 0.25);
            transition: all 0.2s ease;
            user-select: none;
            letter-spacing: 1px;
        }

        #route-text:hover {
            box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
            transform: translateY(-1px);
        }

        #route-text:active {
            transform: scale(0.96); /* 自然的点击回缩感 */
            box-shadow: 0 2px 8px rgba(14, 165, 233, 0.2);
        }

        /* 4. 按钮下方：当前线路提示框 */
        #route-name {
            display: none; /* 默认隐藏，有数据才显示 */
            margin-top: 16px;
            font-size: 13px;
            color: #cbd5e1;
            background-color: rgba(255, 255, 255, 0.05);
            padding: 6px 16px;
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            letter-spacing: 0.5px;
        }

        /* 5. 侧边栏：毛玻璃质感 */
        #route-menu {
            position: fixed;
            z-index: 11000;
            right: 0;
            top: 0;
            width: 200px; /* 稍微加宽给按钮留空间 */
            height: 100vh;
            background-color: rgba(15, 23, 42, 0.75); /* 半透明深底色 */
            backdrop-filter: blur(12px); /* 磨砂玻璃效果 */
            -webkit-backdrop-filter: blur(12px);
            border-left: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: -5px 0 25px rgba(0,0,0,0.4);
            transform: translateX(100%);
            transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            display: none;
            padding: 20px 15px;
            box-sizing: border-box;
        }

        /* 侧边栏滚动条美化 */
        #route-menu::-webkit-scrollbar { width: 4px; }
        #route-menu::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

        /* 动态生成的侧边栏标题（JS注入类名） */
        .route-menu-title {
            color: #38bdf8;
            font-size: 15px;
            font-weight: bold;
            margin-bottom: 16px;
            padding-left: 8px;
            border-left: 3px solid #38bdf8;
            line-height: 1.2;
            text-align: left;
        }

        /* 6. 侧边栏按钮列表：独立现代卡片 */
        .route-menu-item {
            width: 100%;
            height: 44px;
            line-height: 44px;
            text-align: center;
            color: #e2e8f0;
            background-color: #1e293b;
            border-radius: 8px; /* 卡片圆角 */
            margin-bottom: 12px;
            cursor: pointer;
            font-size: 14px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            transition: all 0.2s ease;
            user-select: none;
        }

        .route-menu-item:hover {
            background-color: #334155;
            color: #38bdf8;
            border-color: rgba(56, 189, 248, 0.3);
        }

        .route-menu-item:active {
            transform: scale(0.96);
        }
    </style>
</head>
<body>
<div id="player-shade"></div>
<div id="box">
    <div id="text">No static resource sitemap.xml.</div>
    <div id="route-text">点此切换线路</div>
    <div id="route-name"></div>
    <div id="route-menu"></div>
</div>

<script id="TempScript">
    let RouteUrls = "";
</script>
<script src="/extend/layui/layui.js"></script>
<script src="/public/js/fail.js"></script>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        // 【需求1】拦截报错文字，修改并增加换行格式
        let textBox = document.getElementById('text');
        if (textBox && textBox.innerHTML.includes('没有匹配到解析接口！请检查配置的解析接口是否已经配置或者正确')) {
            textBox.innerHTML = '没有匹配到解析接口！<br><span class="sub-text">如果你是网站管理员请检查接口配置<br>如果你是用户/使用者请检查输入链接是否正确</span>';
        }

        // 【需求4 & 5】监听并美化侧边栏的标题，同时提取线路名
        let routeMenu = document.getElementById('route-menu');
        
        function updateRouteTitle(node) {
            let text = node.textContent || node.innerText;
            if (text && text.includes('当前线路')) {
                // 如果 fail.js 写入的是游离文本，用 div 把它包起来加上美化 CSS
                if (node.nodeType === Node.TEXT_NODE) {
                    let wrapper = document.createElement('div');
                    wrapper.className = 'route-menu-title';
                    wrapper.innerText = text.trim();
                    node.parentNode.replaceChild(wrapper, node);
                } else if (node.nodeType === Node.ELEMENT_NODE && !node.classList.contains('route-menu-title') && !node.classList.contains('route-menu-item')) {
                    // 如果已经有标签包裹，直接挂载美化 class
                    node.classList.add('route-menu-title');
                }
                
                // 提取具体的线路名称，放到按钮下方的提示框里
                let routeNameDisplay = document.getElementById('route-name');
                if (routeNameDisplay && text.includes('-')) {
                    let currentLine = text.split('-')[1]; // 截取“-”后面的文字
                    routeNameDisplay.innerText = "当前使用线路：" + currentLine;
                    routeNameDisplay.style.display = "inline-block"; // 将其展示出来
                }
            }
        }

        if (routeMenu) {
            // 使用 MutationObserver 监听 fail.js 动态渲染菜单的动作
            let observer = new MutationObserver(function(mutations) {
                mutations.forEach(function(mutation) {
                    Array.from(routeMenu.childNodes).forEach(function(node) {
                        updateRouteTitle(node);
                    });
                });
            });
            observer.observe(routeMenu, { childList: true, subtree: true });
            
            // 页面加载兜底执行一次
            Array.from(routeMenu.childNodes).forEach(function(node) {
                updateRouteTitle(node);
            });
        }
    });
</script>
</body>
</html>
