mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
refactor: 重构图标模块,使用`@iconify/json`替换不再维护更新的`@iconify-icons/*`依赖,优化使用体验,确保图标库可持续更新并支持`Tree-shaking`
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { h, defineComponent } from "vue";
|
||
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
||
|
||
// Iconify Icon在Vue里本地使用(用于内网环境)
|
||
export default defineComponent({
|
||
name: "IconifyIconOffline",
|
||
components: { IconifyIcon },
|
||
props: {
|
||
icon: {
|
||
default: null
|
||
}
|
||
},
|
||
render() {
|
||
if (typeof this.icon === "object") addIcon(this.icon, this.icon);
|
||
const attrs = this.$attrs;
|
||
if (typeof this.icon === "string") {
|
||
return h(
|
||
IconifyIcon,
|
||
{
|
||
icon: this.icon,
|
||
"aria-hidden": false,
|
||
style: attrs?.style
|
||
? Object.assign(attrs.style, { outline: "none" })
|
||
: { outline: "none" },
|
||
...attrs
|
||
},
|
||
{
|
||
default: () => []
|
||
}
|
||
);
|
||
} else {
|
||
return h(
|
||
this.icon,
|
||
{
|
||
"aria-hidden": false,
|
||
style: attrs?.style
|
||
? Object.assign(attrs.style, { outline: "none" })
|
||
: { outline: "none" },
|
||
...attrs
|
||
},
|
||
{
|
||
default: () => []
|
||
}
|
||
);
|
||
}
|
||
}
|
||
});
|