瀏覽代碼

feat: Support proxy group icon

MystiPanda 1 年之前
父節點
當前提交
b08333dccd
共有 3 個文件被更改,包括 21 次插入4 次删除
  1. 12 0
      src/components/proxy/proxy-render.tsx
  2. 8 4
      src/components/test/test-item.tsx
  3. 1 0
      src/services/types.d.ts

+ 12 - 0
src/components/proxy/proxy-render.tsx

@@ -37,6 +37,18 @@ export const ProxyRender = (props: RenderProps) => {
         dense
         onClick={() => onHeadState(group.name, { open: !headState?.open })}
       >
+        {group.icon && group.icon.trim().startsWith("http") && (
+          <img src={group.icon} height="40px" style={{ marginRight: "8px" }} />
+        )}
+        {group.icon && group.icon.trim().startsWith("data") && (
+          <img src={group.icon} height="40px" style={{ marginRight: "8px" }} />
+        )}
+        {group.icon && group.icon.trim().startsWith("<svg") && (
+          <img
+            src={`data:image/svg+xml;base64,${btoa(group.icon)}`}
+            height="40px"
+          />
+        )}
         <ListItemText
           primary={group.name}
           secondary={

+ 8 - 4
src/components/test/test-item.tsx

@@ -102,11 +102,15 @@ export const TestItem = (props: Props) => {
           {...attributes}
           {...listeners}
         >
-          {icon ? (
+          {icon && icon.trim() !== "" ? (
             <Box sx={{ display: "flex", justifyContent: "center" }}>
-              {icon?.trim().startsWith("http") ? (
-                <img src={icon} height="40px" />
-              ) : (
+              {icon.trim().startsWith("http") && (
+                <img src={icon} height="40px" style={{ marginRight: "8px" }} />
+              )}
+              {icon.trim().startsWith("data") && (
+                <img src={icon} height="40px" style={{ marginRight: "8px" }} />
+              )}
+              {icon.trim().startsWith("<svg") && (
                 <img
                   src={`data:image/svg+xml;base64,${btoa(icon)}`}
                   height="40px"

+ 1 - 0
src/services/types.d.ts

@@ -53,6 +53,7 @@ interface IProxyItem {
   all?: string[];
   now?: string;
   hidden?: boolean;
+  icon?: string;
   provider?: string; // 记录是否来自provider
 }