fix: 修复渲染进程5个bug(path未定义、editorWrapper未定义、死代码清理)

This commit is contained in:
thzxx
2026-05-21 11:41:23 +08:00
parent 2010f9dff5
commit 5d64e4401f
2 changed files with 5 additions and 9 deletions
+1 -1
View File
@@ -199,7 +199,7 @@
</div> </div>
<div class="welcome-tips"> <div class="welcome-tips">
<p>💡 提示:可以直接拖拽 .md 文件到窗口打开</p> <p>💡 提示:可以直接拖拽 .md 文件到窗口打开</p>
<p>⌨️ 快捷键:Ctrl+O 打开 | Ctrl+S 保存 | Ctrl+1/2/3 切换视图 | Ctrl+T 新建标签</p> <p>⌨️ 快捷键:Ctrl+O 打开 | Ctrl+S 保存 | Ctrl+F 搜索 | Ctrl+H 替换 | Ctrl+1/2/3 视图 | Ctrl+T 标签</p>
</div> </div>
</div> </div>
</div> </div>
+4 -8
View File
@@ -1180,8 +1180,9 @@
const overlay = document.createElement('div'); const overlay = document.createElement('div');
overlay.id = 'search-highlights'; overlay.id = 'search-highlights';
overlay.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;overflow:hidden;z-index:1;'; overlay.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;overflow:hidden;z-index:1;';
editorWrapper.style.position = 'relative'; const wrapper = document.getElementById('editor-wrapper');
editorWrapper.appendChild(overlay); wrapper.style.position = 'relative';
wrapper.appendChild(overlay);
for (let i = 0; i < searchMatches.length; i++) { for (let i = 0; i < searchMatches.length; i++) {
const m = searchMatches[i]; const m = searchMatches[i];
@@ -1270,7 +1271,6 @@
async function openFolder() { async function openFolder() {
if (typeof window.electronAPI === 'undefined') return; if (typeof window.electronAPI === 'undefined') return;
const { dialog } = require('electron');
openFolderDialog(); openFolderDialog();
} }
@@ -1308,17 +1308,13 @@
function renderTree(tree, rootPath) { function renderTree(tree, rootPath) {
sidebarTree.innerHTML = ''; sidebarTree.innerHTML = '';
const rootNode = { name: path.basename(rootPath) || rootPath, path: rootPath, type: 'dir', children: tree }; const rootNode = { name: getFileName(rootPath) || rootPath, path: rootPath, type: 'dir', children: tree };
expandedDirs.add(rootPath); expandedDirs.add(rootPath);
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
buildTreeDOM(fragment, rootNode, 0); buildTreeDOM(fragment, rootNode, 0);
sidebarTree.appendChild(fragment); sidebarTree.appendChild(fragment);
} }
function pathBasename(p) {
return p.split(/[/\\]/).pop();
}
function buildTreeDOM(parent, node, depth) { function buildTreeDOM(parent, node, depth) {
const item = document.createElement('div'); const item = document.createElement('div');
item.className = 'tree-item'; item.className = 'tree-item';