Skip to content

feat: useRenderIcon通用图标函数支持渲染SVG字符串和图片URL#1284

Open
xiaoxian521 wants to merge 1 commit into
mainfrom
feat-perf/useRenderIcon
Open

feat: useRenderIcon通用图标函数支持渲染SVG字符串和图片URL#1284
xiaoxian521 wants to merge 1 commit into
mainfrom
feat-perf/useRenderIcon

Conversation

@xiaoxian521
Copy link
Copy Markdown
Member

@xiaoxian521 xiaoxian521 commented Apr 16, 2026

// mock/asyncRoutes.ts

const systemMonitorRouter = {
  path: "/monitor",
  meta: {
    icon: "ep:monitor",
    title: "menus.pureSysMonitor",
    rank: monitor
  },
  children: [
    {
      path: "/monitor/online-user",
      component: "monitor/online/index",
      name: "OnlineUser",
      meta: {
        icon: "ri:user-voice-line",
        title: "menus.pureOnlineUser",
        roles: ["admin"]
      }
    },
    {
      path: "/monitor/login-logs",
      component: "monitor/logs/login/index",
      name: "LoginLog",
      meta: {
        icon: "ri:window-line",
        title: "menus.pureLoginLog",
        roles: ["admin"]
      }
    },
    {
      path: "/monitor/operation-logs",
      component: "monitor/logs/operation/index",
      name: "OperationLog",
      meta: {
        // 支持后端直接返回 SVG 原始字符串作为菜单图标
        icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12h2a8 8 0 1 0 1.865-5.135L8 9H2V3l2.447 2.446A9.98 9.98 0 0 1 12 2m1 5v4.585l3.243 3.243l-1.415 1.415L11 12.413V7z"/></svg>`,
        title: "menus.pureOperationLog",
        roles: ["admin"]
      }
    },
    {
      path: "/monitor/system-logs",
      component: "monitor/logs/system/index",
      name: "SystemLog",
      meta: {
        // 支持图片 URL
        icon: "https://avatars.githubusercontent.com/u/106637267",
        title: "menus.pureSystemLog",
        roles: ["admin"]
      }
    }
  ]
};

效果如下:

image image image

@xiaoxian521 xiaoxian521 added PR::WIP 正在开发中 v7.1.0 7.1.0版本 labels Apr 16, 2026
@xiaoxian521 xiaoxian521 linked an issue Apr 16, 2026 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR::WIP 正在开发中 v7.1.0 7.1.0版本

Projects

None yet

Development

Successfully merging this pull request may close these issues.

支持后端返回 SVG 类型菜单 Icon

1 participant