Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/14135

Vanessa36386eaea8a6
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 6c8efeda30..95b826041b 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -772,7 +772,9 @@ export class Files extends Model {
if (!liElement) {
const dirname = pathPosix().dirname(currentPath);
if (dirname === "/") {
- this.getLeaf(treeElement.firstElementChild, notebookId, true);
+ if (treeElement.firstElementChild.querySelector(".b3-list-item__arrow--open")) {
+ this.getLeaf(treeElement.firstElementChild, notebookId, true);
+ }
break;
} else {
currentPath = dirname + ".sy";
diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts
index fefb5d3761..93f220b14e 100644
--- a/app/src/mobile/dock/MobileFiles.ts
+++ b/app/src/mobile/dock/MobileFiles.ts
@@ -77,7 +77,7 @@ export class MobileFiles extends Model {
case "createdailynote":
case "heading2doc":
case "li2doc":
- this.onMkdir(data.data);
+ this.selectItem(data.data.box.id, data.data.path);
break;
case "renamenotebook":
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) {
const dirname = pathPosix().dirname(currentPath);
if (dirname === "/") {
- currentPath = dirname;
+ if (treeElement.firstElementChild.querySelector(".b3-list-item__arrow--open")) {
+ this.getLeaf(treeElement.firstElementChild, notebookId, true);
+ }
+ break;
} else {
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) {
// "doc2heading" 后删除文件或挂载帮助文档前的 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");
- 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");
liElement.nextElementSibling?.remove();
this.getOpenPaths();
@@ -660,7 +625,7 @@ export class MobileFiles extends Model {
}
fetchPost("/api/filetree/listDocsByPath", {
notebook: notebookId,
- path: liElement.getAttribute("data-path")
+ path: liElement.getAttribute("data-path"),
}, response => {
if (response.data.path === "/" && response.data.files.length === 0) {
showMessage(window.siyuan.languages.emptyContent);