;(function(){ const ExpenseTheme = { init(){ this.observeList() this.initNavToggle() this.initThemeToggle() }, observeList(){ const el=document.getElementById('ex-body') if(!el) return const mo=new MutationObserver(muts=>{ muts.forEach(m=>{ m.addedNodes.forEach(n=>{ if(n.nodeType===1) n.classList.add('fade-in') }) }) }) mo.observe(el,{childList:true}) }, initNavToggle(){ const key='expense_nav_visible' const btn=document.getElementById('expense-toggle-nav') const eye=`` const setVisible=(v)=>{ document.body.classList.toggle('nav-visible', !!v); if(btn) { btn.setAttribute('aria-pressed', v?'true':'false'); btn.title=v?'隐藏导航':'显示导航'; btn.innerHTML=eye } } const initVal=localStorage.getItem(key)==='1' setVisible(initVal) if(btn) btn.addEventListener('click',()=>{ const cur=document.body.classList.contains('nav-visible'); const next=!cur; localStorage.setItem(key, next?'1':'0'); setVisible(next) }) }, initThemeToggle(){ const key='expense_theme' const btn=document.getElementById('expense-toggle-theme') const moon=`` const sun=`` const apply=(mode)=>{ document.body.setAttribute('data-theme', mode); if(btn) btn.innerHTML=mode==='dark'?moon:sun } const init=localStorage.getItem(key) || 'dark' apply(init) if(btn) btn.addEventListener('click',()=>{ const cur=document.body.getAttribute('data-theme')||'dark'; const next=cur==='dark'?'light':'dark'; localStorage.setItem(key,next); apply(next) }) } } window.ExpenseTheme=ExpenseTheme if(document.body && document.body.classList.contains('theme-expense')) { ExpenseTheme.init() } })();