mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-16 06:06:37 +08:00
feat: 项目加载优化
This commit is contained in:
250
Yi.Ai.Vue3/src/components/FontAwesomeIcon/demo.vue
Normal file
250
Yi.Ai.Vue3/src/components/FontAwesomeIcon/demo.vue
Normal file
@@ -0,0 +1,250 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* FontAwesome 图标演示组件
|
||||
* 展示不同大小和样式的图标
|
||||
*/
|
||||
|
||||
const commonIcons = [
|
||||
'check',
|
||||
'xmark',
|
||||
'plus',
|
||||
'minus',
|
||||
'trash',
|
||||
'pen-to-square',
|
||||
'magnifying-glass',
|
||||
'rotate-right',
|
||||
'download',
|
||||
'upload',
|
||||
'user',
|
||||
'gear',
|
||||
'eye',
|
||||
'eye-slash',
|
||||
'lock',
|
||||
'folder',
|
||||
'file',
|
||||
'image',
|
||||
'comment',
|
||||
'bell',
|
||||
'heart',
|
||||
'star',
|
||||
'clock',
|
||||
'calendar',
|
||||
'share-nodes',
|
||||
];
|
||||
|
||||
const sizes = ['xs', 'sm', 'lg', 'xl', '2x'] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="font-awesome-demo">
|
||||
<h2>FontAwesome 图标演示</h2>
|
||||
|
||||
<section>
|
||||
<h3>基础图标</h3>
|
||||
<div class="icon-grid">
|
||||
<div v-for="icon in commonIcons" :key="icon" class="icon-item">
|
||||
<FontAwesomeIcon :icon="icon" />
|
||||
<span>{{ icon }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>不同尺寸</h3>
|
||||
<div class="size-demo">
|
||||
<div v-for="size in sizes" :key="size" class="size-item">
|
||||
<FontAwesomeIcon icon="star" :size="size" />
|
||||
<span>{{ size }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>动画效果</h3>
|
||||
<div class="animation-demo">
|
||||
<div class="anim-item">
|
||||
<FontAwesomeIcon icon="spinner" spin />
|
||||
<span>spin</span>
|
||||
</div>
|
||||
<div class="anim-item">
|
||||
<FontAwesomeIcon icon="circle-notch" spin />
|
||||
<span>circle-notch spin</span>
|
||||
</div>
|
||||
<div class="anim-item">
|
||||
<FontAwesomeIcon icon="heart" pulse />
|
||||
<span>pulse</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>旋转</h3>
|
||||
<div class="rotation-demo">
|
||||
<div class="rot-item">
|
||||
<FontAwesomeIcon icon="arrow-up" :rotation="0" />
|
||||
<span>0°</span>
|
||||
</div>
|
||||
<div class="rot-item">
|
||||
<FontAwesomeIcon icon="arrow-up" :rotation="90" />
|
||||
<span>90°</span>
|
||||
</div>
|
||||
<div class="rot-item">
|
||||
<FontAwesomeIcon icon="arrow-up" :rotation="180" />
|
||||
<span>180°</span>
|
||||
</div>
|
||||
<div class="rot-item">
|
||||
<FontAwesomeIcon icon="arrow-up" :rotation="270" />
|
||||
<span>270°</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>实际应用示例</h3>
|
||||
<div class="examples">
|
||||
<button class="example-btn">
|
||||
<FontAwesomeIcon icon="magnifying-glass" />
|
||||
搜索
|
||||
</button>
|
||||
<button class="example-btn primary">
|
||||
<FontAwesomeIcon icon="check" />
|
||||
确认
|
||||
</button>
|
||||
<button class="example-btn danger">
|
||||
<FontAwesomeIcon icon="trash" />
|
||||
删除
|
||||
</button>
|
||||
<button class="example-btn">
|
||||
<FontAwesomeIcon icon="download" />
|
||||
下载
|
||||
</button>
|
||||
<button class="example-btn">
|
||||
<FontAwesomeIcon icon="share-nodes" />
|
||||
分享
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.font-awesome-demo {
|
||||
padding: 20px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
|
||||
h2 {
|
||||
margin-bottom: 30px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 30px 0 15px;
|
||||
color: var(--el-text-color-regular);
|
||||
border-bottom: 1px solid var(--el-border-color);
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
section {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.icon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
||||
gap: 15px;
|
||||
|
||||
.icon-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 15px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
background-color: var(--el-color-primary-light-9);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
span {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.size-demo,
|
||||
.animation-demo,
|
||||
.rotation-demo {
|
||||
display: flex;
|
||||
gap: 30px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.size-item,
|
||||
.anim-item,
|
||||
.rot-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
min-width: 80px;
|
||||
|
||||
span {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.example-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 20px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-primary);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background-color: var(--el-color-primary);
|
||||
color: white;
|
||||
border-color: var(--el-color-primary);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--el-color-primary-light-3);
|
||||
}
|
||||
}
|
||||
|
||||
&.danger {
|
||||
background-color: var(--el-color-danger);
|
||||
color: white;
|
||||
border-color: var(--el-color-danger);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--el-color-danger-light-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
3
Yi.Ai.Vue3/src/components/FontAwesomeIcon/index.ts
Normal file
3
Yi.Ai.Vue3/src/components/FontAwesomeIcon/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as FontAwesomeIcon } from './index.vue';
|
||||
export { default as FontAwesomeDemo } from './demo.vue';
|
||||
export { getFontAwesomeIcon, iconMapping } from '@/utils/icon-mapping';
|
||||
33
Yi.Ai.Vue3/src/components/FontAwesomeIcon/index.vue
Normal file
33
Yi.Ai.Vue3/src/components/FontAwesomeIcon/index.vue
Normal file
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
interface Props {
|
||||
/** FontAwesome 图标名称(不含 fa- 前缀) */
|
||||
icon: string;
|
||||
/** 图标大小 */
|
||||
size?: 'xs' | 'sm' | 'lg' | 'xl' | '2x' | '3x' | '4x' | '5x';
|
||||
/** 旋转动画 */
|
||||
spin?: boolean;
|
||||
/** 脉冲动画 */
|
||||
pulse?: boolean;
|
||||
/** 旋转角度 */
|
||||
rotation?: 0 | 90 | 180 | 270;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
size: undefined,
|
||||
spin: false,
|
||||
pulse: false,
|
||||
rotation: undefined,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FontAwesomeIcon
|
||||
:icon="`fa-solid fa-${icon}`"
|
||||
:size="size"
|
||||
:spin="spin"
|
||||
:pulse="pulse"
|
||||
:rotation="rotation"
|
||||
/>
|
||||
</template>
|
||||
Reference in New Issue
Block a user