mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-11-06 10:43:37 +08:00
perf: 同步主分支代码
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { App } from "vue";
|
||||
import { App, defineComponent } from "vue";
|
||||
import icon from "./src/Icon.vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import { iconComponents } from "/@/plugins/element-plus";
|
||||
|
||||
export const Icon = Object.assign(icon, {
|
||||
install(app: App) {
|
||||
@@ -10,3 +12,37 @@ export const Icon = Object.assign(icon, {
|
||||
export default {
|
||||
Icon
|
||||
};
|
||||
/**
|
||||
* find icon component
|
||||
* @param icon icon图标
|
||||
* @returns component
|
||||
*/
|
||||
export function findIconReg(icon: string) {
|
||||
const faReg = /^fa-/;
|
||||
if (faReg.test(icon)) {
|
||||
return findIcon(icon.split(faReg)[1]);
|
||||
} else {
|
||||
return findIcon(icon, false);
|
||||
}
|
||||
}
|
||||
export function findIcon(icon: String, isFa: Boolean = true) {
|
||||
if (isFa) {
|
||||
return defineComponent({
|
||||
name: "FaIcon",
|
||||
data() {
|
||||
return { icon: icon };
|
||||
},
|
||||
components: { FontAwesomeIcon },
|
||||
template: `<font-awesome-icon :icon="icon" />`
|
||||
});
|
||||
} else {
|
||||
const components = iconComponents.filter(
|
||||
component => component.name === icon
|
||||
);
|
||||
if (components.length > 0) {
|
||||
return components[0];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user