collabdocchat 1.0.6 → 1.0.8

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/.gitignore CHANGED
@@ -134,3 +134,6 @@ dist
134
134
  .yarn/build-state.yml
135
135
  .yarn/install-state.gz
136
136
  .pnp.*
137
+
138
+ # CollabDocChat 进程 PID 文件
139
+ .collabdocchat.pid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -143,31 +143,45 @@ function startClient() {
143
143
 
144
144
  // 主函数 - 快速启动,不等待
145
145
  function main() {
146
- console.log('\n📦 CollabDocChat 安装完成!');
147
- console.log('🚀 正在后台启动应用...\n');
148
-
149
- // 立即启动服务器(不等待)
150
- const server = startServer();
151
-
152
- // 立即启动客户端(不等待)
153
- const client = startClient();
154
-
155
- // 延迟打开浏览器,给服务器启动时间
146
+ // 使用 setTimeout 确保在下一个事件循环中执行,不阻塞安装
156
147
  setTimeout(() => {
157
- console.log(`\n🌐 正在打开浏览器: ${CLIENT_URL}`);
158
- openBrowser(CLIENT_URL);
159
- console.log('\n✅ 应用正在启动中,浏览器已打开。');
160
- console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
161
- console.log('\n💡 提示:服务器和客户端正在后台运行');
162
- console.log(' 要停止服务,请关闭终端窗口或使用任务管理器');
163
- }, 8000); // 8秒后打开浏览器,给服务器足够时间启动
148
+ console.log('\n📦 CollabDocChat 安装完成!');
149
+ console.log('🚀 正在后台启动应用...\n');
150
+
151
+ // 立即启动服务器(不等待)
152
+ try {
153
+ const server = startServer();
154
+ } catch (error) {
155
+ // 静默处理错误
156
+ }
157
+
158
+ // 立即启动客户端(不等待)
159
+ try {
160
+ const client = startClient();
161
+ } catch (error) {
162
+ // 静默处理错误
163
+ }
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(' 要停止服务,运行: npm run stop');
174
+ } catch (error) {
175
+ // 静默处理错误
176
+ }
177
+ }, 8000); // 8秒后打开浏览器,给服务器足够时间启动
178
+ }, 100);
164
179
  }
165
180
 
166
181
  // 立即执行,不等待
167
182
  main();
168
183
 
169
- // 快速退出,不阻塞安装
170
- setTimeout(() => {
171
- process.exit(0);
172
- }, 500);
184
+ // 立即退出,不阻塞安装
185
+ // 所有操作都在后台异步执行
186
+ process.exit(0);
173
187
 
@@ -2,7 +2,7 @@ import { exec } from 'child_process';
2
2
  import { platform } from 'os';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { dirname, join } from 'path';
5
- import { existsSync, unlinkSync } from 'fs';
5
+ import { existsSync, unlinkSync, readFileSync } from 'fs';
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = dirname(__filename);
@@ -14,11 +14,10 @@ const isWindows = platform() === 'win32';
14
14
  console.log('🛑 正在停止 CollabDocChat 服务...\n');
15
15
 
16
16
  // 读取 PID 文件
17
- async function readPidFile() {
17
+ function readPidFile() {
18
18
  if (existsSync(pidFile)) {
19
19
  try {
20
- const fs = await import('fs/promises');
21
- const content = await fs.readFile(pidFile, 'utf-8');
20
+ const content = readFileSync(pidFile, 'utf-8');
22
21
  return content.trim().split('\n').filter(Boolean);
23
22
  } catch (error) {
24
23
  return [];
@@ -104,7 +103,7 @@ async function main() {
104
103
  let stopped = false;
105
104
 
106
105
  // 方法1: 通过 PID 文件停止
107
- const pids = await readPidFile();
106
+ const pids = readPidFile();
108
107
  if (pids.length > 0) {
109
108
  console.log(`📋 找到 ${pids.length} 个进程记录`);
110
109
  for (const pid of pids) {