This commit is contained in:
parent
9f0552bc72
commit
814a4ec3ac
7 changed files with 52 additions and 33 deletions
|
@ -46,7 +46,7 @@ const selectOpenTab = () => {
|
|||
/// #if MOBILE
|
||||
if (window.siyuan.mobile.editor?.protyle) {
|
||||
openDock("file");
|
||||
window.siyuan.mobile.files.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
|
||||
window.siyuan.mobile.docks.file.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
|
||||
}
|
||||
/// #else
|
||||
const dockFile = getDockByType("file");
|
||||
|
|
|
@ -71,7 +71,7 @@ export const reloadSync = (
|
|||
}
|
||||
}
|
||||
setNoteBook(() => {
|
||||
window.siyuan.mobile.files.init(false);
|
||||
window.siyuan.mobile.docks.file.init(false);
|
||||
});
|
||||
/// #else
|
||||
const allModels = getAllModels();
|
||||
|
@ -215,7 +215,7 @@ export const setDefRefCount = (data: {
|
|||
|
||||
let liElement;
|
||||
/// #if MOBILE
|
||||
liElement = window.siyuan.mobile.files.element.querySelector(`li[data-node-id="${data.rootID}"]`);
|
||||
liElement = window.siyuan.mobile.docks.file.element.querySelector(`li[data-node-id="${data.rootID}"]`);
|
||||
/// #else
|
||||
liElement = (getDockByType("file").data.file as Files).element.querySelector(`li[data-node-id="${data.rootID}"]`);
|
||||
/// #endif
|
||||
|
|
|
@ -190,7 +190,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
|
|||
liElement.parentElement.setAttribute("data-sortmode", sort.toString());
|
||||
let files;
|
||||
/// #if MOBILE
|
||||
files = window.siyuan.mobile.files;
|
||||
files = window.siyuan.mobile.docks.file;
|
||||
/// #else
|
||||
files = (getDockByType("file").data["file"] as Files);
|
||||
/// #endif
|
||||
|
@ -671,7 +671,7 @@ export const genImportMenu = (notebookId: string, pathString: string) => {
|
|||
const reloadDocTree = () => {
|
||||
let files;
|
||||
/// #if MOBILE
|
||||
files = window.siyuan.mobile.files;
|
||||
files = window.siyuan.mobile.docks.file;
|
||||
/// #else
|
||||
files = (getDockByType("file").data["file"] as Files);
|
||||
/// #endif
|
||||
|
|
|
@ -47,7 +47,16 @@ class App {
|
|||
backStack: [],
|
||||
dialogs: [],
|
||||
blockPanels: [],
|
||||
mobile: {},
|
||||
mobile: {
|
||||
docks: {
|
||||
outline: null,
|
||||
file: null,
|
||||
bookmark: null,
|
||||
tag: null,
|
||||
backlink: null,
|
||||
inbox: null,
|
||||
}
|
||||
},
|
||||
ws: new Model({
|
||||
app: this,
|
||||
id: genUUID(),
|
||||
|
@ -149,7 +158,7 @@ const siyuanApp = new App();
|
|||
// https://github.com/siyuan-note/siyuan/issues/8441
|
||||
window.reconnectWebSocket = () => {
|
||||
window.siyuan.ws.send("ping", {});
|
||||
window.siyuan.mobile.files.send("ping", {});
|
||||
window.siyuan.mobile.docks.file.send("ping", {});
|
||||
window.siyuan.mobile.editor.protyle.ws.send("ping", {});
|
||||
window.siyuan.mobile.popEditor.protyle.ws.send("ping", {});
|
||||
};
|
||||
|
|
|
@ -62,11 +62,6 @@ export const initFramework = (app: App, isStart: boolean) => {
|
|||
renderSnippet();
|
||||
initKeyboardToolbar();
|
||||
const sidebarElement = document.getElementById("sidebar");
|
||||
let outline: MobileOutline;
|
||||
let backlink: MobileBacklinks;
|
||||
let bookmark: MobileBookmarks;
|
||||
let inbox: Inbox;
|
||||
let tag: MobileTags;
|
||||
// 不能使用 getEventName,否则点击返回会展开右侧栏
|
||||
const firstToolbarElement = sidebarElement.querySelector(".toolbar--border");
|
||||
firstToolbarElement.addEventListener("click", (event: MouseEvent) => {
|
||||
|
@ -99,31 +94,31 @@ export const initFramework = (app: App, isStart: boolean) => {
|
|||
const tabPanelElement = sidebarElement.lastElementChild.querySelector(`[data-type="${itemType.replace("-tab", "")}"]`);
|
||||
if (itemType === type) {
|
||||
if (type === "sidebar-outline-tab") {
|
||||
if (!outline) {
|
||||
outline = new MobileOutline(app);
|
||||
if (!window.siyuan.mobile.docks.outline) {
|
||||
window.siyuan.mobile.docks.outline = new MobileOutline(app);
|
||||
} else {
|
||||
outline.update();
|
||||
window.siyuan.mobile.docks.outline.update();
|
||||
}
|
||||
} else if (type === "sidebar-backlink-tab") {
|
||||
if (!backlink) {
|
||||
backlink = new MobileBacklinks(app);
|
||||
if (!window.siyuan.mobile.docks.backlink) {
|
||||
window.siyuan.mobile.docks.backlink = new MobileBacklinks(app);
|
||||
} else {
|
||||
backlink.update();
|
||||
window.siyuan.mobile.docks.backlink.update();
|
||||
}
|
||||
} else if (type === "sidebar-bookmark-tab") {
|
||||
if (!bookmark) {
|
||||
bookmark = new MobileBookmarks(app);
|
||||
if (!window.siyuan.mobile.docks.bookmark) {
|
||||
window.siyuan.mobile.docks.bookmark = new MobileBookmarks(app);
|
||||
} else {
|
||||
bookmark.update();
|
||||
window.siyuan.mobile.docks.bookmark.update();
|
||||
}
|
||||
} else if (type === "sidebar-tag-tab") {
|
||||
if (!tag) {
|
||||
tag = new MobileTags(app);
|
||||
if (!window.siyuan.mobile.docks.tag) {
|
||||
window.siyuan.mobile.docks.tag = new MobileTags(app);
|
||||
} else {
|
||||
tag.update();
|
||||
window.siyuan.mobile.docks.tag.update();
|
||||
}
|
||||
} else if (type === "sidebar-inbox-tab" && !inbox) {
|
||||
inbox = new Inbox(app, document.querySelector('#sidebar [data-type="sidebar-inbox"]'));
|
||||
} else if (type === "sidebar-inbox-tab" && !window.siyuan.mobile.docks.inbox) {
|
||||
window.siyuan.mobile.docks.inbox = new Inbox(app, document.querySelector('#sidebar [data-type="sidebar-inbox"]'));
|
||||
} else if (type === "sidebar-plugin-tab") {
|
||||
if (!custom) {
|
||||
tabPanelElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`;
|
||||
|
@ -140,20 +135,20 @@ export const initFramework = (app: App, isStart: boolean) => {
|
|||
}
|
||||
});
|
||||
});
|
||||
window.siyuan.mobile.files = new MobileFiles(app);
|
||||
window.siyuan.mobile.docks.files = new MobileFiles(app);
|
||||
document.getElementById("toolbarFile").addEventListener("click", () => {
|
||||
hideKeyboardToolbar();
|
||||
activeBlur();
|
||||
sidebarElement.style.transform = "translateX(0px)";
|
||||
const type = sidebarElement.querySelector(".toolbar--border .toolbar__icon--active").getAttribute("data-type");
|
||||
if (type === "sidebar-outline-tab") {
|
||||
outline.update();
|
||||
window.siyuan.mobile.docks.outline.update();
|
||||
} else if (type === "sidebar-backlink-tab") {
|
||||
backlink.update();
|
||||
window.siyuan.mobile.docks.backlink.update();
|
||||
} else if (type === "sidebar-bookmark-tab") {
|
||||
bookmark.update();
|
||||
window.siyuan.mobile.docks.bookmark.update();
|
||||
} else if (type === "sidebar-tag-tab") {
|
||||
tag.update();
|
||||
window.siyuan.mobile.docks.tag.update();
|
||||
}
|
||||
});
|
||||
// 用 touchstart 会导致键盘不收起
|
||||
|
|
|
@ -166,6 +166,14 @@ openTab = (options: {
|
|||
};
|
||||
/// #endif
|
||||
|
||||
const getModelByDockType = (type: TDock | string) => {
|
||||
/// #if MOBILE
|
||||
return window.siyuan.mobile.docks[type];
|
||||
/// #else
|
||||
return getDockByType(type).data[type];
|
||||
/// #endif
|
||||
}
|
||||
|
||||
export const API = {
|
||||
adaptHotkey: updateHotkeyTip,
|
||||
confirm: confirmDialog,
|
||||
|
@ -176,7 +184,7 @@ export const API = {
|
|||
fetchGet,
|
||||
getFrontend,
|
||||
getBackend,
|
||||
getDockByType,
|
||||
getModelByDockType,
|
||||
openTab,
|
||||
openWindow,
|
||||
openMobileFileById,
|
||||
|
|
9
app/src/types/index.d.ts
vendored
9
app/src/types/index.d.ts
vendored
|
@ -376,7 +376,14 @@ interface ISiyuan {
|
|||
mobile?: {
|
||||
editor?: import("../protyle").Protyle
|
||||
popEditor?: import("../protyle").Protyle
|
||||
files?: import("../mobile/dock/MobileFiles").MobileFiles
|
||||
docks?: {
|
||||
outline: import("../mobile/dock/MobileOutline").MobileOutline | null,
|
||||
file: import("../mobile/dock/MobileFiles").MobileFiles | null,
|
||||
bookmark: import("../mobile/dock/MobileBookmarks").MobileBookmarks | null,
|
||||
tag: import("../mobile/dock/MobileTags").MobileTags | null,
|
||||
backlink: import("../mobile/dock/MobileBacklinks").MobileBacklinks | null,
|
||||
inbox: import("../layout/dock/Inbox").Inbox | null,
|
||||
} & { [key: string]: import("../layout/Model").Model | boolean };
|
||||
},
|
||||
user?: {
|
||||
userId: string
|
||||
|
|
Loading…
Add table
Reference in a new issue