An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Preserve mobile top bar controls during landscape startup https://github.com/siyuan-note/siyuan/issues/18985
Daniel09dbae73a0be
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.tsindex 8402bbb6e9..dc5da5c2e8 100644--- a/app/src/dialog/processSystem.ts+++ b/app/src/dialog/processSystem.ts@@ -423,22 +423,22 @@ export const processSync = (data?: IWebSocketData) => {return;}menuSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");- barSyncUseElement.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");+ barSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");return;}- menuSyncUseElement?.parentElement.classList.remove("fn__rotate");- barSyncUseElement.parentElement.classList.remove("fn__rotate");+ menuSyncUseElement?.parentElement?.classList.remove("fn__rotate");+ barSyncUseElement?.parentElement?.classList.remove("fn__rotate");if (data.code === 0) { // syncing- menuSyncUseElement?.parentElement.classList.add("fn__rotate");- barSyncUseElement.parentElement.classList.add("fn__rotate");+ menuSyncUseElement?.parentElement?.classList.add("fn__rotate");+ barSyncUseElement?.parentElement?.classList.add("fn__rotate");menuSyncUseElement?.setAttribute("xlink:href", "#iconRefresh");- barSyncUseElement.setAttribute("xlink:href", "#iconRefresh");+ barSyncUseElement?.setAttribute("xlink:href", "#iconRefresh");} else if (data.code === 2) { // errormenuSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudError");- barSyncUseElement.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudError");+ barSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudError");} else if (data.code === 1) { // successmenuSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");- barSyncUseElement.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");+ barSyncUseElement?.setAttribute("xlink:href", syncDisabled ? "#iconCloudOff" : "#iconCloudSucc");}/// #elseconst iconElement = document.querySelector("#barSync");diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex 7578fd2781..d0d45caf36 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -18,6 +18,7 @@ import {isEncryptedBox} from "../util/pathName";import {bindMobileBarsScroll, pauseMobileBarsScroll} from "./util/mobileBars";import {forEachPluginSubscriber} from "../plugin/EventBusCore";import {logMobileInputEvent} from "./util/inputEventLogger";+import {restoreMobileTopBarLayout, updateMobileTopBarLayout} from "./util/mobileTopBar";export const getCurrentEditor = () => {return window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;@@ -75,6 +76,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[return;}completed = true;+ updateMobileTopBarLayout();logMobileInputEvent("document-load-complete", undefined, logDetails);bindMobileBarsScroll(protyle.contentElement);afterOpen?.(protyle);@@ -287,6 +289,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[}} else {try {+ restoreMobileTopBarLayout();window.siyuan.mobile.editor = new Protyle(app, document.getElementById("editor"), protyleOptions);} catch (error) {console.error(error);diff --git a/app/src/mobile/util/mobileTopBar.test.ts b/app/src/mobile/util/mobileTopBar.test.tsindex 647bf6c9b7..a5e1cbbf18 100644--- a/app/src/mobile/util/mobileTopBar.test.ts+++ b/app/src/mobile/util/mobileTopBar.test.ts@@ -1,6 +1,6 @@import {describe, it} from "node:test";import * as assert from "node:assert/strict";-import {updateMobileTopBarLayout} from "./mobileTopBar";+import {restoreMobileTopBarLayout, updateMobileTopBarLayout} from "./mobileTopBar";class TestClassList {private classes = new Set<string>();@@ -91,10 +91,22 @@ describe("mobile top bar layout", () => {assert.equal(breadcrumbSpace.classList.contains("protyle-breadcrumb__space--mobile-title"), true);assert.deepEqual(breadcrumbSpace.children, [toolbarName, toolbarNameReadonly, toolbarSync]);+ restoreMobileTopBarLayout();+ assert.equal(bodyElement.classList.contains("mobile-topbar--merged"), false);+ assert.equal(breadcrumbSpace.classList.contains("protyle-breadcrumb__space--mobile-title"), false);+ assert.deepEqual(topBarElement.children, [toolbarName, toolbarNameReadonly, toolbarSync]);++ const replacementBreadcrumbSpace = new TestElement();+ editorElement.breadcrumbSpace = replacementBreadcrumbSpace;+ updateMobileTopBarLayout();+ assert.equal(bodyElement.classList.contains("mobile-topbar--merged"), true);+ assert.equal(replacementBreadcrumbSpace.classList.contains("protyle-breadcrumb__space--mobile-title"), true);+ assert.deepEqual(replacementBreadcrumbSpace.children, [toolbarName, toolbarNameReadonly, toolbarSync]);+landscape = false;updateMobileTopBarLayout();assert.equal(bodyElement.classList.contains("mobile-topbar--merged"), false);- assert.equal(breadcrumbSpace.classList.contains("protyle-breadcrumb__space--mobile-title"), false);+ assert.equal(replacementBreadcrumbSpace.classList.contains("protyle-breadcrumb__space--mobile-title"), false);assert.deepEqual(topBarElement.children, [toolbarName, toolbarNameReadonly, toolbarSync]);landscape = true;diff --git a/app/src/mobile/util/mobileTopBar.ts b/app/src/mobile/util/mobileTopBar.tsindex 182e76750f..e863c28316 100644--- a/app/src/mobile/util/mobileTopBar.ts+++ b/app/src/mobile/util/mobileTopBar.ts@@ -12,6 +12,23 @@ const getTopBarElements = () => {return topBarElements;};+export const restoreMobileTopBarLayout = () => {+ const topBarElement = document.getElementById("mobileTopBar");+ if (!topBarElement) {+ return;+ }+ if (mergedBreadcrumbSpace) {+ mergedBreadcrumbSpace.classList.remove("protyle-breadcrumb__space--mobile-title");+ mergedBreadcrumbSpace = undefined;+ }+ getTopBarElements().forEach((element) => {+ if (element.parentElement !== topBarElement) {+ topBarElement.appendChild(element);+ }+ });+ document.body.classList.remove("mobile-topbar--merged");+};+export const updateMobileTopBarLayout = () => {const topBarElement = document.getElementById("mobileTopBar");const editorElement = document.getElementById("editor");