collabdocchat 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -169,7 +169,10 @@ sudo systemctl start mongod
169
169
  5. **启动项目**
170
170
 
171
171
  ```bash
172
- # 一键启动(推荐)- 自动启动服务器和客户端,并打开浏览器
172
+ # 快速启动(推荐)- 自动启动服务器和客户端,并打开浏览器
173
+ npm run quick-start
174
+
175
+ # 或使用完整启动脚本
173
176
  npm start
174
177
 
175
178
  # 开发模式(同时启动前后端,使用 nodemon 自动重启)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -143,47 +143,44 @@ function startClient() {
143
143
 
144
144
  // 主函数 - 完全异步,不阻塞
145
145
  function main() {
146
- // 使用 setImmediate 确保在下一个事件循环中执行
147
- setImmediate(() => {
148
- console.log('\n📦 CollabDocChat 安装完成!');
149
- console.log('🚀 正在后台启动应用...\n');
146
+ console.log('\n📦 CollabDocChat 安装完成!');
147
+ console.log('🚀 正在后台启动应用...\n');
150
148
 
151
- // 立即启动服务器(不等待)
152
- try {
153
- const server = startServer();
154
- } catch (error) {
155
- // 静默处理
156
- }
157
-
158
- // 立即启动客户端(不等待)
149
+ // 立即启动服务器(不等待)
150
+ try {
151
+ const server = startServer();
152
+ } catch (error) {
153
+ // 静默处理
154
+ }
155
+
156
+ // 立即启动客户端(不等待)
157
+ try {
158
+ const client = startClient();
159
+ } catch (error) {
160
+ // 静默处理
161
+ }
162
+
163
+ // 延迟打开浏览器,给服务器启动时间
164
+ setTimeout(() => {
159
165
  try {
160
- const client = startClient();
166
+ console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
167
+ openBrowser(CLIENT_URL);
168
+ console.log('\n✅ 应用正在启动中,浏览器已打开。');
169
+ console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
170
+ console.log('\n💡 提示:服务器和客户端正在后台运行');
171
+ console.log(' 要停止服务,运行: cd node_modules/collabdocchat && npm run stop');
161
172
  } catch (error) {
162
173
  // 静默处理
163
174
  }
164
-
165
- // 延迟打开浏览器,给服务器启动时间
166
- setTimeout(() => {
167
- try {
168
- console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
169
- openBrowser(CLIENT_URL);
170
- console.log('\n✅ 应用正在启动中,浏览器已打开。');
171
- console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
172
- console.log('\n💡 提示:服务器和客户端正在后台运行');
173
- console.log(' 要停止服务,运行: cd node_modules/collabdocchat && npm run stop');
174
- } catch (error) {
175
- // 静默处理
176
- }
177
- }, 8000);
178
- });
175
+ }, 8000);
179
176
  }
180
177
 
181
- // 立即执行,不等待
178
+ // 立即执行
182
179
  main();
183
180
 
184
- // 立即退出,不阻塞安装
185
- // 所有操作都在后台完全异步执行
186
- process.nextTick(() => {
181
+ // 延迟退出,给输出时间显示
182
+ // 但不会阻塞太久
183
+ setTimeout(() => {
187
184
  process.exit(0);
188
- });
185
+ }, 2000);
189
186
 
@@ -0,0 +1,50 @@
1
+ import { spawn } from 'child_process';
2
+ import { platform } from 'os';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ const rootDir = join(__dirname, '..');
9
+ const CLIENT_URL = 'http://localhost:5173';
10
+ const isWindows = platform() === 'win32';
11
+
12
+ // 打开浏览器
13
+ function openBrowser(url) {
14
+ const command = isWindows ? 'cmd' : (platform() === 'darwin' ? 'open' : 'xdg-open');
15
+ const args = isWindows ? ['/c', 'start', url] : [url];
16
+ const browser = spawn(command, args, { stdio: 'ignore', detached: true });
17
+ browser.unref();
18
+ }
19
+
20
+ console.log('\n📦 CollabDocChat 快速启动\n');
21
+ console.log('🚀 正在启动服务器和客户端...\n');
22
+
23
+ // 启动服务器
24
+ const server = spawn('node', ['server/index.js'], {
25
+ cwd: rootDir,
26
+ stdio: 'inherit',
27
+ detached: true,
28
+ windowsHide: true
29
+ });
30
+ server.unref();
31
+
32
+ // 启动客户端
33
+ const client = spawn(isWindows ? 'npm.cmd' : 'npm', ['run', 'client'], {
34
+ cwd: rootDir,
35
+ stdio: 'inherit',
36
+ detached: true,
37
+ windowsHide: true
38
+ });
39
+ client.unref();
40
+
41
+ // 8秒后打开浏览器
42
+ setTimeout(() => {
43
+ console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
44
+ openBrowser(CLIENT_URL);
45
+ console.log('\n✅ 应用正在启动中,浏览器已打开!');
46
+ console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
47
+ console.log('\n💡 提示:服务器和客户端正在后台运行');
48
+ console.log(' 要停止服务,运行: npm run stop');
49
+ }, 8000);
50
+