collabdocchat 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -115,46 +115,43 @@ function startClient() {
115
115
 
116
116
  // 主函数 - 在后台异步运行,不阻塞安装
117
117
  async function main() {
118
- // 延迟启动,确保安装过程完成
119
- setTimeout(async () => {
120
- console.log('\n📦 CollabDocChat 安装完成!');
121
- console.log('🚀 正在自动启动应用...\n');
118
+ console.log('\n📦 CollabDocChat 安装完成!');
119
+ console.log('🚀 正在自动启动应用...\n');
122
120
 
123
- // 启动服务器
124
- const server = startServer();
121
+ // 启动服务器
122
+ const server = startServer();
125
123
 
126
- // 等待服务器就绪
127
- try {
128
- await waitForServer(`http://localhost:${PORT}/health`, 30, 1000);
124
+ // 等待服务器就绪(不阻塞,在后台检查)
125
+ waitForServer(`http://localhost:${PORT}/health`, 30, 1000)
126
+ .then(() => {
129
127
  console.log(`✅ 服务器已就绪: http://localhost:${PORT}\n`);
130
- } catch (error) {
128
+
129
+ // 启动客户端
130
+ const client = startClient();
131
+
132
+ // 等待客户端就绪后打开浏览器
133
+ setTimeout(async () => {
134
+ try {
135
+ await waitForServer(CLIENT_URL, 30, 1000);
136
+ console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
137
+ openBrowser(CLIENT_URL);
138
+ console.log('\n✅ 应用已启动!浏览器应该已经自动打开。');
139
+ } catch (error) {
140
+ // 即使检查失败也尝试打开浏览器(客户端可能正在启动)
141
+ console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
142
+ openBrowser(CLIENT_URL);
143
+ console.log('\n✅ 应用正在启动中,浏览器已打开。');
144
+ console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
145
+ }
146
+ }, 5000);
147
+ })
148
+ .catch(error => {
131
149
  console.error('❌ 服务器启动失败:', error.message);
132
150
  console.log('\n💡 请确保:');
133
151
  console.log(' 1. MongoDB 已启动');
134
152
  console.log(' 2. 端口 3000 和 5173 未被占用');
135
153
  console.log(' 3. 运行 npm start 手动启动');
136
- return;
137
- }
138
-
139
- // 启动客户端
140
- const client = startClient();
141
-
142
- // 等待客户端就绪后打开浏览器
143
- setTimeout(async () => {
144
- try {
145
- await waitForServer(CLIENT_URL, 30, 1000);
146
- console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
147
- openBrowser(CLIENT_URL);
148
- console.log('\n✅ 应用已启动!浏览器应该已经自动打开。');
149
- } catch (error) {
150
- // 即使检查失败也尝试打开浏览器(客户端可能正在启动)
151
- console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
152
- openBrowser(CLIENT_URL);
153
- console.log('\n✅ 应用正在启动中,浏览器已打开。');
154
- console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
155
- }
156
- }, 5000);
157
- }, 1000);
154
+ });
158
155
  }
159
156
 
160
157
  // 启动后台进程,不阻塞安装
@@ -162,7 +159,9 @@ main().catch(error => {
162
159
  // 静默处理错误,不影响安装过程
163
160
  });
164
161
 
165
- // 立即退出,让安装过程完成
166
- // 服务器和客户端会在后台运行
167
- process.exit(0);
162
+ // 不立即退出,让后台进程有时间启动
163
+ // 但也不阻塞安装过程
164
+ setTimeout(() => {
165
+ process.exit(0);
166
+ }, 2000);
168
167