#!/usr/bin/env node /** * 会话激活页面测试地址获取脚本 * 使用方法: * 1. 在浏览器访问 http://localhost:4200 * 2. 打开控制台(F12) * 3. 复制下面的代码并运行 */ console.log('\n🚀 会话激活页面测试地址获取工具\n'); console.log('=' .repeat(60)); console.log('\n📋 您的配置信息:'); console.log(' 公司ID (cid): cDL6R1hgSi'); console.log(' 用户ID: woAs2qCQAAGQckyg7AQBxhMEoSwnlTvg'); console.log('\n' + '='.repeat(60)); console.log('\n📝 步骤1:启动项目'); console.log(' cd yss-project'); console.log(' npm start'); console.log('\n📝 步骤2:打开浏览器'); console.log(' 访问: http://localhost:4200'); console.log('\n📝 步骤3:打开控制台(按F12)'); console.log('\n📝 步骤4:复制并运行以下代码:'); console.log('\n' + '-'.repeat(60)); const script = ` (async () => { try { // 配置信息 const cid = 'cDL6R1hgSi'; const userid = 'woAs2qCQAAGQckyg7AQBxhMEoSwnlTvg'; // 设置localStorage localStorage.setItem('company', cid); localStorage.setItem(\`\${cid}/USERINFO\`, JSON.stringify({ userid: userid, errcode: 0, errmsg: 'ok', cid: cid })); console.log('✅ localStorage配置成功'); // 导入Parse const { FmodeParse } = await import('fmode-ng/parse'); const Parse = FmodeParse.with('nova'); // 查询群聊 const query = new Parse.Query('GroupChat'); query.equalTo('company', { __type: 'Pointer', className: 'Company', objectId: cid }); query.include('project'); query.descending('createdAt'); query.limit(10); const chats = await query.find(); if (chats.length > 0) { console.log(\`\\n✅ 找到 \${chats.length} 个群聊:\\n\`); chats.forEach((chat, i) => { const url = \`http://localhost:4200/wxwork/\${cid}/chat-activation/\${chat.id}\`; const name = chat.get('name') || '未命名'; const project = chat.get('project'); const projectName = project ? project.get('title') : '无项目'; console.log(\`\${i + 1}. \${name}\`); console.log(\` 项目: \${projectName}\`); console.log(\` 🔗 \${url}\\n\`); }); // 复制第一个 const firstUrl = \`http://localhost:4200/wxwork/\${cid}/chat-activation/\${chats[0].id}\`; await navigator.clipboard.writeText(firstUrl); alert(\`✅ 已复制第一个群聊地址!\\n\\n\${chats[0].get('name')}\\n\\n\${firstUrl}\\n\\n点击确定后自动打开...\`); setTimeout(() => window.open(firstUrl, '_blank'), 500); } else { console.log('⚠️ 未找到群聊,正在创建测试数据...'); // 创建测试群聊 const GroupChat = Parse.Object.extend('GroupChat'); const testChat = new GroupChat(); testChat.set('name', '测试群聊 - ' + new Date().toLocaleString('zh-CN')); testChat.set('company', { __type: 'Pointer', className: 'Company', objectId: cid }); testChat.set('chat_id', 'test_chat_' + Date.now()); testChat.set('member_list', [ { type: 1, userid: 'tech_001', name: '技术员-张三', avatar: '' }, { type: 2, userid: 'customer_001', name: '客户-李四', avatar: '' }, { type: 2, userid: 'customer_002', name: '客户-王五', avatar: '' } ]); testChat.set('messages', [ { msgid: 'msg_001', from: 'customer_001', msgtime: Math.floor(Date.now() / 1000) - 3600, msgtype: 'text', text: { content: '你好,我想咨询一下项目进度' } }, { msgid: 'msg_002', from: 'tech_001', msgtime: Math.floor(Date.now() / 1000) - 3500, msgtype: 'text', text: { content: '您好,项目正在进行中,预计本周完成' } }, { msgid: 'msg_003', from: 'customer_001', msgtime: Math.floor(Date.now() / 1000) - 700, msgtype: 'text', text: { content: '可以帮我修改一下需求吗?' } }, { msgid: 'msg_004', from: 'customer_002', msgtime: Math.floor(Date.now() / 1000) - 300, msgtype: 'text', text: { content: '设计稿什么时候能出来?' } } ]); const saved = await testChat.save(); const url = \`http://localhost:4200/wxwork/\${cid}/chat-activation/\${saved.id}\`; console.log(\`\\n✅ 测试群聊创建成功!\`); console.log(\`群聊名称: \${saved.get('name')}\`); console.log(\`群聊ID: \${saved.id}\`); console.log(\`🔗 \${url}\\n\`); await navigator.clipboard.writeText(url); alert(\`✅ 测试群聊已创建!地址已复制\\n\\n\${url}\\n\\n点击确定后自动打开...\`); setTimeout(() => window.open(url, '_blank'), 500); } } catch (e) { console.error('❌ 错误:', e); alert('❌ 发生错误: ' + e.message + '\\n\\n请确保:\\n1. 项目已启动\\n2. Parse Server已连接'); } })(); `.trim(); console.log(script); console.log('\n' + '-'.repeat(60)); console.log('\n✨ 功能说明:'); console.log(' • 自动配置localStorage'); console.log(' • 查找现有群聊或创建测试群聊'); console.log(' • 自动复制URL到剪贴板'); console.log(' • 自动打开测试页面'); console.log('\n📱 URL格式:'); console.log(' http://localhost:4200/wxwork/cDL6R1hgSi/chat-activation/{群聊ID}'); console.log('\n🎯 测试群聊包含:'); console.log(' • 3个成员(1个技术员 + 2个客户)'); console.log(' • 4条消息(包含1条超时未回复)'); console.log(' • 完整的测试数据'); console.log('\n' + '='.repeat(60)); console.log('\n💡 提示:也可以打开 GET-CHAT-ACTIVATION-TEST-URL.html 使用可视化工具\n');