collabdocchat 2.4.5 → 2.4.6

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.
Files changed (47) hide show
  1. package/bin/cli.js +1 -1
  2. package/package.json +3 -1
  3. package/scripts/cleanup-scripts.js +140 -0
  4. package/scripts/fix-startup-issues.js +136 -0
  5. package/scripts/start-app.js +11 -5
  6. package/scripts/start-simple.js +96 -0
  7. package/scripts/add-button-hover.js +0 -58
  8. package/scripts/add-missing-braces.js +0 -27
  9. package/scripts/add-missing-functions.js +0 -68
  10. package/scripts/add-more-features.js +0 -429
  11. package/scripts/add-user-functions.js +0 -203
  12. package/scripts/auto-publish.js +0 -65
  13. package/scripts/beautify-buttons.js +0 -47
  14. package/scripts/beautify-ui.js +0 -269
  15. package/scripts/check-brackets.js +0 -50
  16. package/scripts/check-encoding.js +0 -43
  17. package/scripts/check-syntax.js +0 -56
  18. package/scripts/delete-orphan-block.js +0 -27
  19. package/scripts/find-buttons.js +0 -22
  20. package/scripts/find-duplicate.js +0 -37
  21. package/scripts/find-extra-brace.js +0 -63
  22. package/scripts/find-sidebar-buttons.js +0 -23
  23. package/scripts/fix-file-end.js +0 -46
  24. package/scripts/fix-help.js +0 -276
  25. package/scripts/fix-issues-step1.js +0 -75
  26. package/scripts/fix-issues-step2.js +0 -95
  27. package/scripts/fix-issues-step3.js +0 -157
  28. package/scripts/fix-issues-step4.js +0 -152
  29. package/scripts/fix-optimized-views.js +0 -39
  30. package/scripts/fix-ports.js +0 -77
  31. package/scripts/fix-settings.js +0 -260
  32. package/scripts/fix-syntax-error.js +0 -38
  33. package/scripts/fix-user-dashboard.js +0 -62
  34. package/scripts/fix-workflow.js +0 -112
  35. package/scripts/refactor-step1.js +0 -34
  36. package/scripts/refactor-step2.js +0 -257
  37. package/scripts/refactor-step3.js +0 -139
  38. package/scripts/refactor-step4.js +0 -185
  39. package/scripts/refactor-step5.js +0 -183
  40. package/scripts/refactor-step6.js +0 -256
  41. package/scripts/refactor-step7.js +0 -293
  42. package/scripts/remove-bom.js +0 -69
  43. package/scripts/remove-orphan-code.js +0 -57
  44. package/scripts/remove-quill-from-user-dashboard.js +0 -49
  45. package/scripts/remove-quill-imports-only.js +0 -32
  46. package/scripts/update-port-user.js +0 -23
  47. package/scripts/update-port.js +0 -24
package/bin/cli.js CHANGED
@@ -34,7 +34,7 @@ const npmCmd = isWindows ? 'npm.cmd' : 'npm';
34
34
  const startProcess = spawn(npmCmd, ['start'], {
35
35
  cwd: rootDir,
36
36
  stdio: 'inherit',
37
- shell: true
37
+ shell: false
38
38
  });
39
39
 
