/* ===================================================================== * 多维鹰 手机端 v18(2026-09-09) * 修复 v11 场景切换 bug(_st is not a function → 底部导航/市场点击即崩): * 提供正确的 window.switchTab 实现(显隐各场景容器并触发对应数据加载)。 * 同时修正 v11 fixHeader 在登录遮罩下的显示(登录后 header 已在)。 * 独立文件,index.html 末尾追加一行引用;可整行删除回滚。 * ===================================================================== */ (function () { 'use strict'; if (window.__mobV18) return; window.__mobV18 = true; function $(id) { return document.getElementById(id); } function hideAll() { ['chat-container', 'market-container', 'workflow-container', 'video-container', 'tasks-container', 'profile-container'].forEach(function (id) { var el = $(id); if (el) el.style.display = 'none'; }); var fn = $('function-nav'); if (fn) fn.style.display = 'none'; } function ensureMarket() { if ($('market-container')) return; var c = document.createElement('div'); c.id = 'market-container'; c.style.cssText = 'display:none;'; c.innerHTML = '
加载中…
暂无可用模块
'; return; } box._ok = true; box._data = cat; renderMarket(cat); }).catch(function () { box.innerHTML = '市场加载失败,请检查网络
'; }); } catch (e) {} } function renderMarket(cat) { var box = $('mobMarketList'); if (!box) return; var groups = {}; cat.forEach(function (m) { (groups[m.group] = groups[m.group] || []).push(m); }); var order = ['studio', 'modules', 'market', 'tools']; var html = order.filter(function (g) { return groups[g] && groups[g].length; }).map(function (g) { var rows = groups[g].map(function (m) { var locked = (m.authorized === false) || (m.unlocked === false); var lock = locked ? ' locked' : ''; var bdg = m.badge ? '' + m.badge + '' : ''; return '暂无模块
'; box.onclick = function (e) { var row = e.target.closest && e.target.closest('.mob-app-row'); if (!row) return; var id = decodeURIComponent(row.getAttribute('data-id')); var item = null; (box._data || []).forEach(function (m) { if (m.id === id) item = m; }); if (!item) return; if (item.authorized === false) { alert('该功能未授权,请联系运营开通(中控台后端授权后自动展示)。'); return; } if (item.unlocked === false) { if (window.dwyPayGuide) { window.dwyPayGuide(item); return; } alert('该功能需订阅或充值后使用'); return; } if (window.mobGo) { window.mobGo(item.id); return; } alert('「' + (item.name || id) + '」操作台在电脑端已可用;手机端正在接入中,也可在对话页对 AI 说需求。'); }; } function switchTabCorrect(tab) { try { var t = String(tab || 'home'); hideAll(); var fn = $('function-nav'); if (t === 'home') { var cc = $('chat-container'); if (cc) cc.style.display = ''; if (fn) fn.style.display = 'flex'; } else if (t === 'market') { ensureMarket(); var mc = $('market-container'); if (mc) mc.style.display = 'block'; loadMarket(); } else if (t === 'tasks' || t === 'workflow') { var tc = $('tasks-container'); if (!tc) { try { if (typeof ensureTabContainers === 'function') ensureTabContainers(); } catch (e) {} tc = $('tasks-container'); } if (tc) { tc.style.display = 'block'; try { if (typeof loadScheduledTasks === 'function') loadScheduledTasks(); } catch (e) {} } } else if (t === 'video') { var vc = $('video-container'); if (!vc) { try { if (typeof ensureTabContainers === 'function') ensureTabContainers(); } catch (e) {} vc = $('video-container'); } if (vc) { vc.style.display = 'block'; try { if (typeof loadVideoList === 'function') loadVideoList(); } catch (e) {} } } else if (t === 'profile') { var pc = $('profile-container'); if (!pc) { try { if (typeof ensureTabContainers === 'function') ensureTabContainers(); } catch (e) {} pc = $('profile-container'); } if (pc) { pc.style.display = 'block'; try { if (typeof loadUserProfile === 'function') loadUserProfile(); } catch (e) {} } } else { var ch = $('chat-container'); if (ch) ch.style.display = ''; if (fn) fn.style.display = 'flex'; } var btns = document.querySelectorAll('.bottom-nav .nav-item'); btns.forEach(function (b) { b.classList.remove('active'); b.style.color = '#999'; }); /* 2026-09-19 M1: 底部导航静态按钮是 switchTab('workflow'), 原按 key='tasks' 匹配不到 -> 高亮丢失 */ var alias = { workflow: ['workflow', 'tasks'], tasks: ['tasks', 'workflow'] }; var keys = alias[t] || [t]; btns.forEach(function (b) { var dt = b.getAttribute('data-tab') || ''; var oc = b.getAttribute('onclick') || ''; var hit = false; for (var ki = 0; ki < keys.length; ki++) { if (dt === keys[ki] || oc.indexOf("'" + keys[ki] + "'") >= 0) { hit = true; break; } } if (hit) { b.classList.add('active'); b.style.color = '#667eea'; } }); } catch (e) { try { console.log('[MobV18]', e.message); } catch (e2) {} } } function bootV18() { try { window.switchTab = switchTabCorrect; var nav = document.querySelector('.bottom-nav'); if (nav && !nav.querySelector('[data-tab="market"]')) { var nb = document.createElement('button'); nb.className = 'nav-item'; nb.setAttribute('data-tab', 'market'); nb.innerHTML = '🧩应用市场'; nb.onclick = function () { switchTabCorrect('market'); }; nav.insertBefore(nb, nav.children[1] || null); } try { console.log('[MobV18] switchTab 修复就绪'); } catch (e) {} } catch (e) {} } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', bootV18); else bootV18(); setTimeout(bootV18, 1000); setTimeout(bootV18, 2800); })();