This commit is contained in:
Vanessa 2023-04-02 11:40:27 +08:00
parent 96a03115f1
commit fb9d45e7c2
3 changed files with 28 additions and 34 deletions

View file

@ -998,7 +998,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
}
}).element);
if (!window.siyuan.config.readonly) {
sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
window.siyuan.config.fileTree.sort = sort;
fetchPost("/api/setting/setFiletree", {
sort: window.siyuan.config.fileTree.sort,
@ -1013,6 +1013,12 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
});
});
});
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconSort",
label: window.siyuan.languages.sort,
type: "submenu",
submenu:subMenu,
}).element);
}
return window.siyuan.menus.menu;
}

View file

@ -94,7 +94,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
});
}
}).element);
sortMenu("notebook", parseInt(liElement.parentElement.getAttribute("data-sortmode")), (sort) => {
const subMenu = sortMenu("notebook", parseInt(liElement.parentElement.getAttribute("data-sortmode")), (sort) => {
fetchPost("/api/notebook/setNotebookConf", {
notebook: notebookId,
conf: {
@ -117,6 +117,12 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
});
return true;
});
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconSort",
label: window.siyuan.languages.sort,
type: "submenu",
submenu: subMenu,
}).element);
}
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.riffCard,
@ -514,7 +520,7 @@ const genImportMenu = (notebookId: string, pathString: string) => {
};
export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, clickEvent: (sort: number) => void) => {
const submenu: IMenu[] = [{
const sortMenu: IMenu[] = [{
icon: sortMode === 0 ? "iconSelect" : undefined,
label: window.siyuan.languages.fileNameASC,
click: () => {
@ -606,7 +612,7 @@ export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, click
}
}];
if (type === "notebook") {
submenu.push({
sortMenu.push({
icon: sortMode === 15 ? "iconSelect" : undefined,
label: window.siyuan.languages.sortByFiletree,
click: () => {
@ -614,10 +620,5 @@ export const sortMenu = (type: "notebooks" | "notebook", sortMode: number, click
}
});
}
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconSort",
label: window.siyuan.languages.sort,
type: "submenu",
submenu,
}).element);
return sortMenu;
};

View file

@ -12,7 +12,7 @@ import {unicode2Emoji} from "../../emoji";
import {mountHelp, newNotebook} from "../../util/mount";
import {confirmDialog} from "../../dialog/confirmDialog";
import {newFile} from "../../util/newFile";
import {isMobile} from "../../util/functions";
import {MenuItem} from "../../menus/Menu";
export class MobileFiles extends Model {
public element: HTMLElement;
@ -118,7 +118,7 @@ export class MobileFiles extends Model {
event.preventDefault();
break;
} else if (type === "sort") {
this.genSort(event);
this.genSort();
event.preventDefault();
event.stopPropagation();
break;
@ -167,8 +167,6 @@ export class MobileFiles extends Model {
} else if (target.classList.contains("b3-list-item__action")) {
const type = target.getAttribute("data-type");
const pathString = target.parentElement.getAttribute("data-path");
const x = (event instanceof TouchEvent) ? event.touches[0].clientX : event.clientX;
const y = (event instanceof TouchEvent) ? event.touches[0].clientY : event.clientY;
const ulElement = hasTopClosestByTag(target, "UL");
if (ulElement) {
const notebookId = ulElement.getAttribute("data-url");
@ -176,28 +174,14 @@ export class MobileFiles extends Model {
if (type === "new") {
newFile(notebookId, pathString);
} else if (type === "more-root") {
initNavigationMenu(target.parentElement)
if (isMobile()) {
window.siyuan.menus.menu.fullscreen("bottom");
} else {
window.siyuan.menus.menu.popup({
x,
y
});
}
initNavigationMenu(target.parentElement);
window.siyuan.menus.menu.fullscreen("bottom");
window.siyuan.menus.menu.element.style.zIndex = "310";
}
}
if (type === "more-file") {
initFileMenu(notebookId, pathString, target.parentElement);
if (isMobile()) {
window.siyuan.menus.menu.fullscreen("bottom");
} else {
window.siyuan.menus.menu.popup({
x,
y
});
}
window.siyuan.menus.menu.fullscreen("bottom");
window.siyuan.menus.menu.element.style.zIndex = "310";
}
}
@ -227,9 +211,9 @@ export class MobileFiles extends Model {
}
}
private genSort(event: MouseEvent) {
private genSort() {
window.siyuan.menus.menu.remove();
sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
const subMenu = sortMenu("notebooks", window.siyuan.config.fileTree.sort, (sort: number) => {
window.siyuan.config.fileTree.sort = sort;
fetchPost("/api/setting/setFiletree", {
sort: window.siyuan.config.fileTree.sort,
@ -244,8 +228,11 @@ export class MobileFiles extends Model {
});
});
});
subMenu.forEach((item) => {
window.siyuan.menus.menu.append(new MenuItem(item).element);
});
window.siyuan.menus.menu.fullscreen("bottom");
window.siyuan.menus.menu.element.style.zIndex = "310";
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
}
private genNotebook(item: INotebook) {