1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-13 17:24:44 +08:00

feat: 引入 iconfont.js 使用 SVG

This commit is contained in:
zhengkunwang223 2022-08-18 17:30:38 +08:00
parent 393d0295e2
commit 2964f83d68
3 changed files with 49 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,46 @@
<template>
<svg :class="svgClass" aria-hidden="true">
<use :xlink:href="iconClassName" :fill="color" />
</svg>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
iconName: {
type: String,
required: true,
},
className: {
type: String,
default: '',
},
color: {
type: String,
default: '#409eff',
},
});
// iconfont
const iconClassName = computed(() => {
return `#${props.iconName}`;
});
//
const svgClass = computed(() => {
if (props.className) {
return `svg-icon ${props.className}`;
}
return 'svg-icon';
});
</script>
<style scoped>
.svg-icon {
width: 1.5em;
height: 1.5em;
position: relative;
fill: currentColor;
vertical-align: -2px;
padding-top: 0.3em;
padding-bottom: 0.3em;
padding-left: 0.3em;
padding-right: 0.3em;
}
</style>

View File

@ -3,6 +3,7 @@ import App from './App.vue';
import '@/styles/reset.scss';
import '@/styles/common.scss';
import '@/assets/iconfont/iconfont.css';
import '@/assets/iconfont/iconfont.js';
import ElementPlus from 'element-plus';
import Fit2CloudPlus from 'fit2cloud-ui-plus';
import * as Icons from '@element-plus/icons-vue';
@ -14,7 +15,9 @@ import directives from '@/directives/index';
import router from '@/routers/index';
import I18n from '@/lang/index';
import pinia from '@/store/index';
import SvgIcon from './components/svg-icon/svg-icon.vue';
const app = createApp(App);
app.component('SvgIcon', SvgIcon);
app.use(ElementPlus);
app.use(Fit2CloudPlus);
Object.keys(Icons).forEach((key) => {