Improve local filetree view state and sidebar performance

This commit is contained in:
lix-2026
2026-05-27 11:31:12 +08:00
parent 58e2fdb5d8
commit 3ae33cc21d
56 changed files with 8614 additions and 461 deletions
@@ -850,22 +850,17 @@ async function main() {
await hideTitleCheckbox.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
const hideTitleCheckedBefore = await hideTitleCheckbox.isChecked();
assert.equal(hideTitleCheckedBefore, false, "托管工作区(我的空间)默认不隐藏文件标题");
await hideTitleCheckbox.setChecked(true, { timeout: UI_TIMEOUT_MS });
const optionsPath = path.join(root, ".mnote", "page-options.json");
const optionsHidden = await waitForFileContent(
optionsPath,
(content) => {
try {
const payload = JSON.parse(content);
return payload?.pages?.["local-md:MyNotes.md"]?.hideTitleHeader === true;
} catch {
return false;
}
await hideTitleCheckbox.setChecked(true, { timeout: UI_TIMEOUT_MS });
await page.waitForFunction(
() => {
const header = document.querySelector('.document-pane[data-pane-role="primary"] .document-shell-header');
return header instanceof HTMLElement ? header.hidden || header.getAttribute("data-page-title-hidden") === "true" : false;
},
UI_TIMEOUT_MS,
null,
{ timeout: UI_TIMEOUT_MS },
);
assert(optionsHidden.ok, `隐藏标题应持久化 hideTitleHeader=true,实际: ${optionsHidden.content}`);
await page.waitForTimeout(500);
assert(!fs.existsSync(optionsPath), "隐藏标题不应继续写入 .mnote/page-options.json");
const titleHeaderHiddenAfterCheck = await page.evaluate(() => {
const header = document.querySelector('.document-pane[data-pane-role="primary"] .document-shell-header');
return header instanceof HTMLElement ? header.hidden || header.getAttribute("data-page-title-hidden") === "true" : false;
@@ -873,20 +868,15 @@ async function main() {
assert(titleHeaderHiddenAfterCheck, "勾选隐藏标题后标题应隐藏");
await hideTitleCheckbox.setChecked(false, { timeout: UI_TIMEOUT_MS });
const optionsShown = await waitForFileContent(
optionsPath,
(content) => {
try {
const payload = JSON.parse(content);
return payload?.pages?.["local-md:MyNotes.md"]?.hideTitleHeader === false;
} catch {
return false;
}
await page.waitForFunction(
() => {
const header = document.querySelector('.document-pane[data-pane-role="primary"] .document-shell-header');
return header instanceof HTMLElement ? !header.hidden && header.getAttribute("data-page-title-hidden") === "false" : false;
},
UI_TIMEOUT_MS,
null,
{ timeout: UI_TIMEOUT_MS },
);
assert(optionsShown.ok, `显示标题应持久化 hideTitleHeader=false,实际: ${optionsShown.content}`);
await page.waitForTimeout(500);
assert(!fs.existsSync(optionsPath), "显示标题不应继续写入 .mnote/page-options.json");
const titleHeaderVisibleAfterToggle = await page.evaluate(() => {
const header = document.querySelector('.document-pane[data-pane-role="primary"] .document-shell-header');
return header instanceof HTMLElement ? !header.hidden && header.getAttribute("data-page-title-hidden") === "false" : false;