Pārlūkot izejas kodu

:art: fix https://github.com/siyuan-note/siyuan/issues/5135

Vanessa 3 gadi atpakaļ
vecāks
revīzija
bdc4428e99

+ 1 - 0
app/src/constants.ts

@@ -339,6 +339,7 @@ export abstract class Constants {
 </svg>`;
     public static readonly SIYUAN_IMAGE_FILE: string = "1f4c4";
     public static readonly SIYUAN_IMAGE_NOTE: string = "1f5c3";
+    public static readonly SIYUAN_IMAGE_FOLDER: string = "1f4d1";
 
     // assets
     public static readonly SIYUAN_ASSETS_IMAGE: string[] = [".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg"];

+ 1 - 1
app/src/emoji/index.ts

@@ -414,7 +414,7 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil
         }
     }
     if (emojiElement) {
-        emojiElement.innerHTML = unicode2Emoji(unicode || (icon === "iconFile" ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_NOTE));
+        emojiElement.innerHTML = unicode2Emoji(unicode || (icon === "iconFile" ? (emojiElement.previousElementSibling.classList.contains("fn__hidden") ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER) : Constants.SIYUAN_IMAGE_NOTE));
     }
     if (icon !== "iconFile") {
         setNoteBook();

+ 17 - 1
app/src/layout/dock/Files.ts

@@ -550,6 +550,10 @@ export class Files extends Model {
         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(Constants.SIYUAN_IMAGE_FILE)) {
+                emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)
+            }
             if (targetElement.nextElementSibling && targetElement.nextElementSibling.tagName === "UL") {
                 targetElement.nextElementSibling.remove();
             }
@@ -593,6 +597,10 @@ export class Files extends Model {
                     const iconElement = parentElement.querySelector("svg");
                     iconElement.classList.remove("b3-list-item__arrow--open");
                     iconElement.parentElement.classList.add("fn__hidden");
+                    const emojiElement = iconElement.parentElement.nextElementSibling;
+                    if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) {
+                        emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE);
+                    }
                 }
                 targetElement.parentElement.remove();
             } else {
@@ -667,6 +675,10 @@ export class Files extends Model {
                 if (sourceElement.parentElement.previousElementSibling) {
                     sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__toggle").classList.add("fn__hidden");
                     sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
+                    const emojiElement = sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__icon");
+                    if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) {
+                        emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE);
+                    }
                 }
                 sourceElement.parentElement.remove();
             } else {
@@ -677,6 +689,10 @@ export class Files extends Model {
         // 更新移动到的新文件夹
         if (newElement) {
             newElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden");
+            const emojiElement = newElement.querySelector(".b3-list-item__icon");
+            if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) {
+                emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER);
+            }
             const arrowElement = newElement.querySelector(".b3-list-item__arrow");
             if (arrowElement.classList.contains("b3-list-item__arrow--open")) {
                 arrowElement.classList.remove("b3-list-item__arrow--open");
@@ -831,7 +847,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
     <span style="padding-left: ${(item.path.split("/").length - 1) * 16}px" class="b3-list-item__toggle b3-list-item__toggle--hl${item.subFileCount === 0 ? " fn__hidden" : ""}">
         <svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
     </span>
-    <span class="b3-list-item__icon b3-tooltips b3-tooltips__n" aria-label="${window.siyuan.languages.changeIcon}">${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE)}</span>
+    <span class="b3-list-item__icon b3-tooltips b3-tooltips__n" aria-label="${window.siyuan.languages.changeIcon}">${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER))}</span>
     <span class="b3-list-item__text">${getDisplayName(item.name, true, true)}</span>
     <span data-type="more-file" class="b3-list-item__action b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.more}">
         <svg><use xlink:href="#iconMore"></use></svg>

+ 17 - 1
app/src/mobile/util/MobileFiles.ts

@@ -383,6 +383,10 @@ export class MobileFiles extends Model {
                 if (sourceElement.parentElement.previousElementSibling) {
                     sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__toggle").classList.add("fn__hidden");
                     sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
+                    const emojiElement = sourceElement.parentElement.previousElementSibling.querySelector(".b3-list-item__icon");
+                    if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) {
+                        emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE);
+                    }
                 }
                 sourceElement.parentElement.remove();
             } else {
@@ -392,6 +396,10 @@ export class MobileFiles extends Model {
         const newElement = this.element.querySelector(`[data-url="${data.toNotebook}"] li[data-path="${data.toPath}"]`) as HTMLElement;
         // 重新展开移动到的新文件夹
         if (newElement) {
+            const emojiElement = newElement.querySelector(".b3-list-item__icon");
+            if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FILE)) {
+                emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER);
+            }
             newElement.querySelector(".b3-list-item__toggle").classList.remove("fn__hidden");
             newElement.querySelector(".b3-list-item__arrow").classList.remove("b3-list-item__arrow--open");
             if (newElement.nextElementSibling && newElement.nextElementSibling.tagName === "UL") {
@@ -428,6 +436,10 @@ export class MobileFiles extends Model {
         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(Constants.SIYUAN_IMAGE_FILE)) {
+                emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)
+            }
             if (targetElement.nextElementSibling && targetElement.nextElementSibling.tagName === "UL") {
                 targetElement.nextElementSibling.remove();
             }
@@ -478,6 +490,10 @@ export class MobileFiles extends Model {
                     const iconElement = parentElement.querySelector("svg");
                     iconElement.classList.remove("b3-list-item__arrow--open");
                     iconElement.parentElement.classList.add("fn__hidden");
+                    const emojiElement = iconElement.parentElement.nextElementSibling;
+                    if (emojiElement.innerHTML === unicode2Emoji(Constants.SIYUAN_IMAGE_FOLDER)) {
+                        emojiElement.innerHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE);
+                    }
                 }
                 targetElement.parentElement.remove();
             } else {
@@ -677,7 +693,7 @@ class="b3-list-item" data-path="${item.path}">
     <span style="padding-left: ${(item.path.split("/").length - 1) * 16}px" class="b3-list-item__toggle${item.subFileCount === 0 ? " fn__hidden" : ""}">
         <svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
     </span>
-    <span class="b3-list-item__icon">${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE)}</span>
+    <span class="b3-list-item__icon">${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER))}</span>
     <span class="b3-list-item__text">${getDisplayName(item.name, true, true)}</span>
     <span data-type="more-file" class="b3-list-item__action b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.more}">
         <svg><use xlink:href="#iconMore"></use></svg>