40
40
  startProcess.on('error', (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "2.4.5",
3
+ "version": "2.4.6",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -57,6 +57,7 @@
57
57
  "postinstall": "node scripts/postinstall.js",
58
58
  "dev": "concurrently \"npm run server\" \"npm run client\" \"npm run open-browser\"",
59
59
  "start": "node scripts/start-app.js",
60
+ "start:simple": "node scripts/start-simple.js",
60
61
  "quick-start": "node scripts/quick-start.js",
61
62
  "stop": "node scripts/stop-app.js",
62
63
  "server": "nodemon server/index.js",
@@ -65,6 +66,7 @@
65
66
  "build": "vite build",
66
67
  "preview": "vite preview",
67
68
  "serve": "node server/index.js",
69
+ "fix": "node scripts/fix-startup-issues.js",
68
70
  "prepack": "node scripts/pre-publish-check.js",
69
71
  "prepublishOnly": "node scripts/pre-publish-check.js"
70
72
  },
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 清理不需要的开发脚本
5
+ * 保留生产环境必需的脚本
6
+ */
7
+
8
+ import { unlinkSync, existsSync } from 'fs';
9
+ import { join, dirname } from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+ const scriptsDir = __dirname;
15
+
16
+ console.log('🗑️ 开始清理不需要的脚本...\n');
17
+
18
+ // 需要保留的脚本(生产环境必需)
19
+ const keepScripts = [
20
+ 'postinstall.js', // npm 安装后执行
21
+ 'pre-publish-check.js', // 发布前检查
22
+ 'start-app.js', // 标准启动脚本
23
+ 'start-simple.js', // 简化启动脚本
24
+ 'quick-start.js', // 快速启动
25
+ 'stop-app.js', // 停止应用
26
+ 'open-browser.js', // 打开浏览器
27
+ 'fix-startup-issues.js', // 修复启动问题
28
+ 'generate-docs.js', // 生成文档
29
+ 'cleanup-scripts.js' // 本脚本
30
+ ];
31
+
32
+ // 需要删除的脚本(开发调试用的临时脚本)
33
+ const scriptsToDelete = [
34
+ // 添加功能的临时脚本
35
+ 'add-button-hover.js',
36
+ 'add-missing-braces.js',
37
+ 'add-missing-functions.js',
38
+ 'add-more-features.js',
39
+ 'add-user-functions.js',
40
+
41
+ // 美化相关的临时脚本
42
+ 'beautify-buttons.js',
43
+ 'beautify-ui.js',
44
+
45
+ // 检查相关的临时脚本
46
+ 'check-brackets.js',
47
+ 'check-encoding.js',
48
+ 'check-syntax.js',
49
+
50
+ // 查找相关的临时脚本
51
+ 'find-buttons.js',
52
+ 'find-duplicate.js',
53
+ 'find-extra-brace.js',
54
+ 'find-sidebar-buttons.js',
55
+
56
+ // 修复相关的临时脚本
57
+ 'fix-file-end.js',
58
+ 'fix-help.js',
59
+ 'fix-issues-step1.js',
60
+ 'fix-issues-step2.js',
61
+ 'fix-issues-step3.js',
62
+ 'fix-issues-step4.js',
63
+ 'fix-optimized-views.js',
64
+ 'fix-ports.js',
65
+ 'fix-settings.js',
66
+ 'fix-syntax-error.js',
67
+ 'fix-user-dashboard.js',
68
+ 'fix-workflow.js',
69
+
70
+ // 重构相关的临时脚本
71
+ 'refactor-step1.js',
72
+ 'refactor-step2.js',
73
+ 'refactor-step3.js',
74
+ 'refactor-step4.js',
75
+ 'refactor-step5.js',
76
+ 'refactor-step6.js',
77
+ 'refactor-step7.js',
78
+
79
+ // 删除相关的临时脚本
80
+ 'delete-orphan-block.js',
81
+ 'remove-bom.js',
82
+ 'remove-orphan-code.js',
83
+ 'remove-quill-from-user-dashboard.js',
84
+ 'remove-quill-imports-only.js',
85
+
86
+ // 更新相关的临时脚本
87
+ 'update-port-user.js',
88
+ 'update-port.js',
89
+
90
+ // 自动发布脚本(已不需要)
91
+ 'auto-publish.js'
92
+ ];
93
+
94
+ let deletedCount = 0;
95
+ let failedCount = 0;
96
+
97
+ console.log('📋 将要删除的脚本:\n');
98
+
99
+ scriptsToDelete.forEach((script, index) => {
100
+ const scriptPath = join(scriptsDir, script);
101
+
102
+ if (existsSync(scriptPath)) {
103
+ try {
104
+ unlinkSync(scriptPath);
105
+ console.log(` ${index + 1}. ✅ ${script}`);
106
+ deletedCount++;
107
+ } catch (error) {
108
+ console.log(` ${index + 1}. ❌ ${script} - 删除失败: ${error.message}`);
109
+ failedCount++;
110
+ }
111
+ } else {
112
+ console.log(` ${index + 1}. ⚠️ ${script} - 文件不存在`);
113
+ }
114
+ });
115
+
116
+ console.log('\n' + '='.repeat(60));
117
+ console.log('📊 清理统计:\n');
118
+ console.log(` ✅ 成功删除: ${deletedCount} 个脚本`);
119
+ console.log(` ❌ 删除失败: ${failedCount} 个脚本`);
120
+ console.log(` 📦 保留脚本: ${keepScripts.length} 个\n`);
121
+
122
+ console.log('📝 保留的脚本:\n');
123
+ keepScripts.forEach((script, index) => {
124
+ console.log(` ${index + 1}. ${script}`);
125
+ });
126
+
127
+ console.log('\n' + '='.repeat(60));
128
+ console.log('✅ 清理完成!\n');
129
+ console.log('💡 保留的脚本说明:');
130
+ console.log(' • postinstall.js - npm 安装后自动执行');
131
+ console.log(' • pre-publish-check.js - 发布前检查');
132
+ console.log(' • start-app.js - 标准启动(带端口检测)');
133
+ console.log(' • start-simple.js - 简化启动(推荐)');
134
+ console.log(' • quick-start.js - 快速启动');
135
+ console.log(' • stop-app.js - 停止所有进程');
136
+ console.log(' • open-browser.js - 自动打开浏览器');
137
+ console.log(' • fix-startup-issues.js - 修复启动问题');
138
+ console.log(' • generate-docs.js - 生成文档');
139
+ console.log('\n');
140
+
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 修复启动问题脚本
5
+ * 解决:
6
+ * 1. 端口配置不一致
7
+ * 2. 安全警告(shell: true)
8
+ * 3. Mongoose 重复索引警告
9
+ */
10
+
11
+ import { readFileSync, writeFileSync } from 'fs';
12
+ import { join, dirname } from 'path';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = dirname(__filename);
17
+ const rootDir = join(__dirname, '..');
18
+
19
+ console.log('🔧 开始修复启动问题...\n');
20
+
21
+ let fixCount = 0;
22
+
23
+ // 1. 修复 start-app.js 中的安全警告
24
+ console.log('1️⃣ 修复 start-app.js 安全警告...');
25
+ try {
26
+ const startAppPath = join(rootDir, 'scripts', 'start-app.js');
27
+ let content = readFileSync(startAppPath, 'utf-8');
28
+
29
+ // 移除 shell: true 选项
30
+ content = content.replace(/shell: true/g, 'shell: false');
31
+
32
+ // 修复 Windows 命令
33
+ content = content.replace(
34
+ /const npmCmd = isWindows \? 'npm\.cmd' : 'npm';/g,
35
+ "const npmCmd = isWindows ? 'npm.cmd' : 'npm';"
36
+ );
37
+
38
+ writeFileSync(startAppPath, content, 'utf-8');
39
+ console.log(' ✅ start-app.js 已修复\n');
40
+ fixCount++;
41
+ } catch (error) {
42
+ console.log(' ⚠️ start-app.js 修复失败:', error.message, '\n');
43
+ }
44
+
45
+ // 2. 修复 bin/cli.js 中的安全警告
46
+ console.log('2️⃣ 修复 bin/cli.js 安全警告...');
47
+ try {
48
+ const cliPath = join(rootDir, 'bin', 'cli.js');
49
+ let content = readFileSync(cliPath, 'utf-8');
50
+
51
+ // 移除 shell: true 选项
52
+ content = content.replace(/shell: true/g, 'shell: false');
53
+
54
+ writeFileSync(cliPath, content, 'utf-8');
55
+ console.log(' ✅ bin/cli.js 已修复\n');
56
+ fixCount++;
57
+ } catch (error) {
58
+ console.log(' ⚠️ bin/cli.js 修复失败:', error.message, '\n');
59
+ }
60
+
61
+ // 3. 修复 User.js 中的重复索引
62
+ console.log('3️⃣ 修复 User.js 重复索引警告...');
63
+ try {
64
+ const userModelPath = join(rootDir, 'server', 'models', 'User.js');
65
+ let content = readFileSync(userModelPath, 'utf-8');
66
+
67
+ // 移除 index: true,只保留 unique: true
68
+ content = content.replace(
69
+ /username: \{ type: String, required: true, unique: true, index: true \}/g,
70
+ 'username: { type: String, required: true, unique: true }'
71
+ );
72
+
73
+ content = content.replace(
74
+ /email: \{ type: String, required: true, unique: true, index: true \}/g,
75
+ 'email: { type: String, required: true, unique: true }'
76
+ );
77
+
78
+ writeFileSync(userModelPath, content, 'utf-8');
79
+ console.log(' ✅ User.js 已修复\n');
80
+ fixCount++;
81
+ } catch (error) {
82
+ console.log(' ⚠️ User.js 修复失败:', error.message, '\n');
83
+ }
84
+
85
+ // 4. 创建 .env 文件(如果不存在)
86
+ console.log('4️⃣ 检查 .env 配置...');
87
+ try {
88
+ const envPath = join(rootDir, '.env');
89
+ const envExamplePath = join(rootDir, '.env.example');
90
+
91
+ let envContent = '';
92
+ try {
93
+ envContent = readFileSync(envPath, 'utf-8');
94
+ } catch {
95
+ // .env 不存在,创建默认配置
96
+ envContent = `# MongoDB 配置
97
+ MONGODB_URI=mongodb://localhost:27017/collabdocchat
98
+
99
+ # JWT 密钥
100
+ JWT_SECRET=your_jwt_secret_key_change_this_in_production
101
+
102
+ # 服务器端口
103
+ PORT=3000
104
+
105
+ # Node 环境
106
+ NODE_ENV=development
107
+ `;
108
+ writeFileSync(envPath, envContent, 'utf-8');
109
+ console.log(' ✅ 已创建 .env 文件\n');
110
+ fixCount++;
111
+ }
112
+
113
+ // 检查端口配置
114
+ if (!envContent.includes('PORT=')) {
115
+ envContent += '\n# 服务器端口\nPORT=3000\n';
116
+ writeFileSync(envPath, envContent, 'utf-8');
117
+ console.log(' ✅ 已添加 PORT 配置\n');
118
+ fixCount++;
119
+ } else {
120
+ console.log(' ✅ .env 配置正常\n');
121
+ }
122
+ } catch (error) {
123
+ console.log(' ⚠️ .env 配置失败:', error.message, '\n');
124
+ }
125
+
126
+ // 总结
127
+ console.log('='.repeat(50));
128
+ console.log(`✅ 修复完成!共修复 ${fixCount} 个问题\n`);
129
+ console.log('📝 修复内容:');
130
+ console.log(' 1. 移除不安全的 shell: true 选项');
131
+ console.log(' 2. 修复 Mongoose 重复索引警告');
132
+ console.log(' 3. 确保 .env 配置正确\n');
133
+ console.log('🚀 现在可以重新启动应用:');
134
+ console.log(' collabdocchat');
135
+ console.log(' 或: npm start\n');
136
+
@@ -3,12 +3,16 @@ import { platform } from 'os';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { dirname, join } from 'path';
5
5
  import http from 'http';
6
- import { existsSync } from 'fs';
6
+ import { existsSync, readFileSync } from 'fs';
7
+ import dotenv from 'dotenv';
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url);
9
10
  const __dirname = dirname(__filename);
