test-chat-activation.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>会话激活功能 - 测试工具</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  15. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  16. min-height: 100vh;
  17. display: flex;
  18. align-items: center;
  19. justify-content: center;
  20. padding: 20px;
  21. }
  22. .container {
  23. max-width: 800px;
  24. width: 100%;
  25. background: white;
  26. border-radius: 20px;
  27. box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  28. padding: 40px;
  29. }
  30. h1 {
  31. font-size: 32px;
  32. font-weight: 700;
  33. color: #1a1a1a;
  34. margin-bottom: 10px;
  35. text-align: center;
  36. }
  37. .subtitle {
  38. font-size: 16px;
  39. color: #666;
  40. text-align: center;
  41. margin-bottom: 40px;
  42. }
  43. .section {
  44. margin-bottom: 30px;
  45. padding: 20px;
  46. background: #f8f9fa;
  47. border-radius: 12px;
  48. border-left: 4px solid #667eea;
  49. }
  50. .section-title {
  51. font-size: 18px;
  52. font-weight: 600;
  53. color: #1a1a1a;
  54. margin-bottom: 15px;
  55. display: flex;
  56. align-items: center;
  57. gap: 10px;
  58. }
  59. .section-title::before {
  60. content: '';
  61. width: 6px;
  62. height: 6px;
  63. background: #667eea;
  64. border-radius: 50%;
  65. }
  66. .button-group {
  67. display: grid;
  68. grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  69. gap: 12px;
  70. margin-bottom: 15px;
  71. }
  72. .btn {
  73. padding: 14px 24px;
  74. border: none;
  75. border-radius: 10px;
  76. font-size: 15px;
  77. font-weight: 600;
  78. cursor: pointer;
  79. transition: all 0.3s ease;
  80. display: flex;
  81. align-items: center;
  82. justify-content: center;
  83. gap: 8px;
  84. text-decoration: none;
  85. color: white;
  86. }
  87. .btn:hover {
  88. transform: translateY(-2px);
  89. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  90. }
  91. .btn:active {
  92. transform: translateY(0);
  93. }
  94. .btn-primary {
  95. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  96. }
  97. .btn-success {
  98. background: linear-gradient(135deg, #34c759 0%, #28a745 100%);
  99. }
  100. .btn-danger {
  101. background: linear-gradient(135deg, #ff3b30 0%, #dc3545 100%);
  102. }
  103. .btn-info {
  104. background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
  105. }
  106. .btn-warning {
  107. background: linear-gradient(135deg, #ff9500 0%, #ff6b00 100%);
  108. }
  109. .status {
  110. padding: 15px;
  111. background: white;
  112. border-radius: 8px;
  113. margin-top: 15px;
  114. font-size: 14px;
  115. line-height: 1.6;
  116. color: #333;
  117. border: 1px solid #e0e0e0;
  118. }
  119. .status-item {
  120. display: flex;
  121. justify-content: space-between;
  122. padding: 8px 0;
  123. border-bottom: 1px solid #f0f0f0;
  124. }
  125. .status-item:last-child {
  126. border-bottom: none;
  127. }
  128. .status-label {
  129. font-weight: 600;
  130. color: #666;
  131. }
  132. .status-value {
  133. color: #1a1a1a;
  134. }
  135. .status-value.success {
  136. color: #34c759;
  137. }
  138. .status-value.error {
  139. color: #ff3b30;
  140. }
  141. .console-output {
  142. background: #1a1a1a;
  143. color: #00ff00;
  144. padding: 15px;
  145. border-radius: 8px;
  146. font-family: 'Courier New', monospace;
  147. font-size: 13px;
  148. max-height: 200px;
  149. overflow-y: auto;
  150. margin-top: 15px;
  151. white-space: pre-wrap;
  152. word-break: break-all;
  153. }
  154. .steps {
  155. list-style: none;
  156. counter-reset: step-counter;
  157. }
  158. .steps li {
  159. counter-increment: step-counter;
  160. padding: 12px 0 12px 40px;
  161. position: relative;
  162. font-size: 15px;
  163. line-height: 1.6;
  164. color: #333;
  165. }
  166. .steps li::before {
  167. content: counter(step-counter);
  168. position: absolute;
  169. left: 0;
  170. top: 12px;
  171. width: 28px;
  172. height: 28px;
  173. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  174. color: white;
  175. border-radius: 50%;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. font-weight: 700;
  180. font-size: 14px;
  181. }
  182. .alert {
  183. padding: 15px;
  184. border-radius: 8px;
  185. margin-top: 15px;
  186. font-size: 14px;
  187. line-height: 1.6;
  188. }
  189. .alert-info {
  190. background: #e3f2fd;
  191. color: #1565c0;
  192. border: 1px solid #90caf9;
  193. }
  194. .alert-success {
  195. background: #e7f4e4;
  196. color: #2e7d32;
  197. border: 1px solid #81c784;
  198. }
  199. .alert-warning {
  200. background: #fff3cd;
  201. color: #856404;
  202. border: 1px solid #ffc107;
  203. }
  204. </style>
  205. </head>
  206. <body>
  207. <div class="container">
  208. <h1>🧪 会话激活功能测试工具</h1>
  209. <p class="subtitle">快速设置测试数据,开始本地测试</p>
  210. <!-- 快速开始 -->
  211. <div class="section">
  212. <div class="section-title">🚀 快速开始</div>
  213. <div class="button-group">
  214. <button class="btn btn-primary" onclick="setupData()">
  215. ⚡ 一键设置测试数据
  216. </button>
  217. <button class="btn btn-success" onclick="openTestPage()">
  218. 🔗 打开测试页面
  219. </button>
  220. </div>
  221. <div class="alert alert-info">
  222. <strong>💡 提示:</strong> 点击"一键设置测试数据"后,再点击"打开测试页面"即可开始测试。
  223. </div>
  224. </div>
  225. <!-- 数据管理 -->
  226. <div class="section">
  227. <div class="section-title">📊 数据管理</div>
  228. <div class="button-group">
  229. <button class="btn btn-info" onclick="viewData()">
  230. 👁️ 查看当前数据
  231. </button>
  232. <button class="btn btn-danger" onclick="clearData()">
  233. 🗑️ 清除测试数据
  234. </button>
  235. </div>
  236. <div id="dataStatus" class="status" style="display: none;"></div>
  237. </div>
  238. <!-- 高级功能 -->
  239. <div class="section">
  240. <div class="section-title">🔧 高级功能</div>
  241. <div class="button-group">
  242. <button class="btn btn-warning" onclick="addOverdue()">
  243. ⏰ 添加超时消息
  244. </button>
  245. <button class="btn btn-success" onclick="markIntroSent()">
  246. ✅ 标记群介绍已发送
  247. </button>
  248. </div>
  249. <div class="alert alert-warning">
  250. <strong>⚠️ 注意:</strong> 这些功能用于测试特定场景,使用前请先设置基础数据。
  251. </div>
  252. </div>
  253. <!-- 使用说明 -->
  254. <div class="section">
  255. <div class="section-title">📖 使用说明</div>
  256. <ol class="steps">
  257. <li>点击"一键设置测试数据"按钮</li>
  258. <li>等待数据设置完成(查看控制台)</li>
  259. <li>点击"打开测试页面"按钮</li>
  260. <li>在新页面中测试各项功能</li>
  261. <li>测试完成后点击"清除测试数据"</li>
  262. </ol>
  263. </div>
  264. <!-- 控制台输出 -->
  265. <div class="section">
  266. <div class="section-title">💻 控制台输出</div>
  267. <div id="consoleOutput" class="console-output">
  268. 等待操作...
  269. </div>
  270. </div>
  271. </div>
  272. <script src="/test-setup.js"></script>
  273. <script>
  274. // 重写 console.log 以显示在页面上
  275. const originalLog = console.log;
  276. const outputDiv = document.getElementById('consoleOutput');
  277. console.log = function(...args) {
  278. originalLog.apply(console, args);
  279. const message = args.map(arg =>
  280. typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
  281. ).join(' ');
  282. outputDiv.textContent += message + '\n';
  283. outputDiv.scrollTop = outputDiv.scrollHeight;
  284. };
  285. // 清空控制台输出
  286. function clearConsole() {
  287. outputDiv.textContent = '';
  288. }
  289. // 设置测试数据
  290. function setupData() {
  291. clearConsole();
  292. console.log('开始设置测试数据...\n');
  293. const result = setupTestData();
  294. if (result.success) {
  295. showAlert('success', '✅ 测试数据设置成功!现在可以打开测试页面了。');
  296. }
  297. }
  298. // 查看数据
  299. function viewData() {
  300. clearConsole();
  301. const result = viewTestData();
  302. const statusDiv = document.getElementById('dataStatus');
  303. statusDiv.style.display = 'block';
  304. let html = '';
  305. for (const [key, value] of Object.entries(result.data)) {
  306. const status = value ? 'success' : 'error';
  307. const icon = value ? '✅' : '❌';
  308. const text = value ? '已设置' : '未设置';
  309. html += `
  310. <div class="status-item">
  311. <span class="status-label">${key}</span>
  312. <span class="status-value ${status}">${icon} ${text}</span>
  313. </div>
  314. `;
  315. }
  316. statusDiv.innerHTML = html;
  317. if (result.allSet) {
  318. showAlert('success', '✅ 所有数据已设置,可以开始测试!');
  319. } else {
  320. showAlert('warning', '⚠️ 部分数据未设置,请先执行"一键设置测试数据"。');
  321. }
  322. }
  323. // 清除数据
  324. function clearData() {
  325. if (confirm('确定要清除所有测试数据吗?')) {
  326. clearConsole();
  327. const result = clearTestData();
  328. if (result.success) {
  329. showAlert('success', '✅ 测试数据已清除!');
  330. document.getElementById('dataStatus').style.display = 'none';
  331. }
  332. }
  333. }
  334. // 添加超时消息
  335. function addOverdue() {
  336. clearConsole();
  337. const result = addOverdueMessages();
  338. if (result.success) {
  339. showAlert('success', '✅ 超时消息已添加!刷新测试页面查看效果。');
  340. }
  341. }
  342. // 标记群介绍已发送
  343. function markIntroSent() {
  344. clearConsole();
  345. const result = simulateSendIntro();
  346. if (result.success) {
  347. showAlert('success', '✅ 群介绍已标记为已发送!刷新测试页面查看效果。');
  348. }
  349. }
  350. // 打开测试页面
  351. function openTestPage() {
  352. const url = 'http://localhost:4200/wxwork/test-company-001/project/project-001/chat-activation';
  353. window.open(url, '_blank');
  354. showAlert('info', '🔗 测试页面已在新标签页中打开!');
  355. }
  356. // 显示提示
  357. function showAlert(type, message) {
  358. const alertDiv = document.createElement('div');
  359. alertDiv.className = `alert alert-${type}`;
  360. alertDiv.textContent = message;
  361. alertDiv.style.position = 'fixed';
  362. alertDiv.style.top = '20px';
  363. alertDiv.style.right = '20px';
  364. alertDiv.style.zIndex = '9999';
  365. alertDiv.style.minWidth = '300px';
  366. alertDiv.style.boxShadow = '0 4px 12px rgba(0, 0, 0, 0.15)';
  367. alertDiv.style.animation = 'slideIn 0.3s ease';
  368. document.body.appendChild(alertDiv);
  369. setTimeout(() => {
  370. alertDiv.style.animation = 'slideOut 0.3s ease';
  371. setTimeout(() => {
  372. document.body.removeChild(alertDiv);
  373. }, 300);
  374. }, 3000);
  375. }
  376. // 添加动画样式
  377. const style = document.createElement('style');
  378. style.textContent = `
  379. @keyframes slideIn {
  380. from {
  381. transform: translateX(400px);
  382. opacity: 0;
  383. }
  384. to {
  385. transform: translateX(0);
  386. opacity: 1;
  387. }
  388. }
  389. @keyframes slideOut {
  390. from {
  391. transform: translateX(0);
  392. opacity: 1;
  393. }
  394. to {
  395. transform: translateX(400px);
  396. opacity: 0;
  397. }
  398. }
  399. `;
  400. document.head.appendChild(style);
  401. // 页面加载时检查数据状态
  402. window.addEventListener('load', () => {
  403. console.log('🧪 会话激活功能测试工具已就绪!');
  404. console.log('💡 点击按钮开始测试\n');
  405. });
  406. </script>
  407. </body>
  408. </html>