// ==================== 图标替换脚本 ====================
document.addEventListener('DOMContentLoaded', function() {
    // 定义图标映射关系
    const iconMap = {
        'fa-life-ring': 'ti-help-alt',
        'fa-cogs': 'ti-settings',
        'fa-file-o': 'ti-file',
        'fa-group': 'ti-comments-smiley',
        'fa-shield': 'ti-shield',
        'fa-envelope': 'ti-email',
        'fa-file-picture-o': 'ti-image',
        'fa-users': 'ti-comments-smiley',
        'fa-bar-chart': 'ti-bar-chart-alt',
        'fa-home': 'ti-home',
        'fa-user': 'ti-user',
        'fa-sliders': 'ti-panel',
        'fa-power-off': 'ti-power-off',
        'fa-birthday-cake': 'ti-gift',
        'fa-pencil-square-o': 'ti-pencil-alt',
        'fa-external-link-square': 'ti-new-window',
        'fa-paperclip': 'ti-clip',
        'fa-bell': 'ti-bell'
    };
    
    // 处理包含多个类名的情况
    const complexMap = {
        'icon fa-chevron-right fa-fw': 'ti-angle-right',
        'icon fa-chevron-left fa-fw': 'ti-angle-left'
    };
    
    // 替换普通图标
    for (const [oldClass, newClass] of Object.entries(iconMap)) {
        const elements = document.querySelectorAll(`.${oldClass.replace(/ /g, '.')}`);
        elements.forEach(el => {
            el.classList.remove(oldClass);
            el.classList.add(newClass);
        });
    }
    
    // 替换复杂类名的图标
    for (const [oldClassString, newClass] of Object.entries(complexMap)) {
        const oldClasses = oldClassString.split(' ');
        const selector = oldClasses.map(c => `.${c}`).join('');
        const elements = document.querySelectorAll(selector);
        elements.forEach(el => {
            oldClasses.forEach(cls => {
                el.classList.remove(cls);
            });
            el.classList.add(newClass);
        });
    }
});