collabdocchat 2.4.5 → 2.4.7

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
@@ -1,65 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { execSync } from 'child_process';
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
- const rootDir = path.join(__dirname, '..');
9
-
10
- console.log('🚀 开始自动发布流程...\n');
11
-
12
- // 1. 读取当前版本
13
- const packagePath = path.join(rootDir, 'package.json');
14
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
15
- const currentVersion = packageJson.version;
16
- const versionParts = currentVersion.split('.');
17
- const newPatch = parseInt(versionParts[2]) + 1;
18
- const newVersion = `${versionParts[0]}.${versionParts[1]}.${newPatch}`;
19
-
20
- console.log(`📦 当前版本: ${currentVersion}`);
21
- console.log(`📦 新版本: ${newVersion}\n`);
22
-
23
- // 2. 更新版本号
24
- packageJson.version = newVersion;
25
- fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2), 'utf8');
26
- console.log('✅ 版本号已更新\n');
27
-
28
- // 3. 更新 CHANGELOG
29
- const changelogPath = path.join(rootDir, 'CHANGELOG.md');
30
- let changelog = fs.readFileSync(changelogPath, 'utf8');
31
- const today = new Date().toISOString().split('T')[0];
32
- const newEntry = `# 更新日志
33
-
34
- 所有重要的项目更改都将记录在此文件中。
35
-
36
- ## [${newVersion}] - ${today}
37
-
38
- ### 🐛 Bug 修复
39
- - 修复 auth.js 端口配置问题
40
- - 确保所有 API 调用使用正确的端口 8765
41
-
42
- `;
43
-
44
- changelog = newEntry + changelog.substring(changelog.indexOf('\n## ['));
45
- fs.writeFileSync(changelogPath, changelog, 'utf8');
46
- console.log('✅ CHANGELOG 已更新\n');
47
-
48
- // 4. 发布到 npm
49
- console.log('📤 正在发布到 npm...\n');
50
- try {
51
- execSync('npm publish --access public', {
52
- cwd: rootDir,
53
- stdio: 'inherit'
54
- });
55
- console.log('\n✅ 发布成功!\n');
56
- console.log(`🎉 版本 ${newVersion} 已发布到 npm\n`);
57
- console.log('📝 安装命令:');
58
- console.log(` npm install -g collabdocchat@${newVersion} --registry=https://registry.npmmirror.com\n`);
59
- } catch (error) {
60
- console.error('\n❌ 发布失败:', error.message);
61
- process.exit(1);
62
- }
63
-
64
-
65
-
@@ -1,47 +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 oldButtonsSection = ` <div class="sidebar-footer">
15
- <button class="sidebar-footer-btn" id="settingsBtn">
16
- <span class="icon">⚙️</span> 设置
17
- </button>
18
- <button class="sidebar-footer-btn" id="helpBtn">
19
- <span class="icon">❓</span> 帮助
20
- </button>
21
- </div>`;
22
-
23
- const newButtonsSection = ` <div class="sidebar-footer" style="display: flex; gap: 8px; padding: 0 10px;">
24
- <button class="sidebar-footer-btn" id="settingsBtn" style="flex: 1; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 12px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); display: flex; align-items: center; justify-content: center; gap: 6px;">
25
- <span class="icon" style="font-size: 18px;">⚙️</span>
26
- <span>设置</span>
27
- </button>
28
- <button class="sidebar-footer-btn" id="helpBtn" style="flex: 1; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; border: none; padding: 12px; border-radius: 10px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3); display: flex; align-items: center; justify-content: center; gap: 6px;">
29
- <span class="icon" style="font-size: 18px;">❓</span>
30
- <span>帮助</span>
31
- </button>
32
- </div>`;
33
-
34
- content = content.replace(oldButtonsSection, newButtonsSection);
35
- console.log('✅ 设置和帮助按钮已美化');
36
-
37
- fs.writeFileSync(filePath, content, 'utf8');
38
-
39
- console.log('\n✅ 美化完成!');
40
- console.log('\n变更内容:');
41
- console.log('1. 设置按钮:紫色渐变背景 + 白色文字 + 阴影');
42
- console.log('2. 帮助按钮:粉色渐变背景 + 白色文字 + 阴影');
43
- console.log('3. 按钮并排显示,各占50%宽度');
44
- console.log('4. 图标和文字居中对齐');
45
-
46
-
47
-
@@ -1,269 +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('美化设置和帮助按钮,优化AI助手界面...');
11
- let content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 1. 查找并替换设置和帮助按钮的样式
14
- const oldButtons = ` <button class="nav-btn" id="settingsBtn">⚙️ 设置</button>
15
- <button class="nav-btn" id="helpBtn">❓ 帮助</button>`;
16
-
17
- const newButtons = ` <button class="nav-btn" id="settingsBtn" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);">⚙️ 设置</button>
18
- <button class="nav-btn" id="helpBtn" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3); margin-left: 10px;">❓ 帮助</button>`;
19
-
20
- if (content.includes(oldButtons)) {
21
- content = content.replace(oldButtons, newButtons);
22
- console.log('✅ 设置和帮助按钮样式已更新');
23
- } else {
24
- console.log('⚠️ 未找到设置和帮助按钮,尝试其他匹配方式...');
25
- }
26
-
27
- // 2. 删除AI助手模态框底部的输入框和提示
28
- const oldAIInput = ` <!-- 输入区域 -->
29
- <div class="ai-input-container" style="padding: 20px; border-top: 1px solid var(--border); background: var(--bg-secondary);">
30
- <div style="display: flex; gap: 12px; align-items: end;">
31
- <textarea id="aiInputText" placeholder="输入你的问题..." rows="1" style="flex: 1; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; resize: none; font-size: 14px; transition: border-color 0.2s; max-height: 120px;"></textarea>
32
- <button class="btn-primary" id="aiSendBtnModal" style="padding: 12px 24px; border-radius: 12px; font-size: 15px; font-weight: 600; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; cursor: pointer; transition: transform 0.2s;">
33
- <span style="display: flex; align-items: center; gap: 6px;">
34
- <span>发送</span>
35
- <span>🚀</span>
36
- </span>
37
- </button>
38
- </div>
39
- <div style="margin-top: 10px; font-size: 11px; color: var(--text-tertiary); text-align: center;">
40
- 💡 提示:按 Enter 发送,Shift + Enter 换行
41
- </div>
42
- </div>`;
43
-
44
- const newAIInput = ` <!-- 输入区域已移除,使用快捷问题按钮 -->`;
45
-
46
- content = content.replace(oldAIInput, newAIInput);
47
- console.log('✅ AI助手输入框已删除');
48
-
49
- // 3. 优化AI助手的快捷问题按钮样式
50
- const oldQuickButtons = ` <div style="display: flex; gap: 8px; flex-wrap: wrap;">
51
- <button class="quick-question-btn" data-question="如何创建一个新文档?" style="padding: 6px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.2s;">📄 如何创建文档?</button>
52
- <button class="quick-question-btn" data-question="如何邀请成员加入群组?" style="padding: 6px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.2s;">👥 如何邀请成员?</button>
53
- <button class="quick-question-btn" data-question="如何使用工作流功能?" style="padding: 6px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.2s;">⚙️ 工作流使用?</button>
54
- <button class="quick-question-btn" data-question="如何备份数据?" style="padding: 6px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.2s;">💾 如何备份?</button>
55
- </div>`;
56
-
57
- const newQuickButtons = ` <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;">
58
- <button class="quick-question-btn" data-question="如何创建一个新文档?" style="padding: 12px 16px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); display: flex; align-items: center; gap: 8px;">
59
- <span style="font-size: 20px;">📄</span>
60
- <span>如何创建文档?</span>
61
- </button>
62
- <button class="quick-question-btn" data-question="如何邀请成员加入群组?" style="padding: 12px 16px; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; border: none; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3); display: flex; align-items: center; gap: 8px;">
63
- <span style="font-size: 20px;">👥</span>
64
- <span>如何邀请成员?</span>
65
- </button>
66
- <button class="quick-question-btn" data-question="如何使用工作流功能?" style="padding: 12px 16px; background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; border: none; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3); display: flex; align-items: center; gap: 8px;">
67
- <span style="font-size: 20px;">⚙️</span>
68
- <span>工作流使用?</span>
69
- </button>
70
- <button class="quick-question-btn" data-question="如何备份数据?" style="padding: 12px 16px; background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); color: white; border: none; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(250, 112, 154, 0.3); display: flex; align-items: center; gap: 8px;">
71
- <span style="font-size: 20px;">💾</span>
72
- <span>如何备份?</span>
73
- </button>
74
- </div>`;
75
-
76
- content = content.replace(oldQuickButtons, newQuickButtons);
77
- console.log('✅ 快捷问题按钮已美化');
78
-
79
- // 4. 更新快捷问题按钮的事件处理,移除输入框相关代码
80
- const oldQuickBtnHandler = ` // 快捷问题按钮
81
- document.querySelectorAll('.quick-question-btn').forEach(btn => {
82
- btn.addEventListener('click', () => {
83
- document.getElementById('aiInputText').value = btn.dataset.question;
84
- document.getElementById('aiSendBtnModal').click();
85
- });
86
- btn.addEventListener('mouseenter', (e) => {
87
- e.target.style.background = 'var(--primary)';
88
- e.target.style.color = 'white';
89
- e.target.style.transform = 'translateY(-2px)';
90
- });
91
- btn.addEventListener('mouseleave', (e) => {
92
- e.target.style.background = 'var(--bg)';
93
- e.target.style.color = 'inherit';
94
- e.target.style.transform = 'translateY(0)';
95
- });
96
- });`;
97
-
98
- const newQuickBtnHandler = ` // 快捷问题按钮 - 直接发送问题
99
- document.querySelectorAll('.quick-question-btn').forEach(btn => {
100
- btn.addEventListener('click', async () => {
101
- const question = btn.dataset.question;
102
- const chatMessages = document.getElementById('aiChatMessages');
103
-
104
- // 显示用户问题
105
- const userMsg = document.createElement('div');
106
- userMsg.className = 'ai-message user';
107
- userMsg.textContent = question;
108
- userMsg.style.cssText = 'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 18px; border-radius: 18px 18px 4px 18px; margin: 10px 0; max-width: 75%; margin-left: auto; text-align: right; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); animation: slideInRight 0.3s ease;';
109
- chatMessages.appendChild(userMsg);
110
- chatMessages.scrollTop = chatMessages.scrollHeight;
111
-
112
- // 发送到AI
113
- try {
114
- const token = localStorage.getItem('token');
115
- const response = await fetch('http://localhost:8765/api/ai/ask', {
116
- method: 'POST',
117
- headers: {
118
- 'Content-Type': 'application/json',
119
- 'Authorization': \`Bearer \${token}\`
120
- },
121
- body: JSON.stringify({ question })
122
- });
123
-
124
- const data = await response.json();
125
-
126
- // 显示AI回复
127
- const aiMsg = document.createElement('div');
128
- aiMsg.className = 'ai-message ai';
129
- aiMsg.textContent = data.answer || '抱歉,我现在无法回答这个问题。';
130
- aiMsg.style.cssText = 'background: var(--bg-secondary); padding: 15px 18px; border-radius: 18px 18px 18px 4px; margin: 10px 0; max-width: 75%; border: 1px solid var(--border); box-shadow: 0 2px 4px rgba(0,0,0,0.05); animation: slideInLeft 0.3s ease; line-height: 1.6;';
131
- chatMessages.appendChild(aiMsg);
132
- chatMessages.scrollTop = chatMessages.scrollHeight;
133
- } catch (error) {
134
- const errorMsg = document.createElement('div');
135
- errorMsg.className = 'ai-message ai';
136
- errorMsg.textContent = '抱歉,发生了错误:' + error.message;
137
- errorMsg.style.cssText = 'background: var(--bg-secondary); padding: 15px 18px; border-radius: 18px 18px 18px 4px; margin: 10px 0; max-width: 75%; border: 1px solid var(--border); box-shadow: 0 2px 4px rgba(0,0,0,0.05); animation: slideInLeft 0.3s ease; line-height: 1.6;';
138
- chatMessages.appendChild(errorMsg);
139
- chatMessages.scrollTop = chatMessages.scrollHeight;
140
- }
141
- });
142
-
143
- // 悬停效果
144
- btn.addEventListener('mouseenter', (e) => {
145
- e.target.style.transform = 'translateY(-3px) scale(1.02)';
146
- e.target.style.boxShadow = '0 4px 12px rgba(0,0,0,0.2)';
147
- });
148
- btn.addEventListener('mouseleave', (e) => {
149
- e.target.style.transform = 'translateY(0) scale(1)';
150
- const gradient = e.target.style.background;
151
- if (gradient.includes('667eea')) {
152
- e.target.style.boxShadow = '0 2px 8px rgba(102, 126, 234, 0.3)';
153
- } else if (gradient.includes('f093fb')) {
154
- e.target.style.boxShadow = '0 2px 8px rgba(240, 147, 251, 0.3)';
155
- } else if (gradient.includes('4facfe')) {
156
- e.target.style.boxShadow = '0 2px 8px rgba(79, 172, 254, 0.3)';
157
- } else {
158
- e.target.style.boxShadow = '0 2px 8px rgba(250, 112, 154, 0.3)';
159
- }
160
- });
161
- });`;
162
-
163
- content = content.replace(oldQuickBtnHandler, newQuickBtnHandler);
164
- console.log('✅ 快捷问题按钮事件已更新');
165
-
166
- // 5. 删除不再需要的输入框相关代码
167
- const inputRelatedCode = [
168
- ` // AI输入框自动调整高度
169
- const aiInput = document.getElementById('aiInputText');
170
- aiInput.addEventListener('input', () => {
171
- aiInput.style.height = 'auto';
172
- aiInput.style.height = aiInput.scrollHeight + 'px';
173
- });
174
-
175
- // 支持 Enter 发送,Shift+Enter 换行
176
- aiInput.addEventListener('keydown', (e) => {
177
- if (e.key === 'Enter' && !e.shiftKey) {
178
- e.preventDefault();
179
- document.getElementById('aiSendBtnModal').click();
180
- }
181
- });
182
-
183
- // 输入框聚焦效果
184
- aiInput.addEventListener('focus', () => {
185
- aiInput.style.borderColor = 'var(--primary)';
186
- });
187
- aiInput.addEventListener('blur', () => {
188
- aiInput.style.borderColor = 'var(--border)';
189
- });
190
-
191
- // 发送按钮悬停效果
192
- const aiSendBtn = document.getElementById('aiSendBtnModal');
193
- aiSendBtn.addEventListener('mouseenter', () => {
194
- aiSendBtn.style.transform = 'scale(1.05)';
195
- });
196
- aiSendBtn.addEventListener('mouseleave', () => {
197
- aiSendBtn.style.transform = 'scale(1)';
198
- });
199
-
200
- document.getElementById('aiSendBtnModal').addEventListener('click', async () => {`,
201
- ` document.getElementById('aiSendBtnModal').addEventListener('click', async () => {
202
- const question = document.getElementById('aiInputText').value.trim();
203
- if (!question) return;
204
-
205
- const chatMessages = document.getElementById('aiChatMessages');
206
-
207
- // 显示用户消息
208
- const userMsg = document.createElement('div');
209
- userMsg.className = 'ai-message user';
210
- userMsg.textContent = question;
211
- userMsg.style.cssText = 'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 18px; border-radius: 18px 18px 4px 18px; margin: 10px 0; max-width: 75%; margin-left: auto; text-align: right; box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3); animation: slideInRight 0.3s ease;';
212
- chatMessages.appendChild(userMsg);
213
-
214
- // 清空输入框
215
- document.getElementById('aiInputText').value = '';
216
- document.getElementById('aiInputText').style.height = 'auto';
217
-
218
- chatMessages.scrollTop = chatMessages.scrollHeight;
219
-
220
- try {
221
- const token = localStorage.getItem('token');
222
- const response = await fetch('http://localhost:8765/api/ai/ask', {
223
- method: 'POST',
224
- headers: {
225
- 'Content-Type': 'application/json',
226
- 'Authorization': \`Bearer \${token}\`
227
- },
228
- body: JSON.stringify({ question })
229
- });
230
-
231
- const data = await response.json();
232
-
233
- // 显示AI回复
234
- const aiMsg = document.createElement('div');
235
- aiMsg.className = 'ai-message ai';
236
- aiMsg.textContent = data.answer || '抱歉,我现在无法回答这个问题。';
237
- aiMsg.style.cssText = 'background: var(--bg-secondary); padding: 15px 18px; border-radius: 18px 18px 18px 4px; margin: 10px 0; max-width: 75%; border: 1px solid var(--border); box-shadow: 0 2px 4px rgba(0,0,0,0.05); animation: slideInLeft 0.3s ease; line-height: 1.6;';
238
- chatMessages.appendChild(aiMsg);
239
- chatMessages.scrollTop = chatMessages.scrollHeight;
240
- } catch (error) {
241
- const errorMsg = document.createElement('div');
242
- errorMsg.className = 'ai-message ai';
243
- errorMsg.textContent = '抱歉,发生了错误:' + error.message;
244
- errorMsg.style.cssText = 'background: var(--bg-secondary); padding: 15px 18px; border-radius: 18px 18px 18px 4px; margin: 10px 0; max-width: 75%; border: 1px solid var(--border); box-shadow: 0 2px 4px rgba(0,0,0,0.05); animation: slideInLeft 0.3s ease; line-height: 1.6;';
245
- chatMessages.appendChild(errorMsg);
246
- chatMessages.scrollTop = chatMessages.scrollHeight;
247
- }
248
- });`
249
- ];
250
-
251
- inputRelatedCode.forEach(code => {
252
- if (content.includes(code)) {
253
- content = content.replace(code, '');
254
- console.log('✅ 已删除输入框相关代码');
255
- }
256
- });
257
-
258
- fs.writeFileSync(filePath, content, 'utf8');
259
-
260
- console.log('\n✅ 所有美化完成!');
261
- console.log('\n变更内容:');
262
- console.log('1. 设置按钮:紫色渐变 + 阴影');
263
- console.log('2. 帮助按钮:粉色渐变 + 阴影');
264
- console.log('3. AI助手:删除底部输入框');
265
- console.log('4. 快捷问题:2x2网格布局,渐变色按钮');
266
- console.log('5. 点击快捷问题直接发送到AI');
267
-
268
-
269
-
@@ -1,50 +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('检查 JavaScript 语法...');
11
- const content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 检查括号匹配
14
- let braceCount = 0;
15
- let parenCount = 0;
16
- let bracketCount = 0;
17
- const lines = content.split('\n');
18
-
19
- for (let i = 0; i < lines.length; i++) {
20
- const line = lines[i];
21
-
22
- // 跳过注释和字符串
23
- const cleanLine = line.replace(/\/\/.*$/, '').replace(/'[^']*'/g, '').replace(/"[^"]*"/g, '').replace(/`[^`]*`/g, '');
24
-
25
- for (const char of cleanLine) {
26
- if (char === '{') braceCount++;
27
- if (char === '}') braceCount--;
28
- if (char === '(') parenCount++;
29
- if (char === ')') parenCount--;
30
- if (char === '[') bracketCount++;
31
- if (char === ']') bracketCount--;
32
-
33
- if (braceCount < 0 || parenCount < 0 || bracketCount < 0) {
34
- console.log(`\n❌ 第 ${i + 1} 行发现不匹配的括号:`);
35
- console.log(` ${line.trim()}`);
36
- console.log(` 大括号: ${braceCount}, 圆括号: ${parenCount}, 方括号: ${bracketCount}`);
37
- break;
38
- }
39
- }
40
-
41
- if (braceCount < 0 || parenCount < 0 || bracketCount < 0) break;
42
- }
43
-
44
- console.log(`\n最终统计:`);
45
- console.log(`大括号 {}: ${braceCount > 0 ? '缺少 ' + braceCount + ' 个 }' : braceCount < 0 ? '多了 ' + Math.abs(braceCount) + ' 个 }' : '匹配'}`);
46
- console.log(`圆括号 (): ${parenCount > 0 ? '缺少 ' + parenCount + ' 个 )' : parenCount < 0 ? '多了 ' + Math.abs(parenCount) + ' 个 )' : '匹配'}`);
47
- console.log(`方括号 []: ${bracketCount > 0 ? '缺少 ' + bracketCount + ' 个 ]' : bracketCount < 0 ? '多了 ' + Math.abs(bracketCount) + ' 个 ]' : '匹配'}`);
48
-
49
-
50
-
@@ -1,43 +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 files = [
9
- '../src/pages/optimized-knowledge-view.js',
10
- '../src/pages/optimized-backup-view.js',
11
- '../src/pages/optimized-workflow-view.js'
12
- ];
13
-
14
- files.forEach(file => {
15
- const filePath = path.join(__dirname, file);
16
- console.log(`\n检查文件: ${file}`);
17
-
18
- // 读取文件为 Buffer
19
- const buffer = fs.readFileSync(filePath);
20
-
21
- // 检查 BOM
22
- if (buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
23
- console.log(' ⚠️ 发现 UTF-8 BOM,正在移除...');
24
- const content = buffer.slice(3).toString('utf8');
25
- fs.writeFileSync(filePath, content, 'utf8');
26
- console.log(' ✅ BOM 已移除');
27
- } else {
28
- console.log(' ✅ 无 BOM');
29
- }
30
-
31
- // 读取内容检查乱码
32
- const content = fs.readFileSync(filePath, 'utf8');
33
- if (content.includes('�')) {
34
- console.log(' ❌ 发现乱码字符!');
35
- } else {
36
- console.log(' ✅ 无乱码');
37
- }
38
- });
39
-
40
- console.log('\n✅ 检查完成!');
41
-
42
-
43
-
@@ -1,56 +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
- const content = fs.readFileSync(filePath, 'utf8');
12
-
13
- // 检查是否有明显的语法错误
14
- const lines = content.split('\n');
15
- let inFunction = false;
16
- let functionName = '';
17
- const scopeVars = {};
18
-
19
- lines.forEach((line, i) => {
20
- const lineNum = i + 1;
21
-
22
- // 检测函数开始
23
- if (line.match(/(?:async\s+)?function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(/)) {
24
- const match = line.match(/(?:async\s+)?function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\(/);
25
- functionName = match[1] || match[2] || 'anonymous';
26
- inFunction = true;
27
- scopeVars[functionName] = {};
28
- }
29
-
30
- // 检测变量声明
31
- const varMatch = line.match(/(?:const|let|var)\s+(\w+)\s*=/);
32
- if (varMatch && inFunction) {
33
- const varName = varMatch[1];
34
- if (!scopeVars[functionName][varName]) {
35
- scopeVars[functionName][varName] = [];
36
- }
37
- scopeVars[functionName][varName].push(lineNum);
38
- }
39
-
40
- // 检测函数结束(简单检测)
41
- if (line.match(/^\s*}\s*$/) && inFunction) {
42
- // 检查当前函数作用域的重复声明
43
- for (const [varName, lineNumbers] of Object.entries(scopeVars[functionName])) {
44
- if (lineNumbers.length > 1) {
45
- console.log(`\n⚠️ 在函数 ${functionName} 中发现重复声明: ${varName}`);
46
- console.log(` 出现在第 ${lineNumbers.join(', ')} 行`);
47
- }
48
- }
49
- inFunction = false;
50
- }
51
- });
52
-
53
- console.log('\n✅ 语法检查完成');
54
-
55
-
56
-
@@ -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('删除第 1339-1531 行的孤立代码...');
11
- let content = fs.readFileSync(filePath, 'utf8');
12
- const lines = content.split('\n');
13
-
14
- // 删除第 1339 行(索引 1338)到第 1531 行(索引 1530)之前的内容
15
- const newLines = [
16
- ...lines.slice(0, 1338), // 保留前 1338 行
17
- '', // 保留空行
18
- ...lines.slice(1531) // 从第 1532 行开始保留
19
- ];
20
-
21
- content = newLines.join('\n');
22
- fs.writeFileSync(filePath, content, 'utf8');
23
-
24
- console.log('✅ 已删除 ' + (1531 - 1338) + ' 行孤立代码');
25
-
26
-
27
-
@@ -1,22 +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
- const content = fs.readFileSync(filePath, 'utf8');
10
- const lines = content.split('\n');
11
-
12
- console.log('搜索设置和帮助按钮...\n');
13
-
14
- lines.forEach((line, i) => {
15
- if ((line.includes('设置') || line.includes('帮助')) &&
16
- (line.includes('btn') || line.includes('button') || line.includes('nav-btn'))) {
17
- console.log(`第 ${i + 1} 行: ${line.trim()}`);
18
- }
19
- });
20
-
21
-
22
-
@@ -1,37 +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
- const content = fs.readFileSync(filePath, 'utf8');
12
- const lines = content.split('\n');
13
-
14
- const declarations = {};
15
- lines.forEach((line, i) => {
16
- const match = line.match(/(?:const|let|var)\s+(\w+)\s*=/);
17
- if (match) {
18
- const varName = match[1];
19
- if (!declarations[varName]) {
20
- declarations[varName] = [];
21
- }
22
- declarations[varName].push(i + 1);
23
- }
24
- });
25
-
26
- console.log('\n重复声明的变量:');
27
- for (const [varName, lineNumbers] of Object.entries(declarations)) {
28
- if (lineNumbers.length > 1) {
29
- console.log(`\n${varName}: 出现在第 ${lineNumbers.join(', ')} 行`);
30
- lineNumbers.forEach(lineNum => {
31
- console.log(` ${lineNum}: ${lines[lineNum - 1].trim()}`);
32
- });
33
- }
34
- }
35
-
36
-
37
-