Skip to content

Commit

Permalink
refactor!: 移除 el-icon 使用
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Jun 3, 2023
1 parent 0f347b6 commit 1a8529f
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 209 deletions.
4 changes: 1 addition & 3 deletions src/components/FileUpload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ const onSuccess: UploadProps['onSuccess'] = (res, file, fileList) => {
drag
>
<div class="slot">
<el-icon class="el-icon--upload">
<svg-icon name="ep:upload-filled" />
</el-icon>
<svg-icon name="ep:upload-filled" class="el-icon--upload" />
<div class="el-upload__text">
将文件拖到此处,或<em>点击上传</em>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/components/ImagePreview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const realHeight = computed(() => {
<el-image :src="src" fit="cover" :style="`width:${realWidth};height:${realHeight};`" :preview-src-list="[src]" preview-teleported>
<template #error>
<div class="image-slot">
<el-icon>
<svg-icon name="image-load-fail" />
</el-icon>
<svg-icon name="image-load-fail" />
</div>
</template>
</el-image>
Expand Down
14 changes: 4 additions & 10 deletions src/components/ImageUpload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
<el-image v-if="url === ''" :src="url === '' ? placeholder : url" :style="`width:${width}px;height:${height}px;`" fit="fill">
<template #error>
<div class="image-slot" :style="`width:${width}px;height:${height}px;`">
<el-icon>
<svg-icon name="ep:plus" />
</el-icon>
<svg-icon name="ep:plus" />
</div>
</template>
</el-image>
Expand All @@ -115,14 +113,10 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
<div class="mask">
<div class="actions">
<span title="预览" @click.stop="preview">
<el-icon>
<svg-icon name="ep:zoom-in" />
</el-icon>
<svg-icon name="ep:zoom-in" />
</span>
<span title="移除" @click.stop="remove">
<el-icon>
<svg-icon name="ep:delete" />
</el-icon>
<svg-icon name="ep:delete" />
</span>
</div>
</div>
Expand Down Expand Up @@ -185,7 +179,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
transform: scale(1.5);
}
.el-icon {
.icon {
font-size: 24px;
}
}
Expand Down
22 changes: 6 additions & 16 deletions src/components/ImagesUpload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,16 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
<div class="mask">
<div class="actions">
<span title="预览" @click="preview(index)">
<el-icon>
<svg-icon name="ep:zoom-in" />
</el-icon>
<svg-icon name="ep:zoom-in" />
</span>
<span title="移除" @click="remove(index)">
<el-icon>
<svg-icon name="ep:delete" />
</el-icon>
<svg-icon name="ep:delete" />
</span>
<span v-show="url.length > 1" title="左移" :class="{ disabled: index === 0 }" @click="move(index, 'left')">
<el-icon>
<svg-icon name="ep:back" />
</el-icon>
<svg-icon name="ep:back" />
</span>
<span v-show="url.length > 1" title="右移" :class="{ disabled: index === url.length - 1 }" @click="move(index, 'right')">
<el-icon>
<svg-icon name="ep:right" />
</el-icon>
<svg-icon name="ep:right" />
</span>
</div>
</div>
Expand All @@ -148,9 +140,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
class="images-upload"
>
<div class="image-slot" :style="`width:${width}px;height:${height}px;`">
<el-icon>
<svg-icon name="ep:plus" />
</el-icon>
<svg-icon name="ep:plus" />
</div>
<div v-show="uploadData.progress.percent" class="progress" :style="`width:${width}px;height:${height}px;`">
<el-image :src="uploadData.progress.preview" :style="`width:${width}px;height:${height}px;`" fit="fill" />
Expand Down Expand Up @@ -218,7 +208,7 @@ const onSuccess: UploadProps['onSuccess'] = (res) => {
transform: scale(1.5);
}
.el-icon {
.icon {
font-size: 24px;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/PageMain/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ function unCollaspe() {
</div>
<slot />
<div v-if="collaspeData" class="collaspe" title="展开" @click="unCollaspe">
<el-icon>
<svg-icon name="ep:arrow-down" />
</el-icon>
<svg-icon name="ep:arrow-down" />
</div>
</div>
</template>
Expand Down
4 changes: 1 addition & 3 deletions src/components/SearchBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function toggle() {
<div v-if="showToggle" class="toggle">
<el-button text size="small" @click="toggle">
<template #icon>
<el-icon>
<svg-icon :name="isFold ? 'ep:caret-bottom' : 'ep:caret-top' " />
</el-icon>
<svg-icon :name="isFold ? 'ep:caret-bottom' : 'ep:caret-top' " />
</template>
{{ isFold ? '展开' : '收起' }}
</el-button>
Expand Down
70 changes: 45 additions & 25 deletions src/components/SvgIcon/index.vue
Original file line number Diff line number Diff line change
@@ -1,48 +1,68 @@
<script setup lang="ts">
import { Icon } from '@iconify/vue'
const props = withDefaults(
defineProps<{
name: string
flip?: 'horizontal' | 'vertical' | 'both' | ''
rotate?: number
}>(),
{
flip: '',
rotate: 0,
},
)
const props = defineProps<{
name: string
flip?: 'horizontal' | 'vertical' | 'both'
rotate?: number
color?: string
size?: string | number
}>()
defineOptions({
name: 'SvgIcon',
})
const transformStyle = computed(() => {
const style = []
if (props.flip !== '') {
const style = computed(() => {
const transform = []
if (props.flip) {
switch (props.flip) {
case 'horizontal':
style.push('rotateY(180deg)')
transform.push('rotateY(180deg)')
break
case 'vertical':
style.push('rotateX(180deg)')
transform.push('rotateX(180deg)')
break
case 'both':
style.push('rotateX(180deg)')
style.push('rotateY(180deg)')
transform.push('rotateX(180deg)')
transform.push('rotateY(180deg)')
break
}
}
if (props.rotate !== 0) {
style.push(`rotate(${props.rotate}deg)`)
if (props.rotate) {
transform.push(`rotate(${props.rotate % 360}deg)`)
}
return {
...(props.color && { color: props.color }),
...(props.size && { fontSize: typeof props.size === 'number' ? `${props.size}px` : props.size }),
...(transform.length && { transform: transform.join(' ') }),
}
return `transform: ${style.join(' ')};`
})
</script>

<template>
<Icon v-if="name.indexOf('ep:') === 0" :icon="name" :style="transformStyle" />
<svg v-else :style="transformStyle" aria-hidden="true">
<use :xlink:href="`#icon-${name}`" />
</svg>
<i class="icon" :style="style">
<Icon v-if="name.indexOf('ep:') === 0" :icon="name" />
<svg v-else aria-hidden="true">
<use :xlink:href="`#icon-${name}`" />
</svg>
</i>
</template>

<style lang="scss" scoped>
.icon {
height: 1em;
width: 1em;
line-height: 1em;
display: inline-flex;
justify-content: center;
align-items: center;
position: relative;
fill: currentcolor;
svg {
height: 1em;
width: 1em;
}
}
</style>
8 changes: 3 additions & 5 deletions src/components/Trend/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const isUp = computed(() => {
<span v-if="prefix" class="prefix">{{ prefix }}</span>
<span class="text">{{ value }}</span>
<span v-if="suffix" class="suffix">{{ suffix }}</span>
<el-icon>
<svg-icon name="ep:caret-top" />
</el-icon>
<svg-icon name="ep:caret-top" />
</div>
</template>

Expand All @@ -52,12 +50,12 @@ const isUp = computed(() => {
&.down {
color: var(--el-color-danger);
.el-icon {
.icon {
transform: rotate(180deg);
}
}
.el-icon {
.icon {
margin-left: 5px;
transition: transform 0.3s;
}
Expand Down
Loading

0 comments on commit 1a8529f

Please sign in to comment.