删除没用到的函数
This commit is contained in:
1 parent
c7713f6f8f
commit
448fbd8fd0
8 files changed
+22
-147
No files matched your search
+11
-11
@@ -1,55 +1,55 @@
|
||||
{
|
||||
"hash": "e45b025a",
|
||||
"configHash": "a9175a6e",
|
||||
"hash": "d8cb72aa",
|
||||
"configHash": "b819ff65",
|
||||
"lockfileHash": "d2c17a4e",
|
||||
"browserHash": "39b69c3e",
|
||||
"browserHash": "33fd6e15",
|
||||
"optimized": {
|
||||
"buffer": {
|
||||
"src": "../../buffer/index.js",
|
||||
"file": "buffer.js",
|
||||
"fileHash": "e9bd2ee5",
|
||||
"fileHash": "f0067afa",
|
||||
"needsInterop": true
|
||||
},
|
||||
"aes-js": {
|
||||
"src": "../../aes-js/index.js",
|
||||
"file": "aes-js.js",
|
||||
"fileHash": "1f9ff061",
|
||||
"fileHash": "fb1e814f",
|
||||
"needsInterop": true
|
||||
},
|
||||
"elliptic": {
|
||||
"src": "../../elliptic/lib/elliptic.js",
|
||||
"file": "elliptic.js",
|
||||
"fileHash": "de12123b",
|
||||
"fileHash": "e6f3097a",
|
||||
"needsInterop": true
|
||||
},
|
||||
"js-chacha20": {
|
||||
"src": "../../js-chacha20/src/jschacha20.js",
|
||||
"file": "js-chacha20.js",
|
||||
"fileHash": "a75640d2",
|
||||
"fileHash": "f64b73af",
|
||||
"needsInterop": true
|
||||
},
|
||||
"js-sha256": {
|
||||
"src": "../../js-sha256/src/sha256.js",
|
||||
"file": "js-sha256.js",
|
||||
"fileHash": "4457a116",
|
||||
"fileHash": "b63767ec",
|
||||
"needsInterop": true
|
||||
},
|
||||
"@dicebear/core": {
|
||||
"src": "../../@dicebear/core/lib/index.js",
|
||||
"file": "@dicebear_core.js",
|
||||
"fileHash": "9bc7a118",
|
||||
"fileHash": "be1c1004",
|
||||
"needsInterop": false
|
||||
},
|
||||
"@dicebear/micah": {
|
||||
"src": "../../@dicebear/micah/lib/index.js",
|
||||
"file": "@dicebear_micah.js",
|
||||
"fileHash": "794ecb3f",
|
||||
"fileHash": "ebe1cbe3",
|
||||
"needsInterop": false
|
||||
},
|
||||
"emoji-picker-element": {
|
||||
"src": "../../emoji-picker-element/index.js",
|
||||
"file": "emoji-picker-element.js",
|
||||
"fileHash": "03506a03",
|
||||
"fileHash": "ee1ce99e",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
|
||||
+1
-11
@@ -2,7 +2,7 @@
|
||||
import { createAvatarSVG } from './util.avatar.js';
|
||||
import { roomsData, activeRoomIndex } from './room.js';
|
||||
import { escapeHTML, textToHTML } from './util.string.js';
|
||||
import { $, $$, $id, createElement, on, off, addClass, removeClass } from './util.dom.js';
|
||||
import { $, $id, createElement, on, addClass, removeClass } from './util.dom.js';
|
||||
|
||||
/**
|
||||
* 渲染当前房间消息区
|
||||
@@ -169,16 +169,6 @@ export function addSystemMsg(text, isHistory = false, timestamp = null) {
|
||||
chatArea.scrollTop = chatArea.scrollHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空聊天区域
|
||||
*/
|
||||
export function clearChat() {
|
||||
const chatArea = document.getElementById("chat-area");
|
||||
if (chatArea) {
|
||||
chatArea.innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新聊天输入框样式
|
||||
*/
|
||||
|
||||
+7
-54
@@ -5,42 +5,16 @@
|
||||
|
||||
// 先导入加密库依赖模块
|
||||
import './NodeCrypt.js';
|
||||
|
||||
// === 工具模块导入 ===
|
||||
import { processImage, setupImageSend } from './util.image.js';
|
||||
import { setupImageSend } from './util.image.js';
|
||||
import { setupEmojiPicker } from './util.emoji.js';
|
||||
import { openSettingsPanel, closeSettingsPanel, initSettings, notifyMessage } from './util.settings.js';
|
||||
import { escapeHTML, textToHTML } from './util.string.js';
|
||||
import { $, $$, $id, on, off, addClass, removeClass } from './util.dom.js';
|
||||
|
||||
import { $, $id, removeClass } from './util.dom.js';
|
||||
// === 核心功能模块导入 ===
|
||||
import {
|
||||
roomsData,
|
||||
activeRoomIndex,
|
||||
getNewRoomData,
|
||||
joinRoom,
|
||||
togglePrivateChat,
|
||||
setStatus
|
||||
} from './room.js';
|
||||
import {
|
||||
renderChatArea,
|
||||
addMsg,
|
||||
addSystemMsg,
|
||||
setupImagePreview,
|
||||
updateChatInputStyle,
|
||||
setupInputPlaceholder
|
||||
} from './chat.js';
|
||||
import { roomsData, activeRoomIndex, joinRoom } from './room.js';
|
||||
import { addMsg, addSystemMsg, setupImagePreview, setupInputPlaceholder } from './chat.js';
|
||||
// === 界面相关模块导入 ===
|
||||
import {
|
||||
renderUserList,
|
||||
renderMainHeader,
|
||||
setupMoreBtnMenu,
|
||||
preventSpaceInput,
|
||||
loginFormHandler,
|
||||
openLoginModal,
|
||||
setupTabs,
|
||||
autofillRoomPwd
|
||||
} from './ui.js';
|
||||
import { renderUserList, renderMainHeader, setupMoreBtnMenu, preventSpaceInput, loginFormHandler, openLoginModal, setupTabs, autofillRoomPwd } from './ui.js';
|
||||
|
||||
// === 全局配置 ===
|
||||
|
||||
@@ -50,8 +24,8 @@ import {
|
||||
* debug: 是否开启调试模式
|
||||
*/
|
||||
window.config = {
|
||||
//wsAddress: 'ws://127.0.0.1:8088',
|
||||
wsAddress: '/ws',
|
||||
wsAddress: 'wss://crypt.works/ws',
|
||||
//wsAddress: '/ws',
|
||||
debug: true
|
||||
};
|
||||
|
||||
@@ -222,24 +196,3 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// === 辅助函数 ===
|
||||
|
||||
/**
|
||||
* 清空消息区域
|
||||
* 用于UI重置或切换房间
|
||||
*/
|
||||
function clearChat() {
|
||||
$id("chat-area").innerHTML = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Telegram风格输入框自动增高
|
||||
* 随着用户输入内容增加,输入框自动调整高度
|
||||
*/
|
||||
function autoGrowInput() {
|
||||
const input = $('.input-message-input');
|
||||
if (!input) return;
|
||||
input.style.height = 'auto';
|
||||
input.style.height = input.scrollHeight + 'px';
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { roomsData, activeRoomIndex, togglePrivateChat, exitRoom } from './room.
|
||||
*/
|
||||
// 导入工具库
|
||||
import { escapeHTML } from './util.string.js';
|
||||
import { $, $$, $id, createElement, on, off, addClass, removeClass, toggleClass } from './util.dom.js';
|
||||
import { $id } from './util.dom.js';
|
||||
|
||||
/**
|
||||
* 渲染主面板房间头部
|
||||
|
||||
+1
-11
@@ -59,17 +59,7 @@ export function createElement(tag, attrs = {}, content = '') {
|
||||
} else if (content instanceof Element) {
|
||||
el.appendChild(content);
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置元素样式
|
||||
* @param {Element} el - 目标元素
|
||||
* @param {Object} styles - 样式对象
|
||||
*/
|
||||
export function setStyles(el, styles) {
|
||||
Object.assign(el.style, styles);
|
||||
return el;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// util.emoji.js
|
||||
// 使用emoji-picker-element库的表情选择器模块 (NPM模式)
|
||||
import { $, $$, createElement, on } from './util.dom.js';
|
||||
import { $, on } from './util.dom.js';
|
||||
import 'emoji-picker-element';
|
||||
|
||||
// 添加emoji-picker元素的默认样式
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import { $, on, createElement } from './util.dom.js';
|
||||
|
||||
export async function processImage(file, callback) {
|
||||
// 检查webp支持
|
||||
let webpSupported = await checkWebpSupport();
|
||||
const img = new Image();
|
||||
img.onload = function() {
|
||||
// 限制最大宽高
|
||||
@@ -30,19 +28,6 @@ export async function processImage(file, callback) {
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
function checkWebpSupport() {
|
||||
return new Promise(resolve => {
|
||||
const img = new window.Image();
|
||||
img.onload = function() {
|
||||
resolve(img.width === 1);
|
||||
};
|
||||
img.onerror = function() {
|
||||
resolve(false);
|
||||
};
|
||||
img.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4TAYAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
|
||||
});
|
||||
}
|
||||
|
||||
// 国际化提示已移除,默认英文提示
|
||||
function t(key) {
|
||||
const messages = {
|
||||
|
||||
@@ -23,47 +23,4 @@ export function textToHTML(text) {
|
||||
return escapeHTML(text).replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* 截断长文本并添加省略号
|
||||
* @param {string} text - 输入文本
|
||||
* @param {number} [maxLength=100] - 最大长度
|
||||
* @returns {string} 截断后的文本
|
||||
*/
|
||||
export function truncate(text, maxLength = 100) {
|
||||
if (!text || text.length <= maxLength) return text;
|
||||
return text.substring(0, maxLength) + '...';
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机字符串
|
||||
* @param {number} [length=8] - 字符串长度
|
||||
* @param {string} [chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'] - 字符集
|
||||
* @returns {string} 随机字符串
|
||||
*/
|
||||
export function randomString(length = 8, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
|
||||
let result = '';
|
||||
const charsLength = chars.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * charsLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期时间
|
||||
* @param {Date|number} [date=new Date()] - 日期对象或时间戳
|
||||
* @param {string} [format='YYYY-MM-DD HH:mm:ss'] - 格式化模板
|
||||
* @returns {string} 格式化后的日期时间
|
||||
*/
|
||||
export function formatDate(date = new Date(), format = 'YYYY-MM-DD HH:mm:ss') {
|
||||
const d = date instanceof Date ? date : new Date(date);
|
||||
const pad = (num) => String(num).padStart(2, '0');
|
||||
|
||||
return format
|
||||
.replace(/YYYY/g, d.getFullYear())
|
||||
.replace(/MM/g, pad(d.getMonth() + 1))
|
||||
.replace(/DD/g, pad(d.getDate()))
|
||||
.replace(/HH/g, pad(d.getHours()))
|
||||
.replace(/mm/g, pad(d.getMinutes()))
|
||||
.replace(/ss/g, pad(d.getSeconds()));
|
||||
}
|
||||
Reference in new issue
Block a user