Browse Source

:bug: 自定义表情搜索报错 Fix https://github.com/siyuan-note/siyuan/issues/5883

Liang Ding 2 years ago
parent
commit
cbfec5172d
1 changed files with 12 additions and 7 deletions
  1. 12 7
      app/src/emoji/index.ts

+ 12 - 7
app/src/emoji/index.ts

@@ -25,13 +25,18 @@ export const unicode2Emoji = (unicode: string, assic = false) => {
     if (unicode.indexOf(".") > -1) {
     if (unicode.indexOf(".") > -1) {
         emoji = `<img src="/emojis/${unicode}"/>`;
         emoji = `<img src="/emojis/${unicode}"/>`;
     } else if (isMobile() || window.siyuan.config.appearance.nativeEmoji || assic) {
     } else if (isMobile() || window.siyuan.config.appearance.nativeEmoji || assic) {
-        unicode.split("-").forEach(item => {
-            if (item.length < 5) {
-                emoji += String.fromCodePoint(parseInt("0" + item, 16));
-            } else {
-                emoji += String.fromCodePoint(parseInt(item, 16));
-            }
-        });
+        try {
+            unicode.split("-").forEach(item => {
+                if (item.length < 5) {
+                    emoji += String.fromCodePoint(parseInt("0" + item, 16));
+                } else {
+                    emoji += String.fromCodePoint(parseInt(item, 16));
+                }
+            });
+        } catch (e) {
+            // 自定义表情搜索报错 https://github.com/siyuan-note/siyuan/issues/5883
+            // 这里忽略错误不做处理
+        }
     } else {
     } else {
         emoji = `<svg class="custom-icon"><use xlink:href="#icon-${unicode}"></use></svg>`;
         emoji = `<svg class="custom-icon"><use xlink:href="#icon-${unicode}"></use></svg>`;
     }
     }