From 2ed6dbe733829e138fc78f914494b3ebc736e9cc Mon Sep 17 00:00:00 2001 From: selfrelease Date: Wed, 15 Jul 2026 15:33:06 +0800 Subject: [PATCH] =?UTF-8?q?deploy:=202026-07-15=2015:33=20=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/web/static/index.html | 93 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/demo/web/static/index.html b/demo/web/static/index.html index c7bb330..4acf1a4 100644 --- a/demo/web/static/index.html +++ b/demo/web/static/index.html @@ -1281,10 +1281,50 @@ function renderMarkdown(md) { listStack.push('ul'); } let liContent = inlineMd(trimmed.slice(2)); - // 销售话术突出显示:微信绿色聊天气泡 + let rawText = trimmed.slice(2).replace(/^\*\*(.+?)\*\*[::]?\s*/, ''); + // 销售话术:绿色高亮卡片 + 复制按钮 if (/^\*\*销售话术\*\*/.test(trimmed.slice(2).trim())) { - liContent = liContent.replace(/^销售话术<\/strong>[::]?/, ''); - html += `
  • 销售话术${liContent}
  • `; + liContent = liContent.replace(/^销售话术<\/strong>[::]?\s*/, ''); + const scriptId = 'script-' + Math.random().toString(36).slice(2, 9); + html += `
  • +
    +
    + + + 销售话术 + + +
    +
    ${liContent}
    +
    +
  • `; + } else if (/^\*\*预期回应\*\*/.test(trimmed.slice(2).trim())) { + // 预期回应:灰色信息块 + liContent = liContent.replace(/^预期回应<\/strong>[::]?\s*/, ''); + html += `
  • +
    +
    + + 预期回应 +
    +
    ${liContent}
    +
    +
  • `; + } else if (/^\*\*技巧提示\*\*/.test(trimmed.slice(2).trim())) { + // 技巧提示:黄色提示块 + liContent = liContent.replace(/^技巧提示<\/strong>[::]?\s*/, ''); + html += `
  • +
    +
    + + 技巧提示 +
    +
    ${liContent}
    +
    +
  • `; } else { html += `
  • ${liContent}
  • `; } @@ -1315,6 +1355,53 @@ function inlineMd(text) { return text; } +/** 复制销售话术到剪贴板,并显示 toast 提示 */ +function copyScript(scriptId) { + const el = document.getElementById(scriptId); + if (!el) return; + const contentEl = el.querySelector('.script-content'); + if (!contentEl) return; + const text = contentEl.innerText.trim(); + navigator.clipboard.writeText(text).then(() => { + showToast('话术已复制', 'success'); + }).catch(() => { + // 降级方案:使用临时 textarea + const textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.position = 'fixed'; + textarea.style.opacity = '0'; + document.body.appendChild(textarea); + textarea.select(); + try { + document.execCommand('copy'); + showToast('话术已复制', 'success'); + } catch (e) { + showToast('复制失败,请手动选择文本', 'error'); + } + document.body.removeChild(textarea); + }); +} + +/** 轻量 toast 提示 */ +function showToast(message, type) { + const colors = { success: 'bg-green-600', error: 'bg-red-500', info: 'bg-gray-700' }; + const toast = document.createElement('div'); + toast.className = `fixed top-6 left-1/2 -translate-x-1/2 ${colors[type] || colors.info} text-white text-sm px-4 py-2 rounded-lg shadow-lg z-50 transition-all duration-300`; + toast.style.opacity = '0'; + toast.style.transform = 'translate(-50%, -10px)'; + toast.textContent = message; + document.body.appendChild(toast); + requestAnimationFrame(() => { + toast.style.opacity = '1'; + toast.style.transform = 'translate(-50%, 0)'; + }); + setTimeout(() => { + toast.style.opacity = '0'; + toast.style.transform = 'translate(-50%, -10px)'; + setTimeout(() => toast.remove(), 300); + }, 2000); +} + // --- 工具 --- function escapeHtml(s) { const div = document.createElement('div');