This commit is contained in:
Vanessa 2023-05-18 10:23:19 +08:00
parent 4e3fb4bbf5
commit 0d9fcf8245

View file

@ -9,9 +9,7 @@ import {needSubscribe} from "../../util/needSubscribe";
import {MenuItem} from "../../menus/Menu"; import {MenuItem} from "../../menus/Menu";
import {confirmDialog} from "../../dialog/confirmDialog"; import {confirmDialog} from "../../dialog/confirmDialog";
import {replaceFileName} from "../../editor/rename"; import {replaceFileName} from "../../editor/rename";
import {escapeHtml} from "../../util/escape"; import {getDisplayName, movePathTo, pathPosix} from "../../util/pathName";
import {unicode2Emoji} from "../../emoji";
import {Constants} from "../../constants";
export class Inbox extends Model { export class Inbox extends Model {
private element: Element; private element: Element;
@ -89,7 +87,6 @@ export class Inbox extends Model {
const type = target.getAttribute("data-type"); const type = target.getAttribute("data-type");
if (type === "min") { if (type === "min") {
getDockByType("inbox").toggleModel("inbox"); getDockByType("inbox").toggleModel("inbox");
event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
} else if (type === "selectall") { } else if (type === "selectall") {
@ -106,6 +103,7 @@ export class Inbox extends Model {
}); });
} }
countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`; countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`;
window.siyuan.menus.menu.remove();
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "select") { } else if (type === "select") {
@ -117,6 +115,7 @@ export class Inbox extends Model {
} }
countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`; countElement.innerHTML = `${this.selectIds.length.toString()}/${this.pageCount.toString()}`;
selectAllElement.checked = this.element.lastElementChild.querySelectorAll("input:checked").length === this.element.lastElementChild.querySelectorAll(".b3-list-item").length; selectAllElement.checked = this.element.lastElementChild.querySelectorAll("input:checked").length === this.element.lastElementChild.querySelectorAll(".b3-list-item").length;
window.siyuan.menus.menu.remove();
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "previous") { } else if (type === "previous") {
@ -124,7 +123,6 @@ export class Inbox extends Model {
this.currentPage--; this.currentPage--;
this.update(); this.update();
} }
event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
} else if (type === "next") { } else if (type === "next") {
@ -132,12 +130,10 @@ export class Inbox extends Model {
this.currentPage++; this.currentPage++;
this.update(); this.update();
} }
event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
} else if (type === "back") { } else if (type === "back") {
this.back(); this.back();
event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
} else if (type === "more") { } else if (type === "more") {
@ -155,7 +151,6 @@ export class Inbox extends Model {
detailsElement.classList.remove("fn__none"); detailsElement.classList.remove("fn__none");
detailsElement.scrollTop = 0; detailsElement.scrollTop = 0;
this.element.lastElementChild.classList.add("fn__none"); this.element.lastElementChild.classList.add("fn__none");
event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
} }
@ -173,7 +168,7 @@ export class Inbox extends Model {
this.element.lastElementChild.classList.remove("fn__none"); this.element.lastElementChild.classList.remove("fn__none");
} }
private genDetail(data:IInbox) { private genDetail(data: IInbox) {
let linkHTML = ""; let linkHTML = "";
/// #if MOBILE /// #if MOBILE
if (data.shorthandURL) { if (data.shorthandURL) {
@ -227,26 +222,19 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
} }
} }
}).element); }).element);
const submenu: IMenu[] = []; let ids: string[] = [];
window.siyuan.notebooks.forEach((item) => {
if (!item.closed) {
submenu.push({
iconHTML: `${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_NOTE, false, "b3-menu__icon", true)}`,
label: escapeHtml(item.name),
click: () => {
if (detailsElement.classList.contains("fn__none")) { if (detailsElement.classList.contains("fn__none")) {
this.move(item.id); ids = this.selectIds;
} else { } else {
this.move(item.id, detailsElement.getAttribute("data-id")); ids = [detailsElement.getAttribute("data-id")];
} }
} if (ids.length > 0) {
});
}
});
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.move, label: window.siyuan.languages.move,
icon: "iconMove", icon: "iconMove",
submenu click: () => {
this.move(ids);
}
}).element); }).element);
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.remove, label: window.siyuan.languages.remove,
@ -261,7 +249,9 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
}); });
} }
}).element); }).element);
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); }
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16});
window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡 window.siyuan.menus.menu.element.style.zIndex = "221"; // 移动端被右侧栏遮挡
} }
@ -289,24 +279,19 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
}); });
} }
private move(notebookId: string, id?: string) { private move(ids: string[]) {
let ids: string[]; movePathTo((toPath, toNotebook) => {
if (id) {
ids = [id];
} else {
ids = this.selectIds;
}
ids.forEach(item => { ids.forEach(item => {
fetchPost("/api/filetree/createDoc", { fetchPost("/api/filetree/createDoc", {
notebook: notebookId, notebook: toNotebook[0],
path: `/${Lute.NewNodeID()}.sy`, path: pathPosix().join(getDisplayName(toPath[0], false, true), Lute.NewNodeID() + ".sy"),
title: replaceFileName(this.data[item].shorthandTitle), title: replaceFileName(this.data[item].shorthandTitle),
md: this.data[item].shorthandContent, md: this.data[item].shorthandContent,
}, () => { }, () => {
this.remove(item); this.remove(item);
}); });
}); });
});
} }
private update() { private update() {