From 6c90f42da03c304d685f582d715c6fb6de31b5fb Mon Sep 17 00:00:00 2001
From: BiggerRain <15911122312@163.COM>
Date: Tue, 8 Apr 2025 22:58:53 +0800
Subject: [PATCH] feat: add font icon (#342)
* feat: add font icon
* docs: update notes
* chore: cleanup the uncessary change
---
docs/content.en/docs/release-notes/_index.md | 2 +-
public/assets/fonts/icons/iconfont.js | 1 +
src/components/Common/Icons/ItemIcon.tsx | 7 +++++++
3 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 public/assets/fonts/icons/iconfont.js
diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md
index 3097fcb0..cbd4ba81 100644
--- a/docs/content.en/docs/release-notes/_index.md
+++ b/docs/content.en/docs/release-notes/_index.md
@@ -14,8 +14,8 @@ Information about release notes of Coco Server is provided here.
### Features
- Linux support for application search #330
-
- Add shortcuts to most icon buttons #334
+- Add font icon for search list #342
### Bug fix
diff --git a/public/assets/fonts/icons/iconfont.js b/public/assets/fonts/icons/iconfont.js
new file mode 100644
index 00000000..a916eaaf
--- /dev/null
+++ b/public/assets/fonts/icons/iconfont.js
@@ -0,0 +1 @@
+window._iconfont_svg_string_4878526='',(c=>{var l=(h=(h=document.getElementsByTagName("script"))[h.length-1]).getAttribute("data-injectcss"),h=h.getAttribute("data-disable-injectsvg");if(!h){var t,a,F,o,p,i=function(l,h){h.parentNode.insertBefore(l,h)};if(l&&!c.__iconfont__svg__cssinject__){c.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}t=function(){var l,h=document.createElement("div");h.innerHTML=c._iconfont_svg_string_4878526,(h=h.getElementsByTagName("svg")[0])&&(h.setAttribute("aria-hidden","true"),h.style.position="absolute",h.style.width=0,h.style.height=0,h.style.overflow="hidden",h=h,(l=document.body).firstChild?i(h,l.firstChild):l.appendChild(h))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),t()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(F=t,o=c.document,p=!1,v(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,d())})}function d(){p||(p=!0,F())}function v(){try{o.documentElement.doScroll("left")}catch(l){return void setTimeout(v,50)}d()}})(window);
\ No newline at end of file
diff --git a/src/components/Common/Icons/ItemIcon.tsx b/src/components/Common/Icons/ItemIcon.tsx
index b0ce90a6..74bf3e16 100644
--- a/src/components/Common/Icons/ItemIcon.tsx
+++ b/src/components/Common/Icons/ItemIcon.tsx
@@ -5,6 +5,7 @@ import IconWrapper from "./IconWrapper";
import ThemedIcon from "./ThemedIcon";
import { useFindConnectorIcon } from "@/hooks/useFindConnectorIcon";
import { useAppStore } from "@/stores/appStore";
+import FontIcon from "./FontIcon";
interface ItemIconProps {
item: any;
@@ -23,6 +24,12 @@ const ItemIcon = React.memo(function ItemIcon({
// console.log("connectorSource", connectorSource);
const icons = connectorSource?.assets?.icons || {};
+ if (item?.icon?.startsWith("font_")) {
+ return (
+
+ );
+ }
+
// If the icon is a valid base64-encoded image
const isBase64 = item?.icon?.startsWith("data:image/");
if (isBase64) {