10
11
  const rootDir = join(__dirname, '..');
11
12
 
13
+ // 加载 .env 文件
14
+ dotenv.config({ path: join(rootDir, '.env') });
15
+
12
16
  const PORT = process.env.PORT || 8765;
13
17
  const CLIENT_PORT = 5173;
14
18
  const CLIENT_URL = `http://localhost:${CLIENT_PORT}`;
@@ -29,7 +33,7 @@ function installDevDependencies() {
29
33
  const install = spawn(npmCmd, ['install'], {
30
34
  cwd: rootDir,
31
35
  stdio: 'inherit',
32
- shell: true
36
+ shell: false
33
37
  });
34
38
 
35
39
  install.on('close', (code) => {
@@ -92,7 +96,7 @@ function openBrowser(url) {
92
96
  const browser = spawn(command, args, {
93
97
  stdio: 'ignore',
94
98
  detached: true,
95
- shell: true
99
+ shell: false
96
100
  });
97
101
  browser.unref();
98
102
  } catch (error) {
@@ -146,7 +150,8 @@ function startServer() {
146
150
  const server = spawn('node', ['server/index.js'], {
147
151
  cwd: rootDir,
148
152
  stdio: 'inherit',
149
- shell: true
153
+ shell: false,
154
+ env: { ...process.env }
150
155
  });
151
156
 
152
157
  return server;
@@ -159,7 +164,8 @@ function startClient() {
159
164
  const client = spawn(npmCmd, ['run', 'client'], {
160
165
  cwd: rootDir,
161
166
  stdio: 'inherit',
162
- shell: true
167
+ shell: false,
168
+ env: { ...process.env }
163
169
  });
164
170
 
165
171
  return client;
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 简化的启动脚本 - 避免超时问题
5
+ */
6
+
7
+ import { spawn } from 'child_process';
8
+ import { platform } from 'os';
9
+ import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
11
+ import dotenv from 'dotenv';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const rootDir = join(__dirname, '..');
16
+ const isWindows = platform() === 'win32';
17
+
18
+ // 加载环境变量
19
+ dotenv.config({ path: join(rootDir, '.env') });
20
+
21
+ const PORT = process.env.PORT || 8765;
22
+
23
+ console.log('📦 CollabDocChat 正在启动...\n');
24
+
25
+ // 启动服务器
26
+ console.log('🚀 正在启动服务器...');
27
+ const server = spawn('node', ['server/index.js'], {
28
+ cwd: rootDir,
29
+ stdio: 'inherit',
30
+ env: { ...process.env }
31
+ });
32
+
33
+ server.on('error', (error) => {
34
+ console.error('❌ 服务器启动失败:', error.message);
35
+ process.exit(1);
36
+ });
37
+
38
+ // 等待3秒后启动客户端
39
+ setTimeout(() => {
40
+ console.log('\n🎨 正在启动客户端...\n');
41
+ const npmCmd = isWindows ? 'npm.cmd' : 'npm';
42
+ const client = spawn(npmCmd, ['run', 'client'], {
43
+ cwd: rootDir,
44
+ stdio: 'inherit',
45
+ env: { ...process.env }
46
+ });
47
+
48
+ client.on('error', (error) => {
49
+ console.error('❌ 客户端启动失败:', error.message);
50
+ });
51
+
52
+ // 再等待5秒后打开浏览器
53
+ setTimeout(() => {
54
+ console.log('\n✅ 应用启动成功!');
55
+ console.log('\n💡 访问地址:');
56
+ console.log(` • 服务器: http://localhost:${PORT}`);
57
+ console.log(' • 客户端: http://localhost:5173');
58
+ console.log(' • 默认账号: admin / admin123');
59
+ console.log('\n⚠️ 按 Ctrl+C 停止服务\n');
60
+
61
+ // 打开浏览器
62
+ try {
63
+ const openCmd = isWindows ? 'start' : (platform() === 'darwin' ? 'open' : 'xdg-open');
64
+ const url = 'http://localhost:5173';
65
+
66
+ if (isWindows) {
67
+ spawn('cmd', ['/c', 'start', '', url], {
68
+ stdio: 'ignore',
69
+ detached: true
70
+ }).unref();
71
+ } else {
72
+ spawn(openCmd, [url], {
73
+ stdio: 'ignore',
74
+ detached: true
75
+ }).unref();
76
+ }
77
+ } catch (error) {
78
+ console.log('⚠️ 无法自动打开浏览器,请手动访问: http://localhost:5173');
79
+ }
80
+ }, 5000);
81
+
82
+ // 处理退出信号
83
+ process.on('SIGINT', () => {
84
+ console.log('\n\n🛑 正在关闭服务器...');
85
+ server.kill();
86
+ client.kill();
87
+ process.exit(0);
88
+ });
89
+
90
+ process.on('SIGTERM', () => {
91
+ server.kill();
92
+ client.kill();
93
+ process.exit(0);
94
+ });
95
+ }, 3000);
96
+
@@ -1,58 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- const filePath = path.join(__dirname, '../src/pages/admin-dashboard.js');
9
-
10
- console.log('添加按钮悬停效果...');
11
- let content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 查找设置按钮的点击事件位置
14
- const settingsBtnPattern = /document\.getElementById\('settingsBtn'\)\.addEventListener\('click', \(\) => \{/;
15
-
16
- if (settingsBtnPattern.test(content)) {
17
- // 在设置按钮点击事件之前添加悬停效果
18
- const hoverEffects = `
19
- // 设置和帮助按钮悬停效果
20
- const settingsBtn = document.getElementById('settingsBtn');
21
- const helpBtn = document.getElementById('helpBtn');
22
-
23
- settingsBtn.addEventListener('mouseenter', () => {
24
- settingsBtn.style.transform = 'translateY(-2px)';
25
- settingsBtn.style.boxShadow = '0 4px 12px rgba(102, 126, 234, 0.5)';
26
- });
27
- settingsBtn.addEventListener('mouseleave', () => {
28
- settingsBtn.style.transform = 'translateY(0)';
29
- settingsBtn.style.boxShadow = '0 2px 8px rgba(102, 126, 234, 0.3)';
30
- });
31
-
32
- helpBtn.addEventListener('mouseenter', () => {
33
- helpBtn.style.transform = 'translateY(-2px)';
34
- helpBtn.style.boxShadow = '0 4px 12px rgba(240, 147, 251, 0.5)';
35
- });
36
- helpBtn.addEventListener('mouseleave', () => {
37
- helpBtn.style.transform = 'translateY(0)';
38
- helpBtn.style.boxShadow = '0 2px 8px rgba(240, 147, 251, 0.3)';
39
- });
40
-
41
- `;
42
-
43
- content = content.replace(
44
- settingsBtnPattern,
45
- hoverEffects + "document.getElementById('settingsBtn').addEventListener('click', () => {"
46
- );
47
-
48
- console.log('✅ 悬停效果已添加');
49
- } else {
50
- console.log('⚠️ 未找到设置按钮点击事件');
51
- }
52
-
53
- fs.writeFileSync(filePath, content, 'utf8');
54
-
55
- console.log('\n✅ 完成!按钮现在有悬停动画效果');
56
-
57
-
58
-
@@ -1,27 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- const filePath = path.join(__dirname, '../src/pages/admin-dashboard.js');
9
-
10
- console.log('添加缺失的闭合括号...');
11
- let content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 在文件末尾添加缺失的 }
14
- content = content.trimEnd();
15
- if (!content.endsWith('}')) {
16
- content += '\n}\n';
17
- }
18
-
19
- // 再添加一个
20
- content += '\n';
21
-
22
- fs.writeFileSync(filePath, content, 'utf8');
23
-
24
- console.log('✅ 已添加缺失的闭合括号');
25
-
26
-
27
-
@@ -1,68 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- const filePath = path.join(__dirname, '../src/pages/admin-dashboard.js');
9
-
10
- console.log('读取文件...');
11
- let content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 找到最后一个 renderView('groups'); 之前插入新函数
14
- const insertPoint = content.lastIndexOf(" renderView('groups');");
15
-
16
- if (insertPoint === -1) {
17
- console.error('❌ 找不到插入点');
18
- process.exit(1);
19
- }
20
-
21
- const newFunctions = `
22
- // 知识库管理
23
- async function renderKnowledgeView(container) {
24
- if (!currentGroup) {
25
- container.innerHTML = '<div class="empty-state">请先选择一个群组</div>';
26
- return;
27
- }
28
- container.innerHTML = '<div class="empty-state">知识库功能开发中...</div>';
29
- }
30
-
31
- // 工作流管理
32
- async function renderWorkflowView(container) {
33
- if (!currentGroup) {
34
- container.innerHTML = '<div class="empty-state">请先选择一个群组</div>';
35
- return;
36
- }
37
- container.innerHTML = '<div class="empty-state">工作流功能开发中...</div>';
38
- }
39
-
40
- // 备份管理
41
- async function renderBackupView(container) {
42
- container.innerHTML = '<div class="empty-state">备份功能开发中...</div>';
43
- }
44
-
45
- // AI助手
46
- async function renderAIView(container) {
47
- container.innerHTML = '<div class="empty-state">AI助手功能开发中...</div>';
48
- }
49
-
50
- // 数据导出
51
- async function renderExportView(container) {
52
- container.innerHTML = '<div class="empty-state">数据导出功能开发中...</div>';
53
- }
54
-
55
- `;
56
-
57
- const before = content.substring(0, insertPoint);
58
- const after = content.substring(insertPoint);
59
-
60
- content = before + newFunctions + after;
61
-
62
- console.log('写入文件...');
63
- fs.writeFileSync(filePath, content, 'utf8');
64
-
65
- console.log('✅ 完成!已添加缺失的函数');
66
-
67
-
68
-