collabdocchat 1.2.4 → 1.2.5
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 +28 -12
- package/bin/cli.js +31 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,30 +21,46 @@
|
|
|
21
21
|
|
|
22
22
|
## 🚀 快速开始
|
|
23
23
|
|
|
24
|
-
###
|
|
24
|
+
### 方式一:本地安装(推荐)
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
|
|
27
|
+
# 1. 安装包
|
|
28
|
+
npm install collabdocchat
|
|
29
|
+
|
|
30
|
+
# 2. 进入目录
|
|
31
|
+
cd node_modules/collabdocchat
|
|
32
|
+
|
|
33
|
+
# 3. 启动应用
|
|
34
|
+
npm start
|
|
28
35
|
```
|
|
29
36
|
|
|
30
|
-
###
|
|
37
|
+
### 方式二:克隆仓库
|
|
31
38
|
|
|
32
39
|
```bash
|
|
33
|
-
#
|
|
34
|
-
|
|
40
|
+
# 1. 克隆项目
|
|
41
|
+
git clone https://github.com/shijinghao/collabdocchat.git
|
|
42
|
+
cd collabdocchat
|
|
35
43
|
|
|
36
|
-
#
|
|
37
|
-
|
|
44
|
+
# 2. 安装依赖
|
|
45
|
+
npm install
|
|
46
|
+
|
|
47
|
+
# 3. 启动应用
|
|
48
|
+
npm start
|
|
38
49
|
```
|
|
39
50
|
|
|
40
|
-
###
|
|
51
|
+
### 方式三:使用安装脚本
|
|
41
52
|
|
|
53
|
+
**Windows:**
|
|
42
54
|
```bash
|
|
43
|
-
#
|
|
44
|
-
|
|
55
|
+
# 下载并运行
|
|
56
|
+
install-and-start.bat
|
|
57
|
+
```
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
**Linux/Mac:**
|
|
60
|
+
```bash
|
|
61
|
+
# 下载并运行
|
|
62
|
+
chmod +x install-and-start.sh
|
|
63
|
+
./install-and-start.sh
|
|
48
64
|
```
|
|
49
65
|
|
|
50
66
|
## 📋 系统要求
|
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { spawn } from 'child_process';
|
|
3
|
+
import { spawn, exec } from 'child_process';
|
|
4
4
|
import { platform } from 'os';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { dirname, join } from 'path';
|
|
@@ -9,88 +9,58 @@ import { existsSync } from 'fs';
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
11
|
const rootDir = join(__dirname, '..');
|
|
12
|
-
const CLIENT_URL = 'http://localhost:5173';
|
|
13
12
|
const isWindows = platform() === 'win32';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
if (isWindows) {
|
|
19
|
-
// Windows: 使用 start 命令,需要添加空标题
|
|
20
|
-
spawn('cmd', ['/c', 'start', '""', url], {
|
|
21
|
-
stdio: 'ignore',
|
|
22
|
-
detached: true,
|
|
23
|
-
shell: true
|
|
24
|
-
}).unref();
|
|
25
|
-
} else if (platform() === 'darwin') {
|
|
26
|
-
// macOS
|
|
27
|
-
spawn('open', [url], { stdio: 'ignore', detached: true }).unref();
|
|
28
|
-
} else {
|
|
29
|
-
// Linux
|
|
30
|
-
spawn('xdg-open', [url], { stdio: 'ignore', detached: true }).unref();
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.log(`\n⚠️ 无法自动打开浏览器,请手动访问: ${url}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
14
|
+
console.log('\n🎉 欢迎使用 CollabDocChat!\n');
|
|
15
|
+
console.log('📦 开源的实时协作文档聊天平台\n');
|
|
36
16
|
|
|
37
17
|
// 检查是否在正确的目录
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
18
|
+
const serverPath = join(rootDir, 'server', 'index.js');
|
|
19
|
+
if (!existsSync(serverPath)) {
|
|
20
|
+
console.error('❌ 错误:找不到服务器文件');
|
|
21
|
+
console.error(' 这个包需要在安装后的目录中运行');
|
|
22
|
+
console.error('\n💡 推荐使用方式:');
|
|
23
|
+
console.error(' 1. npm install collabdocchat');
|
|
24
|
+
console.error(' 2. cd node_modules/collabdocchat');
|
|
25
|
+
console.error(' 3. npm start');
|
|
26
|
+
console.error('\n 或者直接运行: npm start (在安装了 collabdocchat 的项目中)');
|
|
27
|
+
process.exit(1);
|
|
45
28
|
}
|
|
46
29
|
|
|
47
|
-
console.log('
|
|
48
|
-
console.log('📦 开源的实时协作文档聊天平台\n');
|
|
49
|
-
console.log('🚀 正在启动服务器和客户端...\n');
|
|
50
|
-
|
|
51
|
-
checkEnvironment();
|
|
30
|
+
console.log('🚀 正在启动应用...\n');
|
|
52
31
|
|
|
53
|
-
//
|
|
54
|
-
const
|
|
32
|
+
// 使用 npm start 脚本来启动
|
|
33
|
+
const npmCmd = isWindows ? 'npm.cmd' : 'npm';
|
|
34
|
+
const startProcess = spawn(npmCmd, ['start'], {
|
|
55
35
|
cwd: rootDir,
|
|
56
36
|
stdio: 'inherit',
|
|
57
|
-
|
|
58
|
-
windowsHide: true
|
|
37
|
+
shell: true
|
|
59
38
|
});
|
|
60
|
-
server.unref();
|
|
61
39
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
startProcess.on('error', (error) => {
|
|
41
|
+
console.error('❌ 启动失败:', error.message);
|
|
42
|
+
console.error('\n💡 请尝试手动启动:');
|
|
43
|
+
console.error(` cd ${rootDir}`);
|
|
44
|
+
console.error(' npm start');
|
|
45
|
+
process.exit(1);
|
|
68
46
|
});
|
|
69
|
-
client.unref();
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(' 如果页面未加载,请稍等片刻后刷新页面。');
|
|
77
|
-
console.log('\n💡 提示:');
|
|
78
|
-
console.log(' • 服务器运行在: http://localhost:3000');
|
|
79
|
-
console.log(' • 客户端运行在: http://localhost:5173');
|
|
80
|
-
console.log(' • 默认管理员账号: admin / admin123');
|
|
81
|
-
console.log('\n📖 更多信息请访问: https://github.com/shijinghao/collabdocchat');
|
|
82
|
-
console.log('\n⚠️ 要停止服务,请运行: npm run stop');
|
|
83
|
-
console.log(' 或者关闭终端窗口\n');
|
|
84
|
-
}, 8000);
|
|
48
|
+
startProcess.on('exit', (code) => {
|
|
49
|
+
if (code !== 0) {
|
|
50
|
+
console.log(`\n⚠️ 进程退出,代码: ${code}`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
85
53
|
|
|
86
54
|
// 处理退出信号
|
|
87
55
|
process.on('SIGINT', () => {
|
|
88
56
|
console.log('\n\n👋 正在关闭应用...');
|
|
57
|
+
startProcess.kill('SIGINT');
|
|
89
58
|
process.exit(0);
|
|
90
59
|
});
|
|
91
60
|
|
|
92
61
|
process.on('SIGTERM', () => {
|
|
93
62
|
console.log('\n\n👋 正在关闭应用...');
|
|
63
|
+
startProcess.kill('SIGTERM');
|
|
94
64
|
process.exit(0);
|
|
95
65
|
});
|
|
96
66
|
|