PageSourceSearch

https://poe2lens.com/static/js/footer.js

js poe2lens.com collected 2026-10-02 01:39:40 UTC 5,084 bytes, 132 lines download raw bytes

1// 统一初始化footer - 完全由脚本管理,页面只需要提供空容器(或完全由脚本创建)
2function initFooter() {
3    // 查找或创建footer容器
4    let footer = document.getElementById('site-footer');
5    
6    if (!footer) {
7        // 如果不存在,创建footer
8        footer = document.createElement('footer');
9        footer.id = 'site-footer';
10        document.body.appendChild(footer);
11    }
12    
13    // 统一设置样式和class(完全由脚本控制,覆盖任何页面设置)
14    // 使用首页的页脚样式(统一格式)
15    footer.className = 'footer';
16    // 使用 !important 确保覆盖 styles.css 中的旧样式
17    footer.style.cssText = 'text-align: center !important; padding: 2rem !important; color: #6b7280 !important; font-size: 0.9rem !important; border-top: 1px solid #1f2937 !important; margin-top: 4rem !important; background-color: transparent !important;';
18    
19    // 确保footer链接样式统一(首页格式)- 使用更强的优先级覆盖 styles.css
20    if (!document.getElementById('footer-style-injected')) {
21        const style = document.createElement('style');
22        style.id = 'footer-style-injected';
23        style.textContent = `
24            /* 覆盖 styles.css 中的旧页脚样式,使用首页格式 */
25            #site-footer.footer {
26                text-align: center !important;
27                padding: 2rem !important;
28                color: #6b7280 !important;
29                font-size: 0.9rem !important;
30                border-top: 1px solid #1f2937 !important;
31                margin-top: 4rem !important;
32                background-color: transparent !important;
33            }
34            
35            /* 覆盖 #site-footer a 的样式 */
36            #site-footer.footer a {
37                color: #60a5fa !important;
38                text-decoration: none !important;
39                margin: 0 0.5rem !important;
40            }
41            
42            #site-footer.footer a:hover {
43                text-decoration: underline !important;
44                background-color: transparent !important;
45            }
46            
47            /* 覆盖 #footer-links 的 flex 布局,使用首页的简单格式 */
48            #site-footer.footer #footer-links {
49                display: block !important;
50                text-align: center !important;
51            }
52            
53            #site-footer.footer #footer-links p {
54                margin: 0;
55                line-height: 1.6;
56            }
57        `;
58        document.head.appendChild(style);
59    }
60    
61    // 清空并创建footer内容容器(完全由脚本控制)
62        footer.innerHTML = `
63                    <div id="footer-links">
64                        <!-- 链接将通过 footer.js 动态生成 -->
65            </div>
66        `;
67}
68
69// 页脚ICP备案信息加载脚本
70async function loadICPInfo() {
71    try {
72        const response = await fetch('/api/v1/site-config');
73        const config = await response.json();
74        const icpElement = document.getElementById('icp-license-text');
75        if (icpElement && config.icp_license) {
76            icpElement.textContent = config.icp_license;
77        }
78    } catch (error) {
79        console.error('加载ICP备案信息失败:', error);
80        // 如果API失败,使用默认值(现在由renderFooterLinks统一处理)
81        // ICP信息已包含在footer中,不再需要单独加载
82    }
83}
84
85// 渲染页脚链接(使用首页的格式)
86function renderFooterLinks() {
87    const footerLinksContainer = document.getElementById('footer-links');
88    if (!footerLinksContainer) {
89        return;
90    }
91    
92    const links = [
93        { href: '/about.html', text: '关于我们' },
94        { href: '/help.html', text: '使用指南' },
95        { href: '/tools-intro.html', text: '工具介绍' },
96        { href: '/contact.html', text: '联系我们' },
97        { href: '/privacy.html', text: '隐私政策' },
98        { href: '/terms.html', text: '服务条款' }
99    ];
100    
101    // 使用首页的格式:链接之间用竖线分隔
102    footerLinksContainer.innerHTML = `
103        <p>
104            ${links.map((link, index) => {
105                const separator = index < links.length - 1 ? ' | ' : '';
106                return `<a href="${link.href}">${link.text}</a>${separator}`;
107            }).join('')}
108        </p>
109        <p style="margin-top: 1rem;">
110            poe2lens © 2024 | 专为流放之路2玩家打造的工具站
111        </p>
112        <p style="margin-top: 0.5rem;">
113            <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer" style="color: #6b7280; text-decoration: none;">
114                沪ICP备2025152952号-1
115            </a>
116        </p>
117    `;
118}
119
120// 页面加载完成后初始化footer并加载ICP信息和页脚链接
121if (document.readyState === 'loading') {
122    document.addEventListener('DOMContentLoaded', () => {
123        initFooter();
124        loadICPInfo();
125        renderFooterLinks();
126    });
127} else {
128    initFooter();
129    loadICPInfo();
130    renderFooterLinks();
131}
132

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.