import { IPSSysImage } from '@ibiz-template/model'; import { useNamespace } from '@ibiz-template/vue-util'; import { defineComponent, PropType, VNode, computed } from 'vue'; import '@ibiz-template/theme/style/components/common/app-icon/app-icon.scss'; import { renderCompatibleIE } from '../../../ie-util'; export const AppIcon = defineComponent({ name: 'AppIcon', props: { icon: { type: Object as PropType, }, size: { type: String as PropType<'small' | 'medium' | 'large'>, }, }, setup(props) { const ns = useNamespace('icon'); const BaseUrl = `${ibiz.env.assetsUrl}/img/`; function getContent(icon?: IPSSysImage): VNode | null { if (icon) { if (icon.cssClass) { if (icon.cssClass.indexOf('fa-') !== -1) { return ; } return renderCompatibleIE(() => { ; }); } if (icon.imagePath) { const prefixUrl = icon.imagePath.startsWith('./') || icon.imagePath.startsWith('/') ? '' : BaseUrl; if (icon.imagePath.endsWith('svg')) { if (icon.imagePath.startsWith('http')) { return renderCompatibleIE(() => { ; }); } return renderCompatibleIE(() => ( )); } if (icon.imagePath.startsWith('http')) { return ; } return ; } } return null; } const content = computed(() => { return getContent(props.icon); }); return () => content.value; }, }); export default AppIcon;