feat:rename subtree from frontend-vue to frontend

This commit is contained in:
zhaoweijie
2025-11-20 09:56:51 +08:00
parent 1aa9e280b0
commit ab8c9e294d
80 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
<template>
<el-tooltip :disabled="!isOverflow" effect="light" placement="top" :content="text">
<div
ref="containerRef"
class="multi-line-ellipsis"
:style="containerStyle"
@mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave"
>
<slot>
{{ text }}
</slot>
</div>
</el-tooltip>
</template>
<script lang="ts" setup>
import { computed, type HTMLAttributes, nextTick, onMounted, ref } from 'vue'
import { ElTooltip } from 'element-plus'
// 定义组件 props 类型
interface Props {
text?: string
lines?: number
maxWidth?: string | number
}
const props = withDefaults(defineProps<Props>(), {
text: '',
lines: 3,
maxWidth: '100%',
})
const isOverflow = ref(false)
const containerRef = ref<HTMLElement | null>(null)
// 计算容器样式
const containerStyle = computed(
() =>
({
maxWidth: props.maxWidth,
display: '-webkit-box',
WebkitBoxOrient: 'vertical',
WebkitLineClamp: props.lines,
overflow: 'hidden',
textOverflow: 'ellipsis',
lineHeight: '1.5',
wordBreak: 'break-all',
}) as HTMLAttributes['style'],
)
// 检查文字是否溢出
const checkOverflow = (element: HTMLElement): boolean => {
// 单行情况下使用宽度判断
if (props.lines === 1) {
return element.scrollWidth > element.clientWidth
}
// 多行情况下使用高度判断
else {
return element.scrollHeight > element.clientHeight
}
}
// 鼠标进入处理
const handleMouseEnter = (event: MouseEvent) => {
const element = event.target as HTMLElement
console.log(checkOverflow(element))
isOverflow.value = checkOverflow(element)
}
// 鼠标离开处理
const handleMouseLeave = () => {
isOverflow.value = false
}
// 初始化时检查溢出状态
onMounted(() => {
nextTick(() => {
if (containerRef.value) {
isOverflow.value = checkOverflow(containerRef.value)
}
})
})
</script>
<style scoped>
.multi-line-ellipsis {
cursor: default;
overflow: hidden;
text-overflow: ellipsis;
white-space: normal;
}
</style>

View File

@@ -0,0 +1,35 @@
<script setup lang="ts">
const props = withDefaults(
defineProps<{
iconClass: string
prefix?: string
color?: string
size?: string
}>(),
{
prefix: 'icon',
color: '',
size: '1em',
},
)
const symbolId = computed(() => `#${props.prefix}-${props.iconClass}`)
</script>
<template>
<svg aria-hidden="true" class="svg-icon" :style="`color:${props.color}`">
<use :xlink:href="symbolId" />
</svg>
</template>
<style scoped>
.svg-icon {
display: inline-block;
width: v-bind('props.size');
height: v-bind('props.size');
overflow: hidden;
vertical-align: -0.15em; /* 因icon大小被设置为和字体大小一致而span等标签的下边缘会和字体的基线对齐故需设置一个往下的偏移比例来纠正视觉上的未对齐效果 */
outline: none;
fill: currentcolor; /* 定义元素的颜色currentColor是一个变量这个变量的值就表示当前元素的color值如果当前元素未设置color值则从父元素继承 */
}
</style>