mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
b3105faf65
commit
36386eaea8
2 changed files with 11 additions and 44 deletions
|
|
@ -772,7 +772,9 @@ export class Files extends Model {
|
||||||
if (!liElement) {
|
if (!liElement) {
|
||||||
const dirname = pathPosix().dirname(currentPath);
|
const dirname = pathPosix().dirname(currentPath);
|
||||||
if (dirname === "/") {
|
if (dirname === "/") {
|
||||||
this.getLeaf(treeElement.firstElementChild, notebookId, true);
|
if (treeElement.firstElementChild.querySelector(".b3-list-item__arrow--open")) {
|
||||||
|
this.getLeaf(treeElement.firstElementChild, notebookId, true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
currentPath = dirname + ".sy";
|
currentPath = dirname + ".sy";
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ export class MobileFiles extends Model {
|
||||||
case "createdailynote":
|
case "createdailynote":
|
||||||
case "heading2doc":
|
case "heading2doc":
|
||||||
case "li2doc":
|
case "li2doc":
|
||||||
this.onMkdir(data.data);
|
this.selectItem(data.data.box.id, data.data.path);
|
||||||
break;
|
break;
|
||||||
case "renamenotebook":
|
case "renamenotebook":
|
||||||
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = data.data.name;
|
this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = data.data.name;
|
||||||
|
|
@ -285,7 +285,10 @@ export class MobileFiles extends Model {
|
||||||
if (!liElement) {
|
if (!liElement) {
|
||||||
const dirname = pathPosix().dirname(currentPath);
|
const dirname = pathPosix().dirname(currentPath);
|
||||||
if (dirname === "/") {
|
if (dirname === "/") {
|
||||||
currentPath = dirname;
|
if (treeElement.firstElementChild.querySelector(".b3-list-item__arrow--open")) {
|
||||||
|
this.getLeaf(treeElement.firstElementChild, notebookId, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
currentPath = dirname + ".sy";
|
currentPath = dirname + ".sy";
|
||||||
}
|
}
|
||||||
|
|
@ -409,44 +412,6 @@ export class MobileFiles extends Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onMkdir(data: {
|
|
||||||
box: INotebook,
|
|
||||||
path: string,
|
|
||||||
}) {
|
|
||||||
let targetElement = this.element.querySelector(`ul[data-url="${data.box.id}"]`);
|
|
||||||
let folderPath = pathPosix().dirname(data.path) + ".sy";
|
|
||||||
while (folderPath !== "/") {
|
|
||||||
targetElement = targetElement.querySelector(`li[data-path="${folderPath}"]`);
|
|
||||||
if (targetElement) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
targetElement = this.element.querySelector(`ul[data-url="${data.box.id}"]`);
|
|
||||||
// 向上查找
|
|
||||||
folderPath = pathPosix().dirname(folderPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (targetElement.tagName === "UL") {
|
|
||||||
if (pathPosix().dirname(data.path) === "/") {
|
|
||||||
targetElement = targetElement.firstElementChild as HTMLElement;
|
|
||||||
} else {
|
|
||||||
targetElement = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetElement) {
|
|
||||||
targetElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
|
|
||||||
targetElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden");
|
|
||||||
const emojiElement = targetElement.querySelector(".b3-list-item__icon");
|
|
||||||
if (emojiElement.innerHTML === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) {
|
|
||||||
emojiElement.innerHTML = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder);
|
|
||||||
}
|
|
||||||
if (targetElement.nextElementSibling && targetElement.nextElementSibling.tagName === "UL") {
|
|
||||||
targetElement.nextElementSibling.remove();
|
|
||||||
}
|
|
||||||
this.getLeaf(targetElement, data.box.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private onRemove(data: IWebSocketData) {
|
private onRemove(data: IWebSocketData) {
|
||||||
// "doc2heading" 后删除文件或挂载帮助文档前的 unmount
|
// "doc2heading" 后删除文件或挂载帮助文档前的 unmount
|
||||||
if (data.cmd === "unmount") {
|
if (data.cmd === "unmount") {
|
||||||
|
|
@ -650,9 +615,9 @@ export class MobileFiles extends Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLeaf(liElement: Element, notebookId: string) {
|
public getLeaf(liElement: Element, notebookId: string, focusUpdate = false) {
|
||||||
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
|
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
|
||||||
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
|
if (toggleElement.classList.contains("b3-list-item__arrow--open") && !focusUpdate) {
|
||||||
toggleElement.classList.remove("b3-list-item__arrow--open");
|
toggleElement.classList.remove("b3-list-item__arrow--open");
|
||||||
liElement.nextElementSibling?.remove();
|
liElement.nextElementSibling?.remove();
|
||||||
this.getOpenPaths();
|
this.getOpenPaths();
|
||||||
|
|
@ -660,7 +625,7 @@ export class MobileFiles extends Model {
|
||||||
}
|
}
|
||||||
fetchPost("/api/filetree/listDocsByPath", {
|
fetchPost("/api/filetree/listDocsByPath", {
|
||||||
notebook: notebookId,
|
notebook: notebookId,
|
||||||
path: liElement.getAttribute("data-path")
|
path: liElement.getAttribute("data-path"),
|
||||||
}, response => {
|
}, response => {
|
||||||
if (response.data.path === "/" && response.data.files.length === 0) {
|
if (response.data.path === "/" && response.data.files.length === 0) {
|
||||||
showMessage(window.siyuan.languages.emptyContent);
|
showMessage(window.siyuan.languages.emptyContent);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue