Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Align mobile outline expansion controls and require mobile parity https://github.com/siyuan-note/siyuan/issues/19729

Vanessa0bef8ceb160f
diff --git a/AGENTS.md b/AGENTS.md
index 7f61cd550d..dc115cabb7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -99,6 +99,10 @@ SiYuan repository guide. Module path `github.com/siyuan-note/siyuan`, license AG
- After contract changes, run `pnpm run api:generate --petal ../../petal` and `pnpm run api:check --petal ../../petal` from `app/`; synchronize related public declarations in `petal` and do not hand-edit generated declarations or schemas
- Run `pnpm run lint` from `app/`, `go test ./apicontract/...` from `kernel/`, and the applicable API compatibility and route coverage tests described in the maintenance document. Verify that existing CI selections and documented commands discover new regression cases; automatic discovery or coverage by an existing full-suite command satisfies this requirement without a documentation edit. Update CI selections and documented commands only when they would otherwise miss the new tests. Report task-specific verification commands and results in the task response or PR description
+11. **Desktop and mobile parity:**
+ - When changing functionality shared by desktop and mobile, inspect the corresponding mobile implementation under `app/src/mobile/` and update it in the same task. This includes menus, toolbars, dialogs, interactions, and their event handlers; do not assume that desktop changes automatically apply to mobile
+ - Before finishing, verify both implementations and their shared dependencies, preserving platform-appropriate interactions. If no corresponding mobile feature exists or the change is desktop-only, state why mobile changes are not needed in the task response
+
---
## 3. Coding conventions
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index 53b638ff28..0b97e9f9d7 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -73,9 +73,7 @@ export class MobileOutline extends Model {
<input spellcheck="false" class="b3-text-field search__label fn__none fn__size200" placeholder="${window.siyuan.languages.searchPlaceholder}" />
<svg data-type="search" class="toolbar__icon"><use xlink:href='#iconSearch'></use></svg>
<svg data-type="keepCurrentExpand" class="toolbar__icon${window.siyuan.storage[Constants.LOCAL_OUTLINE].keepCurrentExpand ? " toolbar__icon--active" : ""}"><use xlink:href="#iconFocus"></use></svg>
- <svg data-type="expandLevel" class="toolbar__icon"><use xlink:href="#iconList"></use></svg>
- <svg data-type="expand" class="toolbar__icon"><use xlink:href="#iconExpand"></use></svg>
- <svg data-type="collapse" class="toolbar__icon"><use xlink:href="#iconContract"></use></svg>
+ <svg data-type="expandLevel" class="toolbar__icon"><use xlink:href="#iconExpandLevel"></use></svg>
</div>
<div class="b3-list-item fn__none" data-type="doc-title"></div>
<div class="fn__flex-1" style="padding: 3px 0 calc(8px + env(safe-area-inset-bottom))"></div>`;
@@ -134,18 +132,6 @@ export class MobileOutline extends Model {
blockExtHTML: window.siyuan.config.readonly ? undefined : '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>',
topExtHTML: window.siyuan.config.readonly ? undefined : '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>',
});
- // 为了快捷键的 dispatch
- this.element.querySelector('[data-type="collapse"]').addEventListener("click", () => {
- this.tree.collapseAll();
- this.saveExpendIds();
- });
-
- // 普通的全部展开按钮
- this.element.querySelector('[data-type="expand"]').addEventListener("click", () => {
- this.tree.expandAll();
- this.saveExpendIds();
- });
-
// 保持当前标题展开功能
this.element.querySelector('[data-type="keepCurrentExpand"]').addEventListener("click", (event: MouseEvent & {
target: Element
@@ -772,6 +758,15 @@ export class MobileOutline extends Model {
setStorageVal(Constants.LOCAL_OUTLINE, window.siyuan.storage[Constants.LOCAL_OUTLINE]);
}
+ private setAllExpanded(expanded: boolean) {
+ if (expanded) {
+ this.tree.expandAll();
+ } else {
+ this.tree.collapseAll();
+ }
+ this.saveExpendIds();
+ }
+
/**
* 显示展开层级菜单
*/
@@ -787,6 +782,19 @@ export class MobileOutline extends Model {
click: () => this.expandToLevel(i)
}).element);
}
+ window.siyuan.menus.menu.append(new MenuItem({id: "separator_all", type: "separator"}).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "expandAll",
+ icon: "iconExpand",
+ label: window.siyuan.languages.expandAll,
+ click: () => this.setAllExpanded(true)
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "foldAll",
+ icon: "iconContract",
+ label: window.siyuan.languages.foldAll,
+ click: () => this.setAllExpanded(false)
+ }).element);
window.siyuan.menus.menu.fullscreen("bottom");
return window.siyuan.menus.menu;
}
@@ -1267,10 +1275,7 @@ export class MobileOutline extends Model {
id: "expandAll",
icon: "iconExpand",
label: window.siyuan.languages.expandAll,
- click: () => {
- this.tree.expandAll();
- this.saveExpendIds();
- }
+ click: () => this.setAllExpanded(true)
}).element);
// 全部折叠
@@ -1278,10 +1283,7 @@ export class MobileOutline extends Model {
id: "foldAll",
icon: "iconContract",
label: window.siyuan.languages.foldAll,
- click: () => {
- this.tree.collapseAll();
- this.saveExpendIds();
- }
+ click: () => this.setAllExpanded(false)
}).element);
window.siyuan.menus.menu.fullscreen("bottom");