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:
parent
393d0295e2
commit
2964f83d68
BIN
frontend/src/assets/iconfont/iconfont.woff2
Normal file
BIN
frontend/src/assets/iconfont/iconfont.woff2
Normal file
Binary file not shown.
46
frontend/src/components/svg-icon/svg-icon.vue
Normal file
46
frontend/src/components/svg-icon/svg-icon.vue
Normal 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>
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user