/** * 欢迎弹窗(试用用户) * 功能:在聊天面板内显示欢迎模态窗口 * 依赖:无 * 使用场景:试用用户首次登录时在聊天面板内显示 */ /** * 获取欢迎弹窗的 HTML 内容 */ export function getWelcomeModalContent(logoUri?: string): string { return `
`; } /** * 获取欢迎弹窗的 CSS 样式 */ export function getWelcomeModalStyles(): string { return ` /* 欢迎弹窗样式 */ .welcome-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 20px; font-family: var(--vscode-font-family, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif); } .welcome-modal-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); animation: fadeIn 0.3s ease-out; } .welcome-modal-content { position: relative; background: var(--vscode-editor-background); border: 1px solid var(--vscode-widget-border); border-radius: 12px; width: 100%; max-width: 500px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5); animation: modalSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); overflow: hidden; } .welcome-logo-corner { position: absolute; top: 16px; left: 24px; height: 40px; width: auto; opacity: 0.9; z-index: 10; } .welcome-modal-header { padding: 60px 32px 20px; text-align: center; } .welcome-icon { font-size: 48px; margin-bottom: 16px; } .welcome-modal-header h2 { margin: 0 0 12px; font-size: 24px; font-weight: 600; color: var(--vscode-foreground); } .welcome-modal-subtitle { margin: 0; font-size: 14px; color: var(--vscode-descriptionForeground); line-height: 1.5; } .welcome-modal-body { padding: 0 32px 32px; } .welcome-step { display: flex; gap: 16px; margin: 20px 0; padding: 16px; background: var(--vscode-editor-inactiveSelectionBackground); border-radius: 8px; border-left: 4px solid var(--vscode-textLink-foreground); } .welcome-step-icon { font-size: 24px; flex-shrink: 0; } .welcome-step-content h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--vscode-textLink-foreground); } .welcome-step-content p { margin: 0; font-size: 13px; color: var(--vscode-descriptionForeground); line-height: 1.5; } .welcome-btn { width: 100%; padding: 12px 16px; font-size: 14px; font-weight: 600; border: none; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--vscode-button-background); color: var(--vscode-button-foreground); transition: all 0.2s; margin-top: 24px; } .welcome-btn:hover { background: var(--vscode-button-hoverBackground); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.2); } .welcome-btn:active { transform: translateY(0); } `; } /** * 获取欢迎弹窗的 JavaScript 逻辑 */ export function getWelcomeModalScript(): string { return ` // 欢迎弹窗逻辑 (function() { const modal = document.getElementById('welcomeModal'); const startBtn = document.getElementById('welcomeStartBtn'); const overlay = modal?.querySelector('.welcome-modal-overlay'); // 显示欢迎弹窗 window.showWelcomeModal = function() { if (modal) { modal.style.display = 'flex'; } }; // 隐藏欢迎弹窗 window.hideWelcomeModal = function() { if (modal) { modal.style.display = 'none'; } }; // 点击"开始使用"按钮 if (startBtn) { startBtn.addEventListener('click', function() { hideWelcomeModal(); }); } // 点击遮罩层关闭弹窗 if (overlay) { overlay.addEventListener('click', function() { hideWelcomeModal(); }); } // 阻止点击弹窗内容时关闭 const content = modal?.querySelector('.welcome-modal-content'); if (content) { content.addEventListener('click', function(e) { e.stopPropagation(); }); } // 监听来自后端的消息 window.addEventListener('message', function(event) { const message = event.data; if (message.command === 'showWelcomeModal') { showWelcomeModal(); } }); // 页面加载时检查是否需要显示欢迎弹窗 vscode.postMessage({ command: 'checkWelcomeModal' }); })(); `; }