collabdocchat 1.1.1 → 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 +4 -1
- package/package.json +1 -1
- package/scripts/quick-start.js +50 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -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
|
+
|