From 394c2f16ef4f07e82e79b9203146f4fd0bd0c1de Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Sat, 31 May 2025 22:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=BA=9B=E6=98=BE?= =?UTF-8?q?=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/js/main.js | 4 ++-- client/js/room.js | 5 +---- client/js/util.file.js | 28 +++++++++------------------- client/js/util.i18n.js | 12 ++++++++++-- vite.config.js | 3 --- wrangler.toml | 2 +- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/client/js/main.js b/client/js/main.js index 140cc23..e3762fc 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -82,8 +82,8 @@ import { renderUserList, // 渲染用户列表 / Render user list // 设置全局配置参数 // Set global configuration parameters window.config = { - //wsAddress: `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}`, // WebSocket 服务器地址 / WebSocket server address - wsAddress: `ws://127.0.0.1:8787`, + wsAddress: `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}`, // WebSocket 服务器地址 / WebSocket server address + //wsAddress: `ws://127.0.0.1:8787`, debug: true // 是否开启调试模式 / Enable debug mode }; diff --git a/client/js/room.js b/client/js/room.js index 0c931d0..a86bc20 100644 --- a/client/js/room.js +++ b/client/js/room.js @@ -365,7 +365,4 @@ export function exitRoom() { return false } -export { - roomsData, - activeRoomIndex -}; \ No newline at end of file +export { roomsData, activeRoomIndex }; \ No newline at end of file diff --git a/client/js/util.file.js b/client/js/util.file.js index 5a08317..3e4d8b5 100644 --- a/client/js/util.file.js +++ b/client/js/util.file.js @@ -1,14 +1,7 @@ // Import necessary modules // 导入必要的模块 -import { - $, - $id, - createElement, - on, - addClass, - removeClass -} from './util.dom.js'; import { deflate, inflate } from 'fflate'; +import { showFileUploadModal } from './util.fileUpload.js'; // File transfer state management // 文件传输状态管理 @@ -360,17 +353,14 @@ export function setupFileSend({ e.preventDefault(); e.stopPropagation(); - // Import and show upload modal - import('./util.fileUpload.js').then(({ showFileUploadModal }) => { - showFileUploadModal(async (files) => { - // 传递 userName 给 onSend - const userName = window.roomsData && window.activeRoomIndex >= 0 - ? (window.roomsData[window.activeRoomIndex]?.myUserName || '') - : ''; - await handleFilesUpload(files, (msg) => { - // 合并 userName 字段 - onSend({ ...msg, userName }); - }); + showFileUploadModal(async (files) => { + // 传递 userName 给 onSend + const userName = window.roomsData && window.activeRoomIndex >= 0 + ? (window.roomsData[window.activeRoomIndex]?.myUserName || '') + : ''; + await handleFilesUpload(files, (msg) => { + // 合并 userName 字段 + onSend({ ...msg, userName }); }); }); }); diff --git a/client/js/util.i18n.js b/client/js/util.i18n.js index 50c0885..c97b0cb 100644 --- a/client/js/util.i18n.js +++ b/client/js/util.i18n.js @@ -254,10 +254,18 @@ export function updateStaticTexts() { loginFormContainer.innerHTML = generateLoginForm(false); }); } - // Update sidebar username label + + // Update sidebar username label const sidebarUsername = document.getElementById('sidebar-username'); if (sidebarUsername) { - sidebarUsername.textContent = t('ui.my_name', 'My Name'); + import('./room.js').then(roomMod => { + const roomsData = roomMod.roomsData; + const activeRoomIndex = roomMod.activeRoomIndex; + const rd = roomsData && roomsData.length > 0 && activeRoomIndex >= 0 ? roomsData[activeRoomIndex] : null; + sidebarUsername.textContent = rd && rd.myUserName ? rd.myUserName : t('ui.my_name', 'My Name'); + }).catch(() => { + sidebarUsername.textContent = t('ui.my_name', 'My Name'); + }); } // Update "Enter a Node" text in sidebar const joinRoomText = document.getElementById('join-room-text'); diff --git a/vite.config.js b/vite.config.js index 58aa927..ff569f1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -50,9 +50,6 @@ export default defineConfig({ if (/aes-js|elliptic|js-chacha20|js-sha256/.test(id)) { return 'crypto-libs' } - if (id.includes('buffer')) { - return 'vendor' - } if (id.includes('emoji-picker-element')) { return 'emoji-libs' } diff --git a/wrangler.toml b/wrangler.toml index d48cf91..a738bdf 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,4 +1,4 @@ -name = "nodecrypt" +name = "nodecrypt-test" main = "worker/index.js" compatibility_date = "2024-09-23" compatibility_flags = ["nodejs_compat"]