collabdocchat 2.0.7 → 2.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collabdocchat",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "开源的实时协作文档聊天平台 - 集成任务管理、多人文档编辑、智能点名功能",
5
5
  "main": "./server/index.js",
6
6
  "type": "module",
@@ -31,12 +31,18 @@ function replacePort(filePath) {
31
31
  let content = fs.readFileSync(filePath, 'utf8');
32
32
  const originalContent = content;
33
33
 
34
+ // 移除 BOM(如果存在)
35
+ if (content.charCodeAt(0) === 0xFEFF) {
36
+ content = content.slice(1);
37
+ }
38
+
34
39
  // 替换所有 8765 端口为 3000
35
40
  content = content.replace(/http:\/\/localhost:8765/g, 'http://localhost:3000');
36
41
  content = content.replace(/ws:\/\/localhost:8765/g, 'ws://localhost:3000');
37
42
 
38
43
  if (content !== originalContent) {
39
- fs.writeFileSync(filePath, content, 'utf8');
44
+ // 写入时不添加 BOM
45
+ fs.writeFileSync(filePath, content, { encoding: 'utf8' });
40
46
  console.log(`✅ 已修复: ${filePath}`);
41
47
  return true;
42
48
  }
@@ -0,0 +1,69 @@
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
+ // 递归查找所有 .js 文件
9
+ function findJsFiles(dir, fileList = []) {
10
+ const files = fs.readdirSync(dir);
11
+
12
+ files.forEach(file => {
13
+ const filePath = path.join(dir, file);
14
+ const stat = fs.statSync(filePath);
15
+
16
+ if (stat.isDirectory()) {
17
+ if (file !== 'node_modules' && file !== '.git') {
18
+ findJsFiles(filePath, fileList);
19
+ }
20
+ } else if (file.endsWith('.js')) {
21
+ fileList.push(filePath);
22
+ }
23
+ });
24
+
25
+ return fileList;
26
+ }
27
+
28
+ // 移除 BOM
29
+ function removeBOM(filePath) {
30
+ try {
31
+ const buffer = fs.readFileSync(filePath);
32
+
33
+ // 检查是否有 UTF-8 BOM (EF BB BF)
34
+ if (buffer.length >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
35
+ // 移除 BOM
36
+ const contentWithoutBOM = buffer.slice(3);
37
+ fs.writeFileSync(filePath, contentWithoutBOM);
38
+ console.log(`✅ 已移除 BOM: ${filePath}`);
39
+ return true;
40
+ }
41
+ return false;
42
+ } catch (error) {
43
+ console.error(`❌ 处理失败: ${filePath}`, error.message);
44
+ return false;
45
+ }
46
+ }
47
+
48
+ // 主函数
49
+ function main() {
50
+ console.log('🔍 开始扫描并移除 BOM...\n');
51
+
52
+ const projectRoot = path.join(__dirname, '..');
53
+ const srcDir = path.join(projectRoot, 'src');
54
+ const jsFiles = findJsFiles(srcDir);
55
+
56
+ console.log(`📁 找到 ${jsFiles.length} 个 JavaScript 文件\n`);
57
+
58
+ let fixedCount = 0;
59
+ jsFiles.forEach(file => {
60
+ if (removeBOM(file)) {
61
+ fixedCount++;
62
+ }
63
+ });
64
+
65
+ console.log(`\n✅ 处理完成!共移除 ${fixedCount} 个文件的 BOM`);
66
+ }
67
+
68
+ main();
69
+
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * 知识库创建和编辑功能
3
3
  */
4
4
 
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * 优化后的投票详情界面
3
3
  * 美化投票结果展示,提升用户体�? */
4
4
 
package/src/main.js CHANGED
@@ -1,20 +1,15 @@
1
- import './styles/main.css';
1
+ import './styles/main.css';
2
2
  import { AuthService } from './services/auth.js';
3
3
  import { WebSocketService } from './services/websocket.js';
4
4
  import { renderLoginPage } from './pages/login.js';
5
5
  import { renderAdminDashboard } from './pages/admin-dashboard.js';
6
6
  import { renderUserDashboard } from './pages/user-dashboard.js';
7
- import { ResponsiveHandler } from './utils/responsive-handler.js';
8
7
 
9
8
  class App {
10
9
  constructor() {
11
10
  this.authService = new AuthService();
12
11
  this.wsService = new WebSocketService();
13
12
  this.currentUser = null;
14
-
15
- // 初始化响应式处理�?
16
- this.responsiveHandler = new ResponsiveHandler();
17
-
18
13
  this.init();
19
14
  }
20
15
 
@@ -56,4 +51,3 @@ class App {
56
51
  new App();
57
52
 
58
53
 
59
-