修复:close超时保护、移除冗余变量、优化文件大小计算、去重formatBytes
This commit is contained in:
+8
-12
@@ -140,13 +140,15 @@
|
||||
}
|
||||
|
||||
// ===== File Size =====
|
||||
function formatBytes(bytes) {
|
||||
if (bytes < 1024) return bytes + ' B';
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
|
||||
function updateFileSize() {
|
||||
const bytes = new TextEncoder().encode(editor.value).length;
|
||||
let display;
|
||||
if (bytes < 1024) display = bytes + ' B';
|
||||
else if (bytes < 1024 * 1024) display = (bytes / 1024).toFixed(1) + ' KB';
|
||||
else display = (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
statusSize.textContent = display;
|
||||
const bytes = new Blob([editor.value]).size;
|
||||
statusSize.textContent = formatBytes(bytes);
|
||||
statusSizeDivider.classList.add('visible');
|
||||
}
|
||||
|
||||
@@ -215,12 +217,6 @@
|
||||
return filePath.split(/[/\\]/).pop();
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
if (bytes < 1024) return bytes + ' B';
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
|
||||
async function updateFileStats(filePath) {
|
||||
if (typeof window.electronAPI !== 'undefined' && filePath) {
|
||||
const stats = await window.electronAPI.getFileStats(filePath);
|
||||
|
||||
Reference in New Issue
Block a user