An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve the mobile bottom bar https://github.com/siyuan-note/siyuan/issues/14542
Daniel859d94994783
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex b4af529a6e..203d79c6c7 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "الشريط السفلي","insertSuperBlockLeft": "إدراج عمود إلى اليسار","insertSuperBlockRight": "إدراج عمود إلى اليمين","assetOpen": "فتح الموارد",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 7aa901a4be..4f54bc4d07 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Untere Leiste","insertSuperBlockLeft": "Spalte links einfügen","insertSuperBlockRight": "Spalte rechts einfügen","assetOpen": "Ressourcen öffnen",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex ae01d4bf0b..ba0dfbd49d 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Bottom bar","insertSuperBlockLeft": "Insert column to the left","insertSuperBlockRight": "Insert column to the right","assetOpen": "Resource opening",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 44af3ff6f5..c1606ce589 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Barra inferior","insertSuperBlockLeft": "Insertar columna a la izquierda","insertSuperBlockRight": "Insertar columna a la derecha","assetOpen": "Apertura de recursos",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 14a265461f..61b1bce709 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Barre inférieure","insertSuperBlockLeft": "Insérer une colonne à gauche","insertSuperBlockRight": "Insérer une colonne à droite","assetOpen": "Ouverture des ressources",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex ae376291d7..77f1c1cd26 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "סרגל תחתון","insertSuperBlockLeft": "הוספת עמודה משמאל","insertSuperBlockRight": "הוספת עמודה מימין","assetOpen": "פתיחת משאבים",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 6d3b2a7108..da29649d2d 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "निचली पट्टी","insertSuperBlockLeft": "बाईं ओर कॉलम डालें","insertSuperBlockRight": "दाईं ओर कॉलम डालें","assetOpen": "संसाधन खोलना",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 1594ffa229..f763091eaa 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Bilah bawah","insertSuperBlockLeft": "Sisipkan kolom di sebelah kiri","insertSuperBlockRight": "Sisipkan kolom di sebelah kanan","assetOpen": "Pembukaan sumber daya",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 0e0b8b6f5e..fda3a4c77b 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Barra inferiore","insertSuperBlockLeft": "Inserisci colonna a sinistra","insertSuperBlockRight": "Inserisci colonna a destra","assetOpen": "Apertura delle risorse",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex c78f4ae919..c52a7e84d7 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "下部バー","insertSuperBlockLeft": "左側に列を挿入","insertSuperBlockRight": "右側に列を挿入","assetOpen": "リソースの開き方",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 995b61ab5d..0b921d8fa4 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "하단 바","insertSuperBlockLeft": "왼쪽에 열 삽입","insertSuperBlockRight": "오른쪽에 열 삽입","assetOpen": "리소스 열기",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 3c37e36a6b..9d28b13b39 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Onderste balk","insertSuperBlockLeft": "Kolom links invoegen","insertSuperBlockRight": "Kolom rechts invoegen","assetOpen": "Bronnen openen",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 71ec3b21c4..ca2f82ca2b 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Dolny pasek","insertSuperBlockLeft": "Wstaw kolumnę po lewej","insertSuperBlockRight": "Wstaw kolumnę po prawej","assetOpen": "Otwieranie zasobów",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 28cabe127e..c7bb656144 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Barra inferior","insertSuperBlockLeft": "Inserir coluna à esquerda","insertSuperBlockRight": "Inserir coluna à direita","assetOpen": "Abertura de recursos",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 8fba2829c4..9b034ed863 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Нижняя панель","insertSuperBlockLeft": "Вставить столбец слева","insertSuperBlockRight": "Вставить столбец справа","assetOpen": "Открытие ресурсов",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex 1a44667e14..547dd9ecf3 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Spodná lišta","insertSuperBlockLeft": "Vložiť stĺpec vľavo","insertSuperBlockRight": "Vložiť stĺpec vpravo","assetOpen": "Otváranie zdrojov",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 08019bea50..21a739918c 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "แถบด้านล่าง","insertSuperBlockLeft": "แทรกคอลัมน์ทางซ้าย","insertSuperBlockRight": "แทรกคอลัมน์ทางขวา","assetOpen": "การเปิดทรัพยากร",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex f177c01583..99349751ed 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Alt çubuk","insertSuperBlockLeft": "Sola sütun ekle","insertSuperBlockRight": "Sağa sütun ekle","assetOpen": "Kaynakları açma",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex ebb42aea3d..3133d12888 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "Нижня панель","insertSuperBlockLeft": "Вставити стовпець ліворуч","insertSuperBlockRight": "Вставити стовпець праворуч","assetOpen": "Відкриття ресурсів",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 4e3a80e35d..8df13af450 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "底栏","insertSuperBlockLeft": "左侧插入分栏","insertSuperBlockRight": "右侧插入分栏","assetOpen": "资源打开方式",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex 1fe2ffd612..df2a531a8a 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,5 @@{+ "mobileBottomBar": "底欄","insertSuperBlockLeft": "左側插入分欄","insertSuperBlockRight": "右側插入分欄","assetOpen": "資源開啟方式",diff --git a/app/src/assets/scss/business/_ai_editor.scss b/app/src/assets/scss/business/_ai_editor.scssindex 417bb60bf5..c484b609dd 100644--- a/app/src/assets/scss/business/_ai_editor.scss+++ b/app/src/assets/scss/business/_ai_editor.scss@@ -73,7 +73,7 @@&--mobile {top: auto !important;right: max(8px, env(safe-area-inset-right));- bottom: max(8px, env(safe-area-inset-bottom));+ bottom: calc(var(--mobile-bottom-bar-offset, env(safe-area-inset-bottom)) + 8px);left: max(8px, env(safe-area-inset-left)) !important;width: auto;max-height: 55%;diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scssindex 2b5ea8fa18..d8e2103cda 100644--- a/app/src/assets/scss/main/_mobile.scss+++ b/app/src/assets/scss/main/_mobile.scss@@ -2,6 +2,18 @@@use "../util/function";@use "../component/svg";+body {+ --mobile-bottom-bar-offset: calc(48px + env(safe-area-inset-bottom));+}++body.mobile-chrome--hidden {+ --mobile-bottom-bar-offset: env(safe-area-inset-bottom);+}++body.mobile-keyboard--open {+ --mobile-bottom-bar-offset: 0px;+}+.block__popover {width: 80vw;}@@ -147,6 +159,31 @@}}+ &__button {+ appearance: none;+ display: flex;+ align-items: center;+ justify-content: center;+ width: 48px;+ height: 48px;+ padding: 0;+ flex-shrink: 0;+ border: 0;+ border-radius: var(--b3-border-radius);+ color: var(--b3-theme-on-surface);+ background: transparent;++ svg {+ width: 20px;+ height: 20px;+ }++ &:active,+ &:focus-visible {+ background-color: var(--b3-list-hover);+ }+ }+&__title {flex: 1;box-shadow: none;@@ -219,6 +256,177 @@}}+.mobile-safe-area {+ height: env(safe-area-inset-top);+ flex-shrink: 0;+ background-color: var(--b3-theme-background);+}++.mobile-topbar {+ box-sizing: border-box;+ min-height: 48px;+ padding: 0 max(4px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));+ flex-shrink: 0;+ transition: margin-bottom 180ms cubic-bezier(.2, 0, 0, 1), opacity 180ms cubic-bezier(.2, 0, 0, 1), transform 180ms cubic-bezier(.2, 0, 0, 1), visibility 180ms;+}++.mobile-bottom-bar {+ position: fixed;+ right: 0;+ bottom: 0;+ left: 0;+ z-index: 3;+ box-sizing: border-box;+ display: flex;+ align-items: flex-start;+ height: calc(48px + env(safe-area-inset-bottom));+ padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));+ border-top: .5px solid var(--b3-theme-background-light);+ background-color: var(--b3-theme-background);+ transition: opacity 180ms cubic-bezier(.2, 0, 0, 1), transform 180ms cubic-bezier(.2, 0, 0, 1), visibility 180ms;+ -webkit-user-select: none;+ user-select: none;++ &__item {+ appearance: none;+ position: relative;+ display: flex;+ align-items: center;+ justify-content: center;+ flex: 1 1 0;+ flex-direction: column;+ gap: 0;+ min-width: 48px;+ height: 48px;+ padding: 2px;+ overflow: hidden;+ border: 0;+ border-radius: var(--b3-border-radius);+ color: var(--b3-theme-on-surface-light);+ background: transparent;++ > svg,+ .mobile-bottom-bar__icon-with-count > svg {+ width: 20px;+ height: 20px;+ flex-shrink: 0;+ }++ &:active,+ &:focus-visible {+ color: var(--b3-theme-on-surface);+ background-color: var(--b3-list-hover);+ }++ &[disabled] {+ opacity: .38;+ }++ }++ &__label {+ max-width: 100%;+ overflow: hidden;+ font-size: 10px;+ line-height: 11px;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ &__icon-with-count {+ position: relative;+ display: flex;+ }++ .toolbar__tabs-count {+ position: absolute;+ top: -5px;+ left: 14px;+ min-width: 13px;+ padding: 0 2px;+ border: 1px solid var(--b3-theme-background);+ border-radius: 8px;+ color: var(--b3-theme-on-primary);+ background-color: var(--b3-theme-primary);+ font-size: 9px;+ line-height: 13px;+ text-align: center;+ }+}++.mobile-chrome--hidden {+ .mobile-topbar {+ margin-bottom: -48px;+ opacity: 0;+ transform: translateY(-100%);+ visibility: hidden;+ }++ .mobile-bottom-bar {+ opacity: 0;+ pointer-events: none;+ transform: translateY(100%);+ visibility: hidden;+ }+}++.mobile-keyboard--open .mobile-bottom-bar {+ opacity: 0;+ pointer-events: none;+ transform: translateY(100%);+ visibility: hidden;+}++.mobile-bottom-bar-setting {+ display: block;++ > .fn__flex {+ align-items: center;+ }++ .b3-button {+ display: flex;+ align-items: center;+ gap: 6px;++ svg {+ width: 14px;+ height: 14px;+ }+ }++ &__slots {+ display: grid;+ gap: 8px;+ margin-top: 12px;+ }++ &__slot {+ display: flex;+ align-items: center;+ gap: 12px;+ min-height: 48px;++ > span {+ width: 20px;+ color: var(--b3-theme-on-surface-light);+ text-align: center;+ }+ }+}++#editor {+ box-sizing: border-box;+ padding-bottom: var(--mobile-bottom-bar-offset);+}++@media (prefers-reduced-motion: reduce) {+ .mobile-topbar,+ .mobile-bottom-bar {+ transition: none;+ }+}+.mobile-tabs {display: flex;flex-direction: column;@@ -932,6 +1140,8 @@flex-direction: column;align-items: center;justify-content: center;+ box-sizing: border-box;+ padding-bottom: var(--mobile-bottom-bar-offset);.b3-list-item {width: 200px;diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tplindex 186ba8e1c9..9ce5c67b41 100644--- a/app/src/assets/template/mobile/index.tpl+++ b/app/src/assets/template/mobile/index.tpl@@ -11,22 +11,13 @@<div class="b3-dialog__scrim" style="background-color: #1e1e1e"></div><img style="position: absolute;width: 24vh;" src="../../icon.svg"></div>-<div class="toolbar toolbar--border">- <svg id="toolbarFile" class="toolbar__icon">- <use xlink:href="#iconMenu"></use>- </svg>+<div class="mobile-safe-area"></div>+<div id="mobileTopBar" class="toolbar toolbar--border mobile-topbar"><input class="toolbar__title fn__hidden" id="toolbarName" autocomplete="off"><span class="toolbar__title toolbar__title--readonly fn__hidden fn__none" id="toolbarNameReadonly"></span>- <svg id="toolbarSync" class="toolbar__icon toolbar__icon-deactivate fn__none">- <use xlink:href="#iconCloudSucc"></use>- </svg>- <button id="toolbarTabs" class="toolbar__tabs" type="button">- <svg><use xlink:href="#iconLayoutGrid"></use></svg>- <span class="toolbar__tabs-count">0</span>+ <button id="toolbarSync" class="toolbar__button toolbar__icon-deactivate fn__none" type="button">+ <svg><use xlink:href="#iconCloudSucc"></use></svg></button>- <svg id="toolbarMore" class="toolbar__icon">- <use xlink:href="#iconSettings"></use>- </svg></div><div id="editor" class="fn__none fn__flex-1"></div><div id="empty" class="b3-list--mobile"></div>@@ -75,6 +66,51 @@<div id="message" class="b3-snackbars"></div><div id="tooltip" class="tooltip fn__none"></div><div id="status" class="status"></div>+<div id="mobileBottomBar" class="mobile-bottom-bar" role="group" aria-hidden="false" data-prevent-swipe>+ <button id="toolbarFile" class="mobile-bottom-bar__item" data-action="documents" type="button">+ <svg><use xlink:href="#iconFiles"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarSearch" class="mobile-bottom-bar__item" data-action="search" type="button">+ <svg><use xlink:href="#iconSearch"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarNewDoc" class="mobile-bottom-bar__item" data-action="newDoc" type="button">+ <svg><use xlink:href="#iconAddDoc"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="toolbarTabs" class="mobile-bottom-bar__item" data-action="tabs" type="button">+ <span class="mobile-bottom-bar__icon-with-count">+ <svg><use xlink:href="#iconLayoutGrid"></use></svg>+ <span class="toolbar__tabs-count">0</span>+ </span>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarRecent" class="mobile-bottom-bar__item fn__none" data-action="recent" type="button">+ <svg><use xlink:href="#iconList"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarOutline" class="mobile-bottom-bar__item fn__none" data-action="outline" type="button">+ <svg><use xlink:href="#iconOutline"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarBookmark" class="mobile-bottom-bar__item fn__none" data-action="bookmark" type="button">+ <svg><use xlink:href="#iconBookmark"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarTag" class="mobile-bottom-bar__item fn__none" data-action="tag" type="button">+ <svg><use xlink:href="#iconTag"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="mobileBottomBarCommand" class="mobile-bottom-bar__item fn__none" data-action="command" type="button">+ <svg><use xlink:href="#iconTerminal"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+ <button id="toolbarMore" class="mobile-bottom-bar__item" data-action="more" type="button">+ <svg><use xlink:href="#iconMore"></use></svg>+ <span class="mobile-bottom-bar__label"></span>+ </button>+</div><div id="keyboardToolbar" class="keyboard fn__none"></div><div class="side-mask fn__none"></div></body>diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.tsindex 0b5c2ef78e..15372b552d 100644--- a/app/src/config/tabs/appearanceTab.ts+++ b/app/src/config/tabs/appearanceTab.ts@@ -35,6 +35,9 @@ import {unregisterCustomFont} from "../../util/customFont";import {showMessage} from "../../dialog/message";+/// #if MOBILE+import {genMobileBottomBarSettingHTML, mountMobileBottomBarSetting} from "../../mobile/util/mobileBottomBar";+/// #endif/// #if !MOBILEimport {genEntryVisibilityHtml, mountEntryVisibility} from "../entryVisibility/ui";/// #endif@@ -597,6 +600,18 @@ const registerAppearanceInterfaceGroup = (tab: SettingTabBuilder) => {const registerAppearanceControlsGroup = (tab: SettingTabBuilder) => {const group = tab.group("controls", window.siyuan.languages.configGroupControls);+ /// #if MOBILE+ group.slot({+ key: "mobileBottomBar",+ keywords: [+ window.siyuan.languages.mobile,+ window.siyuan.languages.mobileBottomBar,+ window.siyuan.languages.reset,+ ],+ html: genMobileBottomBarSettingHTML,+ afterMount: mountMobileBottomBarSetting,+ });+ /// #endif/// #if !MOBILEgroup.slot({key: "entryVisibility",diff --git a/app/src/constants.ts b/app/src/constants.tsindex 4db6f8ebc4..d64b458df3 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -166,6 +166,7 @@ export abstract class Constants {public static readonly LOCAL_SEARCHUNREF = "local-searchunref";public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobilepublic static readonly LOCAL_MOBILE_TABS = "local-mobile-tabs"; // only mobile+ public static readonly LOCAL_MOBILE_BOTTOM_BAR = "local-mobile-bottom-bar"; // only mobilepublic static readonly LOCAL_DAILYNOTEID = "local-dailynoteid"; // stringpublic static readonly LOCAL_HISTORY = "local-history";public static readonly LOCAL_CODELANG = "local-codelang"; // stringdiff --git a/app/src/mobile/dock/util.ts b/app/src/mobile/dock/util.tsindex 2d517fbc13..939bde2a3e 100644--- a/app/src/mobile/dock/util.ts+++ b/app/src/mobile/dock/util.ts@@ -1,4 +1,7 @@+import {activeBlur} from "../util/keyboardToolbar";+export const openDock = (type: string) => {- document.getElementById("toolbarFile").dispatchEvent(new CustomEvent("click"));+ activeBlur();+ document.getElementById("sidebar").style.transform = "translateX(0px)";document.querySelector("#sidebar .toolbar--border").dispatchEvent(new CustomEvent("click", {detail:type}));};diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex e23a086807..8e8af2e241 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -15,6 +15,7 @@ import type {App} from "../index";import {initMirror} from "../protyle/undo/globalUndo";import {getDocByScroll, saveScroll} from "../protyle/scroll/saveScroll";import {isEncryptedBox} from "../util/pathName";+import {bindMobileBarsScroll, pauseMobileBarsScroll} from "./util/mobileBars";export const getCurrentEditor = () => {return window.siyuan.mobile.popEditor || window.siyuan.mobile.editor;@@ -66,6 +67,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[return;}completed = true;+ bindMobileBarsScroll(protyle.contentElement);afterOpen?.(protyle);};const fail = (invalid = false) => {@@ -117,6 +119,7 @@ export const loadMobileFileById = (app: App, id: string, action: TProtyleAction[updateRecentDocSwitchTime(createRecentDocUpdate(rootID, rootID));}complete(protyle);+ pauseMobileBarsScroll();return;}}diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.tsindex da8394ca52..61118ba41b 100644--- a/app/src/mobile/menu/index.ts+++ b/app/src/mobile/menu/index.ts@@ -22,6 +22,7 @@ import {openDataMigration} from "../../menus/dataMigration";import {normalizeSearchText} from "../../config/search/normalize";import type {SettingTabSearchResult} from "../../config/setting/builder";import {unmountBazaarTab} from "../../config/bazaarTab";+import {openDock} from "../dock/util";const getSettingTabFromMenuTarget = (target: HTMLElement): ISettingTabShell<TSettingTab> | undefined => {const item = target.closest(".b3-menu__item") as HTMLElement | null;@@ -228,6 +229,26 @@ export const initRightMenu = (app: App) => {<span class="b3-menu__label">${window.siyuan.languages.back}</span></div><div class="b3-menu__items b3-menu__groups">+ <div class="b3-menu__group">+ <div class="b3-menu__group-title">${window.siyuan.languages.mobileBottomBar}</div>+ <div class="b3-menu__group-items">+ <div id="menuDocuments" class="b3-menu__item">+ <svg class="b3-menu__icon"><use xlink:href="#iconFiles"></use></svg><span class="b3-menu__label">${window.siyuan.languages.fileTree}</span>+ </div>+ <div id="menuTabs" class="b3-menu__item">+ <svg class="b3-menu__icon"><use xlink:href="#iconLayoutGrid"></use></svg><span class="b3-menu__label">${window.siyuan.languages.mobileTabs}</span>+ </div>+ <div id="menuOutline" class="b3-menu__item">+ <svg class="b3-menu__icon"><use xlink:href="#iconOutline"></use></svg><span class="b3-menu__label">${window.siyuan.languages.outline}</span>+ </div>+ <div id="menuBookmark" class="b3-menu__item">+ <svg class="b3-menu__icon"><use xlink:href="#iconBookmark"></use></svg><span class="b3-menu__label">${window.siyuan.languages.bookmark}</span>+ </div>+ <div id="menuTag" class="b3-menu__item">+ <svg class="b3-menu__icon"><use xlink:href="#iconTag"></use></svg><span class="b3-menu__label">${window.siyuan.languages.tag}</span>+ </div>+ </div>+ </div><div class="b3-menu__group"><div class="b3-menu__group-title">${window.siyuan.languages.mobileMenuQuickActions}</div><div class="b3-menu__group-items">@@ -302,6 +323,9 @@ export const initRightMenu = (app: App) => {<div class="b3-menu__item" id="menuSettings"><svg class="b3-menu__icon"><use xlink:href="#iconSettings"></use></svg><span class="b3-menu__label">${window.siyuan.languages.config}</span></div>+ <div class="b3-menu__item" id="menuBottomBarConfig">+ <svg class="b3-menu__icon"><use xlink:href="#iconMenu"></use></svg><span class="b3-menu__label">${window.siyuan.languages.mobileBottomBar}</span>+ </div><div class="b3-menu__item${window.siyuan.config.readonly ? " fn__none" : ""}" id="menuHelp"><svg class="b3-menu__icon"><use xlink:href="#iconHelp"></use></svg><span class="b3-menu__label">${window.siyuan.languages.userGuide}</span></div>@@ -324,6 +348,24 @@ export const initRightMenu = (app: App) => {event.preventDefault();event.stopPropagation();break;+ } else if (target.id === "menuDocuments") {+ closePanel();+ openDock("file");+ event.preventDefault();+ event.stopPropagation();+ break;+ } else if (target.id === "menuTabs") {+ closePanel();+ document.getElementById("toolbarTabs").dispatchEvent(new CustomEvent("click"));+ event.preventDefault();+ event.stopPropagation();+ break;+ } else if (["menuOutline", "menuBookmark", "menuTag"].includes(target.id)) {+ closePanel();+ openDock(target.id.replace("menu", "").toLowerCase());+ event.preventDefault();+ event.stopPropagation();+ break;} else if (target.id === "menuRecent") {getRecentDocs(app);event.preventDefault();@@ -406,6 +448,14 @@ export const initRightMenu = (app: App) => {event.preventDefault();event.stopPropagation();break;+ } else if (target.id === "menuBottomBarConfig") {+ openMobileSetting(app, "appearance");+ window.setTimeout(() => {+ document.getElementById("mobileBottomBarSetting")?.scrollIntoView({block: "center"});+ }, 100);+ event.preventDefault();+ event.stopPropagation();+ break;} else if (target.id === "menuPlugin") {openTopBarMenu(app);event.preventDefault();diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex e3f6366891..7629fc7056 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -27,6 +27,8 @@ import {showMessage} from "../../dialog/message";import {setTitle} from "../../util/processTitle";import {activateQueuedAVLocate, queueAVLocateRequest} from "../../protyle/render/av/locate";import {MobileTabs} from "../tabs/MobileTabs";+import {initMobileBottomBar} from "./mobileBottomBar";+import {initMobileBars} from "./mobileBars";let custom: MobileCustom;const openDockMenu = (app: App) => {@@ -65,6 +67,8 @@ export const initFramework = async (app: App, isStart: boolean) => {setInlineStyle();const snippetReady = renderSnippet(Constants.TIMEOUT_SNIPPET_LOAD);initKeyboardToolbar();+ initMobileBottomBar(app);+ initMobileBars();const sidebarElement = document.getElementById("sidebar");// 不能使用 getEventName,否则点击返回会展开右侧栏const firstToolbarElement = sidebarElement.querySelector(".toolbar--border");@@ -151,16 +155,7 @@ export const initFramework = async (app: App, isStart: boolean) => {}activeBlur();sidebarElement.style.transform = "translateX(0px)";- const type = sidebarElement.querySelector(".toolbar--border .toolbar__icon--active").getAttribute("data-type");- if (type === "sidebar-outline-tab") {- window.siyuan.mobile.docks.outline.reload();- } else if (type === "sidebar-backlink-tab") {- window.siyuan.mobile.docks.backlink.update();- } else if (type === "sidebar-bookmark-tab") {- window.siyuan.mobile.docks.bookmark.update();- } else if (type === "sidebar-tag-tab") {- window.siyuan.mobile.docks.tag.update();- }+ firstToolbarElement.dispatchEvent(new CustomEvent("click", {detail: "file"}));});// 用 touchstart 会导致键盘不收起document.getElementById("toolbarMore").addEventListener("click", () => {@@ -169,6 +164,7 @@ export const initFramework = async (app: App, isStart: boolean) => {document.getElementById("toolbarSync").addEventListener(getEventName(), () => {syncGuide(app);});+ document.getElementById("toolbarSync").setAttribute("aria-label", window.siyuan.languages.accountSync);document.getElementById("modelClose").addEventListener("click", () => {closeModel();});@@ -176,6 +172,9 @@ export const initFramework = async (app: App, isStart: boolean) => {const toolbarTabsElement = document.getElementById("toolbarTabs");toolbarTabsElement.setAttribute("aria-label", window.siyuan.languages.mobileTabs);toolbarTabsElement.addEventListener("click", () => {+ if (getCurrentEditor()?.protyle.toolbar.isMultiSelectMode()) {+ return;+ }activeBlur();window.siyuan.mobile.tabs.openOverview();});diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.tsindex 879c3e6e42..c144d053a5 100644--- a/app/src/mobile/util/keyboardToolbar.ts+++ b/app/src/mobile/util/keyboardToolbar.ts@@ -826,19 +826,24 @@ export const showKeyboardToolbar = () => {hideKeyboardToolbarUtil();}const toolbarElement = document.getElementById("keyboardToolbar");- window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: true}));const selection = getSelection();if (selection.rangeCount > 0 &&hasClosestByClassName(selection.getRangeAt(0).startContainer, "agent-chat__composer-host", true)) {// 智能体发送框自带操作栏,不能显示会作用于下层文档的移动端编辑工具栏。+ window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: true}));toolbarElement.classList.add("fn__none");document.getElementById("model").style.paddingBottom = "";return;}- if (!toolbarElement.classList.contains("fn__none") || getSelection().rangeCount === 0) {+ if (!toolbarElement.classList.contains("fn__none")) {+ window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: true}));+ return;+ }+ if (selection.rangeCount === 0) {return;}toolbarElement.classList.remove("fn__none");+ window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: true}));toolbarElement.style.zIndex = (++window.siyuan.zIndex).toString();updateKeyboardToolbarPosition();const modelElement = document.getElementById("model");@@ -920,7 +925,6 @@ export const hideKeyboardToolbar = () => {clearTimeout(renderKeyboardToolbarTimeout);clearTimeout(scrollSelectionIntoViewTimeout);clearRenderGutterAfterScroll?.();- window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: false}));if (showUtil) {return;}@@ -941,6 +945,7 @@ export const hideKeyboardToolbar = () => {if (modelElement.style.transform === "translateX(0px)") {modelElement.style.paddingBottom = "";}+ window.dispatchEvent(new CustomEvent("siyuan-mobile-keyboard-change", {detail: false}));};export const hideKeyboardToolbarByApp = (preserveSelection = false) => {diff --git a/app/src/mobile/util/mobileBars.ts b/app/src/mobile/util/mobileBars.tsnew file mode 100644index 0000000000..e5cd47b7d9--- /dev/null+++ b/app/src/mobile/util/mobileBars.ts@@ -0,0 +1,209 @@+import {+ createMobileBarsState,+ getMobileBarsVisibility,+ reduceMobileBarsState,+} from "./mobileBarsState";++const PANEL_IDS = ["sidebar", "menu", "model"];++let barsState = createMobileBarsState();+let scrollElement: HTMLElement | undefined;+let scrollFrame = 0;+let panelObserver: MutationObserver | undefined;+let selectionObserver: MutationObserver | undefined;+let selectionFrame = 0;+let programmaticScrollTimeout = 0;+let initialized = false;++const hasTextSelection = () => {+ const selection = getSelection();+ if (!selection || selection.isCollapsed || selection.rangeCount === 0 || !scrollElement) {+ return false;+ }+ const range = selection.getRangeAt(0);+ return scrollElement.contains(range.startContainer) && scrollElement.contains(range.endContainer);+};++export const isMobileBlockSelecting = () => {+ const multiSelectElement = scrollElement?.closest(".protyle")+ ?.querySelector(".protyle-util--mobile [data-type='exitMultiSelectMode']");+ return Boolean(multiSelectElement && !multiSelectElement.closest(".fn__none"));+};++const isPanelOpen = () => PANEL_IDS.some((id) => {+ const element = document.getElementById(id);+ return Boolean(element?.style.transform);+});++const renderMobileBars = () => {+ const visibility = getMobileBarsVisibility(barsState);+ const immersive = !visibility.readingBarsVisible && !visibility.editingBarVisible;+ document.body.classList.toggle("mobile-chrome--hidden", immersive);+ document.body.classList.toggle("mobile-keyboard--open", visibility.editingBarVisible);++ const topbarElement = document.getElementById("mobileTopBar");+ if (topbarElement) {+ topbarElement.toggleAttribute("inert", immersive);+ topbarElement.setAttribute("aria-hidden", immersive ? "true" : "false");+ }+ const bottomBarElement = document.getElementById("mobileBottomBar");+ if (bottomBarElement) {+ bottomBarElement.toggleAttribute("inert", !visibility.readingBarsVisible);+ bottomBarElement.setAttribute("aria-hidden", visibility.readingBarsVisible ? "false" : "true");+ }+};++const updatePanelState = () => {+ const open = isPanelOpen();+ if (barsState.panelOpen === open) {+ return;+ }+ barsState = reduceMobileBarsState(barsState, {+ type: "set-panel-open",+ open,+ scrollTop: scrollElement?.scrollTop,+ });+ renderMobileBars();+};++const updateSelectionState = () => {+ const selecting = hasTextSelection() || isMobileBlockSelecting();+ if (barsState.selecting === selecting) {+ return;+ }+ barsState = reduceMobileBarsState(barsState, {+ type: "set-selecting",+ active: selecting,+ scrollTop: scrollElement?.scrollTop,+ });+ renderMobileBars();+};++const onSelectionChange = () => {+ if (selectionFrame) {+ return;+ }+ selectionFrame = requestAnimationFrame(() => {+ selectionFrame = 0;+ updateSelectionState();+ });+};++const onScroll = () => {+ if (!scrollElement || scrollFrame) {+ return;+ }+ scrollFrame = requestAnimationFrame(() => {+ scrollFrame = 0;+ if (!scrollElement) {+ return;+ }+ updatePanelState();+ updateSelectionState();+ if (barsState.selecting || barsState.programmaticScrolling) {+ barsState = reduceMobileBarsState(barsState, {+ type: "scroll",+ scrollTop: scrollElement.scrollTop,+ });+ return;+ }+ barsState = reduceMobileBarsState(barsState, {+ type: "scroll",+ scrollTop: scrollElement.scrollTop,+ });+ renderMobileBars();+ });+};++export const bindMobileBarsScroll = (element: HTMLElement) => {+ if (scrollElement === element) {+ resetMobileBars(element.scrollTop);+ updateSelectionState();+ return;+ }+ cancelAnimationFrame(scrollFrame);+ scrollFrame = 0;+ scrollElement?.removeEventListener("scroll", onScroll);+ selectionObserver?.disconnect();+ selectionObserver = undefined;+ scrollElement = element;+ scrollElement.addEventListener("scroll", onScroll, {passive: true});+ const selectionElement = element.closest(".protyle")?.querySelector(".protyle-util--mobile");+ if (selectionElement) {+ selectionObserver = new MutationObserver(updateSelectionState);+ selectionObserver.observe(selectionElement, {+ attributes: true,+ attributeFilter: ["class"],+ childList: true,+ subtree: true,+ });+ }+ resetMobileBars(element.scrollTop);+ updateSelectionState();+};++export const clearMobileBarsScroll = () => {+ cancelAnimationFrame(scrollFrame);+ cancelAnimationFrame(selectionFrame);+ scrollFrame = 0;+ selectionFrame = 0;+ scrollElement?.removeEventListener("scroll", onScroll);+ selectionObserver?.disconnect();+ selectionObserver = undefined;+ scrollElement = undefined;+ resetMobileBars(0);+};++export const resetMobileBars = (scrollTop = scrollElement?.scrollTop || 0) => {+ clearTimeout(programmaticScrollTimeout);+ barsState = reduceMobileBarsState(barsState, {type: "document-changed", scrollTop});+ renderMobileBars();+};++export const pauseMobileBarsScroll = (duration = 320) => {+ clearTimeout(programmaticScrollTimeout);+ barsState = reduceMobileBarsState(barsState, {+ type: "set-programmatic-scrolling",+ active: true,+ scrollTop: scrollElement?.scrollTop,+ });+ programmaticScrollTimeout = window.setTimeout(() => {+ barsState = reduceMobileBarsState(barsState, {+ type: "set-programmatic-scrolling",+ active: false,+ scrollTop: scrollElement?.scrollTop,+ });+ renderMobileBars();+ }, duration);+};++export const showMobileBars = () => {+ barsState = reduceMobileBarsState(barsState, {type: "set-reading-bars", visible: true});+ renderMobileBars();+};++export const initMobileBars = () => {+ if (initialized) {+ return;+ }+ initialized = true;+ window.addEventListener("siyuan-mobile-keyboard-change", ((event: CustomEvent<boolean>) => {+ barsState = reduceMobileBarsState(barsState, {+ type: "set-editing",+ active: event.detail,+ scrollTop: scrollElement?.scrollTop,+ });+ renderMobileBars();+ }) as EventListener);+ document.addEventListener("selectionchange", onSelectionChange);++ panelObserver?.disconnect();+ const panelElements = PANEL_IDS.map((id) => document.getElementById(id)).filter(Boolean);+ panelObserver = new MutationObserver(updatePanelState);+ panelElements.forEach((element) => panelObserver.observe(element, {+ attributes: true,+ attributeFilter: ["style"],+ }));+ barsState = createMobileBarsState(scrollElement?.scrollTop);+ renderMobileBars();+};diff --git a/app/src/mobile/util/mobileBarsState.test.ts b/app/src/mobile/util/mobileBarsState.test.tsnew file mode 100644index 0000000000..81b426fbe6--- /dev/null+++ b/app/src/mobile/util/mobileBarsState.test.ts@@ -0,0 +1,176 @@+import {describe, it} from "node:test";+import * as assert from "node:assert/strict";+import {+ createMobileBarsState,+ getMobileBarsVisibility,+ reduceMobileBarsState,+ type IMobileBarsScrollOptions,+ type IMobileBarsState,+ type MobileBarsAction,+} from "./mobileBarsState";++const scrollOptions: IMobileBarsScrollOptions = {+ hideThreshold: 30,+ showThreshold: 12,+ topThreshold: 4,+};++const update = (state: IMobileBarsState, action: MobileBarsAction) => {+ return reduceMobileBarsState(state, action, scrollOptions);+};++describe("mobile bars state", () => {+ it("uses asymmetric default thresholds to avoid flicker", () => {+ let state = createMobileBarsState();+ state = reduceMobileBarsState(state, {type: "scroll", scrollTop: 31});+ assert.equal(state.readingBarsVisible, true);+ state = reduceMobileBarsState(state, {type: "scroll", scrollTop: 32});+ assert.equal(state.readingBarsVisible, false);+ state = reduceMobileBarsState(state, {type: "scroll", scrollTop: 17});+ assert.equal(state.readingBarsVisible, false);+ state = reduceMobileBarsState(state, {type: "scroll", scrollTop: 16});+ assert.equal(state.readingBarsVisible, true);+ });++ it("shows reading bars initially and supports explicit visibility changes", () => {+ let state = createMobileBarsState();+ assert.deepEqual(getMobileBarsVisibility(state), {+ readingBarsVisible: true,+ editingBarVisible: false,+ scrollPaused: false,+ });++ state = update(state, {type: "set-reading-bars", visible: false});+ assert.equal(state.readingBarsVisible, false);+ state = update(state, {type: "set-reading-bars", visible: true});+ assert.equal(state.readingBarsVisible, true);+ });++ it("hides reading bars after cumulative downward movement", () => {+ let state = createMobileBarsState();+ state = update(state, {type: "scroll", scrollTop: 10});+ state = update(state, {type: "scroll", scrollTop: 24});+ assert.equal(state.readingBarsVisible, true);+ assert.equal(state.scrollDistance, 24);++ state = update(state, {type: "scroll", scrollTop: 31});+ assert.equal(state.readingBarsVisible, false);+ assert.equal(state.scrollDistance, 0);+ });++ it("restarts accumulation when the scroll direction changes", () => {+ let state = createMobileBarsState();+ state = update(state, {type: "scroll", scrollTop: 20});+ state = update(state, {type: "scroll", scrollTop: 18});+ state = update(state, {type: "scroll", scrollTop: 35});++ assert.equal(state.readingBarsVisible, true);+ assert.equal(state.scrollDirection, "down");+ assert.equal(state.scrollDistance, 17);+ });++ it("shows hidden reading bars after cumulative upward movement", () => {+ let state = createMobileBarsState(80);+ state = update(state, {type: "set-reading-bars", visible: false});+ state = update(state, {type: "scroll", scrollTop: 72});+ assert.equal(state.readingBarsVisible, false);++ state = update(state, {type: "scroll", scrollTop: 66});+ assert.equal(state.readingBarsVisible, true);+ assert.equal(state.scrollDistance, 0);+ });++ it("forces reading bars to show near the top", () => {+ let state = createMobileBarsState(80);+ state = update(state, {type: "set-reading-bars", visible: false});+ state = update(state, {type: "scroll", scrollTop: 4});++ assert.equal(state.readingBarsVisible, true);+ assert.equal(state.scrollDirection, undefined);+ assert.equal(state.scrollDistance, 0);+ });++ it("gives the editing bar priority and restores reading bars after editing", () => {+ let state = createMobileBarsState(100);+ state = update(state, {type: "set-editing", active: true});+ assert.deepEqual(getMobileBarsVisibility(state), {+ readingBarsVisible: false,+ editingBarVisible: true,+ scrollPaused: true,+ });++ state = update(state, {type: "set-reading-bars", visible: true});+ state = update(state, {type: "scroll", scrollTop: 180});+ assert.equal(state.readingBarsVisible, false);+ assert.equal(state.scrollTop, 180);++ state = update(state, {type: "set-editing", active: false, scrollTop: 180});+ assert.deepEqual(getMobileBarsVisibility(state), {+ readingBarsVisible: true,+ editingBarVisible: false,+ scrollPaused: false,+ });+ });++ it("gives selection priority and restores reading bars after selection", () => {+ let state = createMobileBarsState(100);+ state = update(state, {type: "set-selecting", active: true});+ assert.deepEqual(getMobileBarsVisibility(state), {+ readingBarsVisible: false,+ editingBarVisible: false,+ scrollPaused: true,+ });++ state = update(state, {type: "scroll", scrollTop: 180});+ assert.equal(state.scrollDistance, 0);+ state = update(state, {type: "set-selecting", active: false, scrollTop: 180});+ assert.deepEqual(getMobileBarsVisibility(state), {+ readingBarsVisible: true,+ editingBarVisible: false,+ scrollPaused: false,+ });+ });++ it("pauses scroll decisions while a panel is open and rebases when it closes", () => {+ let state = createMobileBarsState(100);+ state = update(state, {type: "set-panel-open", open: true});+ assert.equal(getMobileBarsVisibility(state).readingBarsVisible, false);+ state = update(state, {type: "scroll", scrollTop: 200});+ assert.equal(state.readingBarsVisible, true);+ assert.equal(state.scrollDistance, 0);++ state = update(state, {type: "set-panel-open", open: false, scrollTop: 200});+ assert.equal(getMobileBarsVisibility(state).readingBarsVisible, true);+ state = update(state, {type: "scroll", scrollTop: 220});+ assert.equal(state.readingBarsVisible, true);+ state = update(state, {type: "scroll", scrollTop: 231});+ assert.equal(state.readingBarsVisible, false);+ });++ it("pauses programmatic scrolling and applies the top rule after resuming", () => {+ let state = createMobileBarsState(100);+ state = update(state, {type: "set-programmatic-scrolling", active: true});+ state = update(state, {type: "scroll", scrollTop: 260});+ state = update(state, {type: "set-programmatic-scrolling", active: false, scrollTop: 260});+ state = update(state, {type: "scroll", scrollTop: 278});+ assert.equal(state.readingBarsVisible, true);+ state = update(state, {type: "scroll", scrollTop: 291});+ assert.equal(state.readingBarsVisible, false);++ state = update(state, {type: "set-programmatic-scrolling", active: true});+ state = update(state, {type: "scroll", scrollTop: 0});+ assert.equal(state.readingBarsVisible, false);+ state = update(state, {type: "set-programmatic-scrolling", active: false, scrollTop: 0});+ assert.equal(state.readingBarsVisible, true);+ });++ it("resets transient state when the document changes", () => {+ let state = createMobileBarsState(100);+ state = update(state, {type: "set-editing", active: true});+ state = update(state, {type: "set-panel-open", open: true});+ state = update(state, {type: "set-programmatic-scrolling", active: true});+ state = update(state, {type: "document-changed", scrollTop: 12});++ assert.deepEqual(state, createMobileBarsState(12));+ });+});diff --git a/app/src/mobile/util/mobileBarsState.ts b/app/src/mobile/util/mobileBarsState.tsnew file mode 100644index 0000000000..782d178dcc--- /dev/null+++ b/app/src/mobile/util/mobileBarsState.ts@@ -0,0 +1,189 @@+export type MobileBarsScrollDirection = "up" | "down";++export interface IMobileBarsScrollOptions {+ hideThreshold: number,+ showThreshold: number,+ topThreshold: number,+}++export interface IMobileBarsState {+ readingBarsVisible: boolean,+ editing: boolean,+ selecting: boolean,+ panelOpen: boolean,+ programmaticScrolling: boolean,+ scrollTop: number,+ scrollDirection?: MobileBarsScrollDirection,+ scrollDistance: number,+}++export interface IMobileBarsVisibility {+ readingBarsVisible: boolean,+ editingBarVisible: boolean,+ scrollPaused: boolean,+}++export type MobileBarsAction = {+ type: "scroll",+ scrollTop: number,+} | {+ type: "set-reading-bars",+ visible: boolean,+} | {+ type: "set-editing",+ active: boolean,+ scrollTop?: number,+} | {+ type: "set-selecting",+ active: boolean,+ scrollTop?: number,+} | {+ type: "set-panel-open",+ open: boolean,+ scrollTop?: number,+} | {+ type: "set-programmatic-scrolling",+ active: boolean,+ scrollTop?: number,+} | {+ type: "document-changed",+ scrollTop?: number,+};++export const MOBILE_BARS_SCROLL_OPTIONS: Readonly<IMobileBarsScrollOptions> = {+ hideThreshold: 32,+ showThreshold: 16,+ topThreshold: 8,+};++const normalizeScrollTop = (scrollTop: number, fallback = 0) => {+ return Number.isFinite(scrollTop) ? Math.max(0, scrollTop) : fallback;+};++const getScrollOptions = (options: Partial<IMobileBarsScrollOptions>) => ({+ hideThreshold: Number.isFinite(options.hideThreshold) ?+ Math.max(0, options.hideThreshold) : MOBILE_BARS_SCROLL_OPTIONS.hideThreshold,+ showThreshold: Number.isFinite(options.showThreshold) ?+ Math.max(0, options.showThreshold) : MOBILE_BARS_SCROLL_OPTIONS.showThreshold,+ topThreshold: Number.isFinite(options.topThreshold) ?+ Math.max(0, options.topThreshold) : MOBILE_BARS_SCROLL_OPTIONS.topThreshold,+});++const resetScrollTracking = (state: IMobileBarsState, scrollTop = state.scrollTop): IMobileBarsState => ({+ ...state,+ scrollTop: normalizeScrollTop(scrollTop, state.scrollTop),+ scrollDirection: undefined,+ scrollDistance: 0,+});++export const createMobileBarsState = (scrollTop = 0): IMobileBarsState => ({+ readingBarsVisible: true,+ editing: false,+ selecting: false,+ panelOpen: false,+ programmaticScrolling: false,+ scrollTop: normalizeScrollTop(scrollTop),+ scrollDistance: 0,+});++export const isMobileBarsScrollPaused = (state: IMobileBarsState) => {+ return state.editing || state.selecting || state.panelOpen || state.programmaticScrolling;+};++export const getMobileBarsVisibility = (state: IMobileBarsState): IMobileBarsVisibility => ({+ readingBarsVisible: state.readingBarsVisible && !state.editing && !state.selecting && !state.panelOpen,+ editingBarVisible: state.editing,+ scrollPaused: isMobileBarsScrollPaused(state),+});++export const reduceMobileBarsState = (+ state: IMobileBarsState,+ action: MobileBarsAction,+ options: Partial<IMobileBarsScrollOptions> = {},+): IMobileBarsState => {+ const scrollOptions = getScrollOptions(options);++ if (action.type === "document-changed") {+ return createMobileBarsState(action.scrollTop);+ }++ if (action.type === "set-reading-bars") {+ return {+ ...resetScrollTracking(state),+ readingBarsVisible: state.editing ? false : action.visible,+ };+ }++ if (action.type === "set-editing") {+ return {+ ...resetScrollTracking(state, action.scrollTop),+ readingBarsVisible: !action.active,+ editing: action.active,+ };+ }++ if (action.type === "set-selecting") {+ return {+ ...resetScrollTracking(state, action.scrollTop),+ readingBarsVisible: action.active ? state.readingBarsVisible : true,+ selecting: action.active,+ };+ }++ if (action.type === "set-panel-open") {+ const nextState = {+ ...resetScrollTracking(state, action.scrollTop),+ panelOpen: action.open,+ };+ if (!action.open && !nextState.editing && !nextState.programmaticScrolling &&+ nextState.scrollTop <= scrollOptions.topThreshold) {+ nextState.readingBarsVisible = true;+ }+ return nextState;+ }++ if (action.type === "set-programmatic-scrolling") {+ const nextState = {+ ...resetScrollTracking(state, action.scrollTop),+ programmaticScrolling: action.active,+ };+ if (!action.active && !nextState.editing && !nextState.panelOpen &&+ nextState.scrollTop <= scrollOptions.topThreshold) {+ nextState.readingBarsVisible = true;+ }+ return nextState;+ }++ const scrollTop = normalizeScrollTop(action.scrollTop, state.scrollTop);+ const nextState = resetScrollTracking(state, scrollTop);+ if (isMobileBarsScrollPaused(state)) {+ return nextState;+ }+ if (scrollTop <= scrollOptions.topThreshold) {+ nextState.readingBarsVisible = true;+ return nextState;+ }++ const scrollDelta = scrollTop - state.scrollTop;+ if (scrollDelta === 0) {+ return state;+ }++ const scrollDirection: MobileBarsScrollDirection = scrollDelta > 0 ? "down" : "up";+ const canChangeVisibility = scrollDirection === "down" ? state.readingBarsVisible : !state.readingBarsVisible;+ if (!canChangeVisibility) {+ return nextState;+ }++ const scrollDistance = Math.abs(scrollDelta) ++ (state.scrollDirection === scrollDirection ? state.scrollDistance : 0);+ const threshold = scrollDirection === "down" ? scrollOptions.hideThreshold : scrollOptions.showThreshold;+ if (scrollDistance >= threshold) {+ nextState.readingBarsVisible = scrollDirection === "up";+ return nextState;+ }++ nextState.scrollDirection = scrollDirection;+ nextState.scrollDistance = scrollDistance;+ return nextState;+};diff --git a/app/src/mobile/util/mobileBottomBar.ts b/app/src/mobile/util/mobileBottomBar.tsnew file mode 100644index 0000000000..5875292484--- /dev/null+++ b/app/src/mobile/util/mobileBottomBar.ts@@ -0,0 +1,222 @@+import type {App} from "../../index";+import {Constants} from "../../constants";+import {setStorageVal} from "../../protyle/util/compatibility";+import {escapeAttr, escapeHtml} from "../../util/escape";+import {newFile} from "../../util/newFile";+import {commandPanel} from "../../boot/globalEvent/command/panel";+import {popSearch} from "../menu/search";+import {getRecentDocs} from "../menu/getRecentDocs";+import {openDock} from "../dock/util";+import {closePanel} from "./closePanel";+import {activeBlur} from "./keyboardToolbar";+import {isMobileBlockSelecting} from "./mobileBars";+import {+ MOBILE_BOTTOM_BAR_ACTIONS,+ normalizeMobileBottomBarConfig,+ reduceMobileBottomBarConfig,+ resolveMobileBottomBarAvailability,+ type IMobileBottomBarConfig,+ type MobileBottomBarAction,+ type MobileBottomBarSlot,+} from "./mobileBottomBarConfig";++const getActionLabel = (action: MobileBottomBarAction) => {+ switch (action) {+ case "documents":+ return window.siyuan.languages.fileTree;+ case "search":+ return window.siyuan.languages.search;+ case "newDoc":+ return window.siyuan.languages.newFile;+ case "tabs":+ return window.siyuan.languages.mobileTabs;+ case "recent":+ return window.siyuan.languages.recentDocs;+ case "outline":+ return window.siyuan.languages.outline;+ case "bookmark":+ return window.siyuan.languages.bookmark;+ case "tag":+ return window.siyuan.languages.tag;+ case "command":+ return window.siyuan.languages.commandPanel;+ }+};++const getBottomBarConfig = () => {+ const config = normalizeMobileBottomBarConfig(window.siyuan.storage[Constants.LOCAL_MOBILE_BOTTOM_BAR]);+ if (!window.siyuan.config.readonly && !window.siyuan.isPublish) {+ return config;+ }+ return resolveMobileBottomBarAvailability(config, ["newDoc"]);+};++const setBottomBarConfig = (config: IMobileBottomBarConfig) => {+ window.siyuan.storage[Constants.LOCAL_MOBILE_BOTTOM_BAR] = config;+ setStorageVal(Constants.LOCAL_MOBILE_BOTTOM_BAR, config);+ renderMobileBottomBar();+};++const updateActionText = (element: HTMLElement, label: string) => {+ element.setAttribute("aria-label", label);+ element.setAttribute("title", label);+ const labelElement = element.querySelector(".mobile-bottom-bar__label");+ if (labelElement) {+ labelElement.textContent = label;+ }+};++export const renderMobileBottomBar = () => {+ const bottomBarElement = document.getElementById("mobileBottomBar");+ const moreElement = document.getElementById("toolbarMore");+ if (!bottomBarElement || !moreElement) {+ return;+ }++ const config = getBottomBarConfig();+ MOBILE_BOTTOM_BAR_ACTIONS.forEach((action) => {+ const element = bottomBarElement.querySelector<HTMLElement>(`[data-action="${action}"]`);+ if (!element) {+ return;+ }+ element.classList.add("fn__none");+ element.removeAttribute("data-slot");+ updateActionText(element, getActionLabel(action));+ });+ config.actions.forEach((action, slot) => {+ const element = bottomBarElement.querySelector<HTMLElement>(`[data-action="${action}"]`);+ if (!element) {+ return;+ }+ element.classList.remove("fn__none");+ element.dataset.slot = slot.toString();+ bottomBarElement.insertBefore(element, moreElement);+ });+ updateActionText(moreElement, window.siyuan.languages.more);+ bottomBarElement.setAttribute("aria-label", window.siyuan.languages.mobileBottomBar);+ (document.getElementById("mobileBottomBarNewDoc") as HTMLButtonElement).disabled =+ window.siyuan.config.readonly || window.siyuan.isPublish;+};++const bindBottomBarAction = (id: string, callback: () => void) => {+ const element = document.getElementById(id);+ if (!element) {+ return;+ }+ element.addEventListener("click", callback);+};++export const initMobileBottomBar = (app: App) => {+ renderMobileBottomBar();+ const bottomBarElement = document.getElementById("mobileBottomBar");+ if (!bottomBarElement || bottomBarElement.dataset.bound === "true") {+ return;+ }+ bottomBarElement.dataset.bound = "true";+ bindBottomBarAction("mobileBottomBarSearch", () => {+ if (isMobileBlockSelecting()) {+ return;+ }+ activeBlur();+ popSearch(app);+ });+ bindBottomBarAction("mobileBottomBarNewDoc", () => {+ if (isMobileBlockSelecting()) {+ return;+ }+ activeBlur();+ newFile(app);+ closePanel();+ });+ bindBottomBarAction("mobileBottomBarRecent", () => {+ if (isMobileBlockSelecting()) {+ return;+ }+ activeBlur();+ getRecentDocs(app);+ });+ bindBottomBarAction("mobileBottomBarOutline", () => {+ if (!isMobileBlockSelecting()) {+ openDock("outline");+ }+ });+ bindBottomBarAction("mobileBottomBarBookmark", () => {+ if (!isMobileBlockSelecting()) {+ openDock("bookmark");+ }+ });+ bindBottomBarAction("mobileBottomBarTag", () => {+ if (!isMobileBlockSelecting()) {+ openDock("tag");+ }+ });+ bindBottomBarAction("mobileBottomBarCommand", () => {+ if (isMobileBlockSelecting()) {+ return;+ }+ activeBlur();+ closePanel();+ commandPanel(app);+ });+};++const genBottomBarOptions = () => MOBILE_BOTTOM_BAR_ACTIONS.map((action) =>+ `<option value="${action}">${escapeHtml(getActionLabel(action))}</option>`+).join("");++export const genMobileBottomBarSettingHTML = () => {+ const title = window.siyuan.languages.mobileBottomBar;+ const disabled = window.siyuan.config.readonly || window.siyuan.isPublish ? " disabled" : "";+ const selects = [0, 1, 2, 3].map((slot) => `<label class="mobile-bottom-bar-setting__slot">+ <span>${slot + 1}</span>+ <select class="b3-select fn__flex-1" data-bottom-bar-slot="${slot}" aria-label="${escapeAttr(`${title} ${slot + 1}`)}"${disabled}>${genBottomBarOptions()}</select>+ </label>`).join("");+ return `<div id="mobileBottomBarSetting" class="b3-label config-item mobile-bottom-bar-setting">+ <div class="fn__flex">+ <div class="fn__flex-1 config-item__main"><div class="config-name">${escapeHtml(title)}</div></div>+ <button class="b3-button b3-button--outline" data-type="reset" type="button"${disabled}>+ <svg><use xlink:href="#iconUndo"></use></svg>${escapeHtml(window.siyuan.languages.reset)}+ </button>+ </div>+ <div class="mobile-bottom-bar-setting__slots">${selects}</div>+</div>`;+};++export const mountMobileBottomBarSetting = (root: HTMLElement) => {+ const settingElement = root.querySelector<HTMLElement>("#mobileBottomBarSetting");+ if (!settingElement) {+ return;+ }+ let config = getBottomBarConfig();+ const syncSelects = () => {+ settingElement.querySelectorAll<HTMLSelectElement>("[data-bottom-bar-slot]").forEach((selectElement) => {+ const slot = Number(selectElement.dataset.bottomBarSlot) as MobileBottomBarSlot;+ selectElement.value = config.actions[slot];+ });+ };+ settingElement.addEventListener("change", (event) => {+ const selectElement = (event.target as HTMLElement).closest<HTMLSelectElement>("[data-bottom-bar-slot]");+ if (!selectElement) {+ return;+ }+ const slot = Number(selectElement.dataset.bottomBarSlot);+ const action = selectElement.value as MobileBottomBarAction;+ if (![0, 1, 2, 3].includes(slot) || !MOBILE_BOTTOM_BAR_ACTIONS.includes(action)) {+ syncSelects();+ return;+ }+ config = reduceMobileBottomBarConfig(config, {+ type: "select-action",+ slot: slot as MobileBottomBarSlot,+ action,+ });+ setBottomBarConfig(config);+ syncSelects();+ });+ settingElement.querySelector('[data-type="reset"]')?.addEventListener("click", () => {+ config = reduceMobileBottomBarConfig(config, {type: "reset"});+ setBottomBarConfig(config);+ syncSelects();+ });+ syncSelects();+};diff --git a/app/src/mobile/util/mobileBottomBarConfig.test.ts b/app/src/mobile/util/mobileBottomBarConfig.test.tsnew file mode 100644index 0000000000..953f697706--- /dev/null+++ b/app/src/mobile/util/mobileBottomBarConfig.test.ts@@ -0,0 +1,77 @@+import {describe, it} from "node:test";+import * as assert from "node:assert/strict";+import {+ createDefaultMobileBottomBarConfig,+ DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS,+ MOBILE_BOTTOM_BAR_ACTIONS,+ MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ normalizeMobileBottomBarConfig,+ reduceMobileBottomBarConfig,+ resolveMobileBottomBarAvailability,+} from "./mobileBottomBarConfig";++describe("mobile bottom bar config", () => {+ it("falls back to the default for malformed storage values", () => {+ [+ null,+ false,+ "not json",+ [],+ {version: 2, actions: ["recent", "outline", "bookmark", "tag"]},+ {version: MOBILE_BOTTOM_BAR_CONFIG_VERSION, actions: "documents"},+ ].forEach((storedValue) => {+ assert.deepEqual(normalizeMobileBottomBarConfig(storedValue), createDefaultMobileBottomBarConfig());+ });+ });++ it("accepts serialized config and fills invalid or duplicate slots in order", () => {+ const config = normalizeMobileBottomBarConfig(JSON.stringify({+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: ["recent", "recent", "unknown", "tag"],+ }));++ assert.deepEqual(config.actions, ["recent", "documents", "search", "tag"]);+ assert.equal(config.actions.length, 4);+ assert.equal(new Set(config.actions).size, 4);+ assert.equal(config.actions.every((action) => MOBILE_BOTTOM_BAR_ACTIONS.includes(action)), true);+ });++ it("swaps slots when selecting an action already in the bottom bar", () => {+ const config = reduceMobileBottomBarConfig(createDefaultMobileBottomBarConfig(), {+ type: "select-action",+ slot: 0,+ action: "tabs",+ });++ assert.deepEqual(config.actions, ["tabs", "search", "newDoc", "documents"]);+ });++ it("replaces a slot when selecting an unused action", () => {+ const config = reduceMobileBottomBarConfig(createDefaultMobileBottomBarConfig(), {+ type: "select-action",+ slot: 1,+ action: "outline",+ });++ assert.deepEqual(config.actions, ["documents", "outline", "newDoc", "tabs"]);+ });++ it("resets customized actions to a fresh default config", () => {+ const customized = normalizeMobileBottomBarConfig({+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: ["recent", "outline", "bookmark", "command"],+ });+ const config = reduceMobileBottomBarConfig(customized, {type: "reset"});++ assert.equal(config.version, 1);+ assert.deepEqual(config.actions, DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS);+ assert.notEqual(config.actions, DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS);+ });++ it("replaces actions that are unavailable in the current mode", () => {+ const config = resolveMobileBottomBarAvailability(createDefaultMobileBottomBarConfig(), ["newDoc"]);++ assert.deepEqual(config.actions, ["documents", "search", "recent", "tabs"]);+ assert.equal(config.actions.includes("newDoc"), false);+ });+});diff --git a/app/src/mobile/util/mobileBottomBarConfig.ts b/app/src/mobile/util/mobileBottomBarConfig.tsnew file mode 100644index 0000000000..b7dcbd1387--- /dev/null+++ b/app/src/mobile/util/mobileBottomBarConfig.ts@@ -0,0 +1,164 @@+export const MOBILE_BOTTOM_BAR_CONFIG_VERSION = 1 as const;++export const MOBILE_BOTTOM_BAR_ACTIONS = [+ "documents",+ "search",+ "newDoc",+ "tabs",+ "recent",+ "outline",+ "bookmark",+ "tag",+ "command",+] as const;++export type MobileBottomBarAction = typeof MOBILE_BOTTOM_BAR_ACTIONS[number];+export type MobileBottomBarSlot = 0 | 1 | 2 | 3;+export type MobileBottomBarSlots = readonly [+ MobileBottomBarAction,+ MobileBottomBarAction,+ MobileBottomBarAction,+ MobileBottomBarAction,+];++export interface IMobileBottomBarConfig {+ version: typeof MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: MobileBottomBarSlots,+}++export type MobileBottomBarConfigEvent = {+ type: "select-action",+ slot: MobileBottomBarSlot,+ action: MobileBottomBarAction,+} | {+ type: "reset",+};++export const DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS: MobileBottomBarSlots = [+ "documents",+ "search",+ "newDoc",+ "tabs",+];++export const DEFAULT_MOBILE_BOTTOM_BAR_CONFIG: IMobileBottomBarConfig = {+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS,+};++const mobileBottomBarActionSet = new Set<string>(MOBILE_BOTTOM_BAR_ACTIONS);++export const isMobileBottomBarAction = (value: unknown): value is MobileBottomBarAction => {+ return typeof value === "string" && mobileBottomBarActionSet.has(value);+};++const toMobileBottomBarSlots = (actions: MobileBottomBarAction[]): MobileBottomBarSlots => {+ return [actions[0], actions[1], actions[2], actions[3]];+};++const normalizeMobileBottomBarActions = (storedActions: unknown[]): MobileBottomBarSlots => {+ const actions = new Array<MobileBottomBarAction>(4);+ const usedActions = new Set<MobileBottomBarAction>();++ for (let slot = 0; slot < actions.length; slot++) {+ const action = storedActions[slot];+ if (isMobileBottomBarAction(action) && !usedActions.has(action)) {+ actions[slot] = action;+ usedActions.add(action);+ }+ }++ const fallbackActions: readonly MobileBottomBarAction[] = [+ ...DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS,+ ...MOBILE_BOTTOM_BAR_ACTIONS,+ ];+ let fallbackIndex = 0;+ for (let slot = 0; slot < actions.length; slot++) {+ if (actions[slot]) {+ continue;+ }+ while (usedActions.has(fallbackActions[fallbackIndex])) {+ fallbackIndex++;+ }+ actions[slot] = fallbackActions[fallbackIndex];+ usedActions.add(actions[slot]);+ }++ return toMobileBottomBarSlots(actions);+};++export const createDefaultMobileBottomBarConfig = (): IMobileBottomBarConfig => ({+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: [...DEFAULT_MOBILE_BOTTOM_BAR_ACTIONS],+});++export const normalizeMobileBottomBarConfig = (storedValue: unknown): IMobileBottomBarConfig => {+ let value = storedValue;+ if (typeof value === "string") {+ try {+ value = JSON.parse(value);+ } catch {+ return createDefaultMobileBottomBarConfig();+ }+ }+ if (!value || typeof value !== "object" || Array.isArray(value)) {+ return createDefaultMobileBottomBarConfig();+ }++ const record = value as Record<string, unknown>;+ if (record.version !== MOBILE_BOTTOM_BAR_CONFIG_VERSION || !Array.isArray(record.actions)) {+ return createDefaultMobileBottomBarConfig();+ }+ return {+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: normalizeMobileBottomBarActions(record.actions),+ };+};++export const resolveMobileBottomBarAvailability = (+ storedValue: unknown,+ unavailableActions: readonly MobileBottomBarAction[],+): IMobileBottomBarConfig => {+ const config = normalizeMobileBottomBarConfig(storedValue);+ const unavailable = new Set(unavailableActions);+ const actions = [...config.actions];+ actions.forEach((action, slot) => {+ if (!unavailable.has(action)) {+ return;+ }+ const replacement = MOBILE_BOTTOM_BAR_ACTIONS.find((candidate) =>+ !unavailable.has(candidate) && !actions.includes(candidate)+ );+ if (replacement) {+ actions[slot] = replacement;+ }+ });+ return {+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: toMobileBottomBarSlots(actions),+ };+};++export const reduceMobileBottomBarConfig = (+ state: IMobileBottomBarConfig,+ event: MobileBottomBarConfigEvent,+): IMobileBottomBarConfig => {+ if (event.type === "reset") {+ return createDefaultMobileBottomBarConfig();+ }++ const currentState = normalizeMobileBottomBarConfig(state);+ const actions = [...currentState.actions];+ const existingSlot = actions.indexOf(event.action);+ if (existingSlot === event.slot) {+ return currentState;+ }+ if (existingSlot >= 0) {+ actions[existingSlot] = actions[event.slot];+ }+ actions[event.slot] = event.action;+ return {+ version: MOBILE_BOTTOM_BAR_CONFIG_VERSION,+ actions: toMobileBottomBarSlots(actions),+ };+};diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.tsindex fb4fd59ffe..516d853123 100644--- a/app/src/mobile/util/onMessage.ts+++ b/app/src/mobile/util/onMessage.ts@@ -15,6 +15,8 @@ import {reloadSync} from "../../util/reloadSync";import {activateOnboarding} from "../../onboarding";import {updateServerAddresses} from "../../config/tabs/accessRuntime";import {reloadInlineStyles} from "../../util/assets";+import {renderMobileBottomBar} from "./mobileBottomBar";+import {Constants} from "../../constants";let statusTimeout: number;const statusElement = document.querySelector("#status") as HTMLElement;@@ -35,7 +37,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {} else {clearTimeout(statusTimeout);statusElement.innerHTML = `<div class="fn__flex">${data.data.tasks[0].action}<div class="fn__progress"><div></div></div>`;- statusElement.style.bottom = "0";+ statusElement.style.bottom = "var(--mobile-bottom-bar-offset)";}break;case "setAppearance":@@ -99,19 +101,31 @@ export const onMessage = (app: App, data: IWebSocketData) => {break;case "setLocalStorageVal":window.siyuan.storage[data.data.key] = data.data.val;+ if (data.data.key === Constants.LOCAL_MOBILE_BOTTOM_BAR) {+ renderMobileBottomBar();+ }break;case "setLocalStorageVals":Object.keys(data.data.keyVals).forEach((k) => {window.siyuan.storage[k] = data.data.keyVals[k];});+ if (Object.prototype.hasOwnProperty.call(data.data.keyVals, Constants.LOCAL_MOBILE_BOTTOM_BAR)) {+ renderMobileBottomBar();+ }break;case "removeLocalStorageVal":delete window.siyuan.storage[data.data.key];+ if (data.data.key === Constants.LOCAL_MOBILE_BOTTOM_BAR) {+ renderMobileBottomBar();+ }break;case "removeLocalStorageVals":data.data.keys.forEach((k: string) => {delete window.siyuan.storage[k];});+ if (data.data.keys.includes(Constants.LOCAL_MOBILE_BOTTOM_BAR)) {+ renderMobileBottomBar();+ }break;case"progress":progressLoading(data);@@ -144,7 +158,7 @@ export const onMessage = (app: App, data: IWebSocketData) => {}clearTimeout(statusTimeout);statusElement.innerHTML = data.msg;- statusElement.style.bottom = "0";+ statusElement.style.bottom = "var(--mobile-bottom-bar-offset)";statusTimeout = window.setTimeout(() => {statusElement.style.bottom = "";}, 12000);diff --git a/app/src/mobile/util/setEmpty.ts b/app/src/mobile/util/setEmpty.tsindex 3123ae4ffd..239ad7c60c 100644--- a/app/src/mobile/util/setEmpty.ts+++ b/app/src/mobile/util/setEmpty.ts@@ -6,9 +6,12 @@ import {getRecentDocs} from "../menu/getRecentDocs";import {openHistory} from "../../history/history";import type {App} from "../../index";import {setTitle} from "../../util/processTitle";+import {clearMobileBarsScroll} from "./mobileBars";export const setEmpty = (app: App) => {setTitle("", true);+ clearMobileBarsScroll();+ document.getElementById("mobileTopBar").classList.add("fn__none");document.getElementById("toolbarName").classList.add("fn__hidden");document.getElementById("toolbarNameReadonly").classList.add("fn__hidden");document.getElementById("editor").classList.add("fn__none");@@ -75,6 +78,7 @@ export const setEmpty = (app: App) => {};export const setEditor = () => {+ document.getElementById("mobileTopBar").classList.remove("fn__none");const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement;setTitle(toolbarNameElement.value);toolbarNameElement.classList.remove("fn__hidden");diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex ce96aeadbe..6465c76bd6 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -746,6 +746,10 @@ export const getLocalStorage = (cb: () => void) => {version: 1,tabs: [],};+ defaultStorage[Constants.LOCAL_MOBILE_BOTTOM_BAR] = {+ version: 1,+ actions: ["documents", "search", "newDoc", "tabs"],+ };defaultStorage[Constants.LOCAL_IMAGES] = {file: "1f4c4",note: "1f5c3",@@ -778,6 +782,7 @@ export const getLocalStorage = (cb: () => void) => {[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR,Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_MOBILE_TABS,+ Constants.LOCAL_MOBILE_BOTTOM_BAR,Constants.LOCAL_FONTSTYLES,Constants.LOCAL_SEARCHDATA, Constants.LOCAL_ZOOM, Constants.LOCAL_LAYOUTS,Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD,