فهرست منبع

:art: fix https://github.com/siyuan-note/siyuan/issues/7828

Vanessa 2 سال پیش
والد
کامیت
b6c540f563

+ 32 - 0
app/src/mobile/menu/getRecentDocs.ts

@@ -0,0 +1,32 @@
+import {fetchPost} from "../../util/fetch";
+import {unicode2Emoji} from "../../emoji";
+import {Constants} from "../../constants";
+import {escapeHtml} from "../../util/escape";
+import {hasClosestByClassName} from "../../protyle/util/hasClosest";
+import {openModel} from "./model";
+import {openMobileFileById} from "../editor";
+
+export const getRecentDocs = () => {
+    fetchPost("/api/storage/getRecentDocs", {}, (response) => {
+        let html = "";
+        response.data.forEach((item: any, index: number) => {
+            html += `<li data-index="${index}" data-node-id="${item.rootID}" class="b3-list-item${index === 0 ? " b3-list-item--focus" : ""}">
+${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true)}
+<span class="b3-list-item__text">${escapeHtml(item.title)}</span>
+</li>`;
+        });
+        openModel({
+            title: window.siyuan.languages.recentDocs,
+            icon: "iconList",
+            html: `<ul class="b3-list b3-list--mobile">${html}</ul>`,
+            bindEvent(element: HTMLElement) {
+                element.addEventListener("click", (event) => {
+                    const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
+                    if (liElement) {
+                        openMobileFileById(liElement.dataset.nodeId, [Constants.CB_GET_SCROLL])
+                    }
+                });
+            }
+        })
+    });
+}

+ 11 - 2
app/src/mobile/util/menu.ts → app/src/mobile/menu/index.ts

@@ -1,18 +1,19 @@
 import {popSearch} from "./search";
 import {initAppearance} from "../settings/appearance";
-import {closePanel} from "./closePanel";
+import {closePanel} from "../util/closePanel";
 import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";
 import {repos} from "../../config/repos";
 import {exitSiYuan, lockScreen, processSync} from "../../dialog/processSystem";
 import {openHistory} from "../../history/history";
 import {syncGuide} from "../../sync/syncGuide";
 import {openCard} from "../../card/openCard";
-import {activeBlur, hideKeyboardToolbar} from "./keyboardToolbar";
+import {activeBlur, hideKeyboardToolbar} from "../util/keyboardToolbar";
 import {initAI} from "../settings/ai";
 import {initRiffCard} from "../settings/riffCard";
 import {login, showAccountInfo} from "../settings/account";
 import {openModel} from "./model";
 import {initAbout} from "../settings/about";
+import {getRecentDocs} from "./getRecentDocs";
 
 export const popMenu = () => {
     activeBlur();
@@ -39,6 +40,9 @@ export const popMenu = () => {
 </div>
 <div class="b3-menu__separator"></div>
 ${accountHTML}
+<div id="menuRecent" class="b3-menu__item">
+    <svg class="b3-menu__icon"><use xlink:href="#iconList"></use></svg><span class="b3-menu__label">${window.siyuan.languages.recentDocs}</span>
+</div>
 <div id="menuSearch" class="b3-menu__item">
     <svg class="b3-menu__icon"><use xlink:href="#iconSearch"></use></svg><span class="b3-menu__label">${window.siyuan.languages.search}</span>
 </div>
@@ -104,6 +108,11 @@ ${accountHTML}
                 event.preventDefault();
                 event.stopPropagation();
                 break;
+            } else if (target.id === "menuRecent") {
+                getRecentDocs();
+                event.preventDefault();
+                event.stopPropagation();
+                break;
             } else if (target.id === "menuAppearance") {
                 initAppearance();
                 event.preventDefault();

+ 0 - 0
app/src/mobile/util/model.ts → app/src/mobile/menu/model.ts


+ 1 - 1
app/src/mobile/util/search.ts → app/src/mobile/menu/search.ts

@@ -1,4 +1,4 @@
-import {closePanel} from "./closePanel";
+import {closePanel} from "../util/closePanel";
 import {openMobileFileById} from "../editor";
 import {Constants} from "../../constants";
 import {fetchPost} from "../../util/fetch";

+ 1 - 1
app/src/mobile/settings/about.ts

@@ -7,7 +7,7 @@ import {showMessage} from "../../dialog/message";
 import {openByMobile, writeText} from "../../protyle/util/compatibility";
 import {exitSiYuan, processSync} from "../../dialog/processSystem";
 import {pathPosix} from "../../util/pathName";
-import {openModel} from "../util/model";
+import {openModel} from "../menu/model";
 
 export const initAbout = () => {
     if (!window.siyuan.config.localIPs || window.siyuan.config.localIPs.length === 0 ||

+ 1 - 1
app/src/mobile/settings/account.ts

@@ -1,4 +1,4 @@
-import {openModel} from "../util/model";
+import {openModel} from "../menu/model";
 import {getEventName} from "../../protyle/util/compatibility";
 import {fetchPost} from "../../util/fetch";
 import {closePanel} from "../util/closePanel";

+ 1 - 1
app/src/mobile/settings/ai.ts

@@ -1,4 +1,4 @@
-import {openModel} from "../util/model";
+import {openModel} from "../menu/model";
 import {ai} from "../../config/ai";
 
 export const initAI = () => {

+ 1 - 1
app/src/mobile/settings/appearance.ts

@@ -2,7 +2,7 @@ import {fetchPost} from "../../util/fetch";
 import {setInlineStyle} from "../../util/assets";
 import {genOptions} from "../../util/genOptions";
 import {reloadProtyle} from "../../protyle/util/reload";
-import {openModel} from "../util/model";
+import {openModel} from "../menu/model";
 
 export const initAppearance = () => {
     openModel({

+ 1 - 1
app/src/mobile/settings/riffCard.ts

@@ -1,4 +1,4 @@
-import {openModel} from "../util/model";
+import {openModel} from "../menu/model";
 import {flashcard} from "../../config/flashcard";
 
 export const initRiffCard = () => {

+ 1 - 1
app/src/mobile/util/MobileTags.ts

@@ -5,7 +5,7 @@ import {MenuItem} from "../../menus/Menu";
 import {Dialog} from "../../dialog";
 import {confirmDialog} from "../../dialog/confirmDialog";
 import {escapeHtml} from "../../util/escape";
-import {popSearch, toolbarSearchEvent} from "./search";
+import {popSearch, toolbarSearchEvent} from "../menu/search";
 
 export class MobileTags {
     public element: HTMLElement;

+ 1 - 1
app/src/mobile/util/initFramework.ts

@@ -8,7 +8,7 @@ import {setInlineStyle} from "../../util/assets";
 import {renderSnippet} from "../../config/util/snippets";
 import {setEmpty} from "./setEmpty";
 import {getOpenNotebookCount} from "../../util/pathName";
-import {popMenu} from "./menu";
+import {popMenu} from "../menu";
 import {MobileFiles} from "./MobileFiles";
 import {MobileOutline} from "./MobileOutline";
 import {hasTopClosestByTag} from "../../protyle/util/hasClosest";