mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
89e22e06d0
commit
d568df24b5
11 changed files with 51 additions and 10 deletions
32
app/src/mobile/menu/getRecentDocs.ts
Normal file
32
app/src/mobile/menu/getRecentDocs.ts
Normal file
|
|
@ -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])
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue