/* ===================================================================== * 多维鹰 手机端 v17 整合修复层(2026-09-09) * 基于真实 DOM 证据(chat-client/index 轮询 → #ai-chat-wrapper 内 * .message-bubble.user/.ai > .bubble-content;#chat-input 为单行 input): * 1) 输入框替换为 textarea 自动增高(长文可见,Enter 发送 / Shift+Enter 换行) * 2) 全真类灰化:气泡/输入/发送钮/功能胶囊/底部导航/欢迎语 * 3) ☰ 菜单自建(含 登录/注册、退出);登录弹窗可关可滑退 * 4) 协议勾选 + 右滑返回 * 独立文件,index.html 引用本文件(可整行删除回滚) * ===================================================================== */ (function () { 'use strict'; if (window.__mobV17) return; window.__mobV17 = true; function lg() { try { console.log('[MobV17]', [].slice.call(arguments).join(' ')); } catch (e) {} } function $(id) { return document.getElementById(id); } var AGREEMENT = '/mobile/agreement.html'; /* ============ 1. 样式:真实类全覆盖灰化 + 压缩 ============ */ function cssV() { var st = document.createElement('style'); st.id = 'mobv17css'; st.textContent = [ /* 顶部:隐藏右上角账号钮,品牌小字 */ '#mobile-user-info{display:none!important}', '.mobile-header{min-height:42px!important;padding:4px 8px!important}', '.mobile-header h1{font-size:14px!important;margin:0!important;display:flex;align-items:center;gap:6px!important}', '#mobV11Brand{color:#334155!important;font-weight:700!important;font-size:14px!important}', '.mobile-header h1 span{color:#94a3b8!important;font-weight:400!important}', /* 欢迎引导:灰色小字一行 */ '#chat-container h2{font-size:12px!important;color:#94a3b8!important;font-weight:400!important;text-align:center!important;padding:0 12px!important;margin:6px 0 2px!important}', /* 消息气泡:白底卡片化,AI 灰底深字 */ '#ai-chat-wrapper{display:flex;flex-direction:column;gap:8px;padding:10px 4px}', '#ai-chat-wrapper .message-bubble{max-width:92%;padding:0;border:none!important;background:transparent!important;box-shadow:none!important}', '#ai-chat-wrapper .message-bubble.user{align-self:flex-end}', '#ai-chat-wrapper .message-bubble.ai{align-self:flex-start}', '#ai-chat-wrapper .bubble-content{display:inline-block;font-size:14px!important;line-height:1.7!important;color:#1e293b!important;background:#f1f5f9!important;background-image:none!important;border-radius:14px!important;padding:8px 12px!important;white-space:pre-wrap;word-break:break-word}', '#ai-chat-wrapper .message-bubble.user .bubble-content{background:#e2e8f0!important;color:#0f172a!important}', /* 输入行:textarea 自适应样式 */ '#chat-input{width:100%;box-sizing:border-box;border:1px solid #e2e8f0!important;border-radius:16px!important;background:#fff!important;font-size:14px!important;line-height:1.6!important;padding:8px 12px!important;min-height:40px;max-height:160px;outline:none;resize:none;font-family:inherit}', 'button.send-btn,#send-btn{width:auto!important;height:auto!important;min-width:54px!important;padding:7px 14px!important;border-radius:16px!important;background:#f1f5f9!important;background-image:none!important;color:#475569!important;border:none!important;box-shadow:none!important;font-size:13px!important;flex:none}', /* 功能导航胶囊 / 底部导航:小灰 */ '#function-nav{gap:6px!important;padding:6px 8px!important}', '#function-nav button{background:#f1f5f9!important;background-image:none!important;color:#475569!important;border:none!important;box-shadow:none!important;font-size:12px!important;padding:5px 11px!important;border-radius:15px!important;margin:0!important;transform:none!important;white-space:nowrap}', '.bottom-nav{min-height:50px!important}', '.bottom-nav .nav-item{padding:3px 1px!important}', '.bottom-nav .nav-item span{font-size:11px!important}', '.bottom-nav .nav-item span[style*="24px"]{font-size:18px!important}', /* 若 AI 组件(ai-chat-*)也被挂载,一并灰化 */ '.ai-chat-messages .ai-chat-message > div{background:#f1f5f9!important;color:#1e293b!important;border:none!important;font-size:13px!important}', '.ai-chat-send-btn{width:auto!important;height:auto!important;min-width:52px!important;padding:6px 13px!important;border-radius:15px!important;background:#f1f5f9!important;background-image:none!important;color:#475569!important;border:none!important;font-size:13px!important}', '.ai-chat-input{font-size:14px!important}', /* 登录弹窗灰化小字 */ '#login-form-container .form-section{padding:16px!important}', '#login-form-container .form-title{font-size:16px!important}', '#login-form-container .form-input{font-size:14px!important;padding:8px 10px!important}', '#login-form-container .form-submit-button{background:#334155!important;background-image:none!important;border:none!important;color:#fff!important;border-radius:9px!important;font-size:14px!important}', '#login-form-container .form-button{font-size:13px!important}', '.v11-agree-line{display:flex;gap:6px;align-items:flex-start;font-size:12px;color:#64748b;margin:2px 0 8px;line-height:1.5}', '.v11-agree-line input{width:15px;height:15px;flex:none;margin-top:2px}', '.v11-agree-line a{color:#475569;text-decoration:underline}', /* 市场与菜单:紧凑 */ '.mob-app-row{padding:7px 12px!important}', '.mob-app-row .nm{font-size:14px!important}', '.mob-app-group{border-radius:10px!important;margin:6px 8px!important}', '#mobV11Menu .drawer .mi{font-size:14px!important;padding:10px 14px!important}', '#mobPanelBody{font-size:13px!important;line-height:1.7!important}' ].join('\n'); document.head.appendChild(st); } /* ============ 2. 输入框 textarea 化(保留 #chat-input 引用) ============ */ function upgradeInput() { try { var old = $('chat-input'); if (!old || old.tagName === 'TEXTAREA') return; var ta = document.createElement('textarea'); ta.id = 'chat-input'; ta.placeholder = old.placeholder || '输入消息...'; ta.setAttribute('rows', '1'); // 保留父容器位置与兄弟(发送按钮) old.parentNode.replaceChild(ta, old); var autosize = function () { ta.style.height = 'auto'; ta.style.height = Math.min(Math.max(ta.scrollHeight, 40), 160) + 'px'; }; ta.addEventListener('input', autosize); ta.addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); try { if (typeof window.sendMessage === 'function') window.sendMessage(); else if (typeof sendMessage === 'function') sendMessage(); } catch (err) { lg('send', err.message); } setTimeout(autosize, 30); } }); setTimeout(autosize, 200); lg('chat-input → textarea'); } catch (e) { lg('upgradeInput', e.message); } } /* ============ 3. ☰ 菜单自建(登录集成) ============ */ function accHTML() { try { var u = JSON.parse(localStorage.getItem('user_info') || '{}'); var tok = localStorage.getItem('user_token'); if (tok && (u.id || u.username)) { return '
👤 ' + (u.nickname || u.username || '用户') + '
↪ 退出登录
'; } return '
🔑 登录 / 注册
'; } catch (e) { return '
🔑 登录 / 注册
'; } } function openMenuV() { try { var old = $('mobV11Menu'); if (old) old.remove(); var m = document.createElement('div'); m.id = 'mobV11Menu'; m.className = 'open'; var d = document.createElement('div'); d.className = 'drawer'; d.innerHTML = '
主场景
' + '
🏠 对话首页
' + '
🧩 应用市场
' + '
⏰ 定时任务
' + '
🎬 视频管理
' + '
👤 我的
' + '
常用工具
' + '
🔔 通知中心
' + '
📡 发布中心
' + '
⚙️ 个人设置
' + '
🔑 API Key
' + '
❓ 帮助
' + '
账号
' + accHTML() + '
📄 用户协议与隐私政策
'; d.addEventListener('click', function (e) { var row = e.target.closest && e.target.closest('.mi'); if (!row) return; var go = row.getAttribute('data-go'); m.remove(); goV(go); }); m.appendChild(d); m.addEventListener('click', function (e) { if (e.target === m) m.remove(); }); document.body.appendChild(m); } catch (e) { lg('menu', e.message); } } function goV(go) { try { if (go === 'home' || go === 'market' || go === 'tasks' || go === 'video' || go === 'profile') { var t = go === 'tasks' ? 'tasks' : go; var sw = window.switchTab || switchTab; if (typeof sw === 'function') sw(t); return; } if (go === 'login') { showLoginV(); return; } if (go === 'logout') { if (!confirm('确定退出登录吗?')) return; try { localStorage.removeItem('user_token'); localStorage.removeItem('user_info'); localStorage.removeItem('user_id'); if (typeof logout === 'function') logout(); else location.reload(); } catch (e) { location.reload(); } return; } if (go === 'acct') { try { if (typeof showProfile === 'function') showProfile(); } catch (e) {} return; } if (window.mobGo) window.mobGo(go); // notify/publish/settings/apikey/help } catch (e) { lg('goV', e.message); } } function bindMenuBtnV() { var b = $('mobV11MenuBtn') || document.querySelector('.mobile-header h1 button'); if (b) b.onclick = function (e) { if (e) e.stopPropagation(); openMenuV(); }; } /* ============ 4. 登录弹窗可关可滑退 ============ */ function showLoginV() { try { var c = $('login-form-container'); if (!c) return; c.style.display = 'flex'; var sec = $('login-form-section'); if (sec) sec.style.display = 'block'; var reg = $('register-form-section'); if (reg) reg.style.display = 'none'; var fp = $('forgot-password-section'); if (fp) fp.style.display = 'none'; } catch (e) {} } function fixLoginV() { try { var c = $('login-form-container'); if (!c) return; function hide() { c.style.display = 'none'; } var x = $('close-login-modal'); if (x) x.onclick = hide; if (!c._v17) { c._v17 = true; c.addEventListener('click', function (ev) { if (ev.target === c) hide(); }); } } catch (e) {} } /* ============ 5. 协议勾选 ============ */ function agreeV() { try { var lf = $('login-form'); if (lf && !$('v11AgreeLogin')) { var r1 = document.createElement('label'); r1.className = 'v11-agree-line'; r1.innerHTML = '我已阅读并同意 《用户协议与隐私政策》'; lf.insertBefore(r1, lf.firstChild); } var rf = $('register-form'); if (rf && !$('v11AgreeReg')) { var r2 = document.createElement('label'); r2.className = 'v11-agree-line'; r2.innerHTML = '我已阅读并同意 《用户协议与隐私政策》,知悉平台提供 AI 生成与自动化发布服务'; rf.insertBefore(r2, rf.firstChild); } document.addEventListener('click', function (e) { var t = e.target; if (!t || !t.closest) return; var btn = t.closest('#login-form button[type="submit"], #register-form button[type="submit"], .form-login-submit'); if (!btn) return; var f = btn.closest('form'); if (!f) return; var cb = f.id === 'register-form' ? $('v11AgreeReg') : $('v11AgreeLogin'); if (cb && !cb.checked) { e.preventDefault(); if (e.stopImmediatePropagation) e.stopImmediatePropagation(); alert('请先勾选同意《用户协议与隐私政策》'); cb.focus(); } }, true); } catch (e) { lg('agree', e.message); } } /* ============ 6. 右滑关闭顶层 ============ */ function swipeV() { var x0 = null, y0 = null; document.addEventListener('touchstart', function (e) { if (e.touches.length === 1) { x0 = e.touches[0].clientX; y0 = e.touches[0].clientY; } else { x0 = null; } }, { passive: true }); document.addEventListener('touchend', function (e) { if (x0 === null) return; var dx = e.changedTouches[0].clientX - x0; var dy = e.changedTouches[0].clientY - y0; x0 = null; if (dx < 70 || Math.abs(dx) < Math.abs(dy) * 1.3) return; try { var p = $('mobPanel'); if (p && p.classList.contains('open')) { p.remove(); return; } var mn = $('mobV11Menu'); if (mn && mn.classList.contains('open')) { mn.remove(); return; } var lc = $('login-form-container'); if (lc && lc.style.display === 'flex') { lc.style.display = 'none'; return; } } catch (e2) {} }, { passive: true }); } /* ============ 启动 ============ */ function bootV() { try { cssV(); upgradeInput(); agreeV(); fixLoginV(); bindMenuBtnV(); swipeV(); window.openMenu = openMenuV; window.mobShowLogin = showLoginV; lg('v17 ready'); } catch (e) { lg('boot', e.message); } } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', bootV); else bootV(); setTimeout(bootV, 900); setTimeout(function () { try { cssV(); upgradeInput(); agreeV(); fixLoginV(); } catch (e) {} }, 2400); })();