perf: 样式调整

This commit is contained in:
rd
2025-07-30 17:44:27 +08:00
parent 35835ca113
commit b1a5914e30
6 changed files with 167 additions and 16 deletions

View File

@ -0,0 +1,141 @@
<template>
<a-tooltip :disabled="isShowBtn || (!isShowBtn && disabled)" :placement="props.placement">
<template #content>
<div :style="contentStyle" class="tip-content">{{ props.context }}</div>
</template>
<div class="overflow-hidden">
<div v-bind="$attrs" ref="Text" :class="`${isShow ? '' : `line-${props.line}`} `" class="overflow-text">
{{ props.context }}
</div>
<div
v-if="isShowBtn && !disabled"
class="color-#8C8C8C flex items-center cursor-pointer mt-2px"
@click="
() => {
isShow = !isShow;
}
"
>
{{ isShow ? '收起' : '展开' }}
<icon-up size="16" :class="{ active: isShow }" class="ml-2px color-#8C8C8C" />
</div>
</div>
</a-tooltip>
</template>
<script setup>
import { ref, reactive, toRefs, onBeforeMount, onMounted, watchEffect, computed, watch, nextTick, defineProps } from 'vue';
import elementResizeDetectorMaker from 'element-resize-detector';
const props = defineProps({
context: {
type: String,
default: '',
},
placement: {
type: String,
default: 'bottom',
},
line: {
type: Number,
default: 1,
},
maxHeight: {
type: [String, Number],
default: '',
},
maxWidth: {
type: [String, Number],
default: '',
},
isShowBtn: {
type: Boolean,
default: false,
},
});
const data = reactive({});
const isShow = ref(false);
const contentStyle = computed(() => {
let style = {
'max-height': props.maxHeight + 'px',
'max-width': props.maxWidth + 'px',
overflow: 'auto',
padding: '1px 0',
};
return props.maxHeight || props.maxWidth ? style : {};
});
const disabled = ref(true);
const Text = ref(null);
const textWidth = ref();
watch(
[() => props.context, textWidth],
async () => {
if (props.context) {
await nextTick();
nextTick(() => {
if (props.line < 2) {
if (Text.value?.clientWidth < Text.value?.scrollWidth) {
disabled.value = false;
} else {
disabled.value = true;
}
} else {
if (Text.value?.clientHeight < Text.value?.scrollHeight) {
disabled.value = false;
} else {
disabled.value = true;
}
}
});
}
},
{
deep: true,
immediate: true,
},
);
onBeforeMount(() => {});
onMounted(async () => {
await nextTick();
const erd = elementResizeDetectorMaker();
if (Text.value) {
erd.listenTo(Text.value, () => {
const _width = Text.value.getBoundingClientRect().width;
textWidth.value = _width;
});
}
});
watchEffect(() => {});
defineExpose({
...toRefs(data),
});
</script>
<style scoped lang="scss">
.overflow-text {
display: inline-block;
font-family: $font-family-regular;
width: 100%;
vertical-align: middle;
font-style: normal;
box-sizing: border-box;
white-space: pre-line;
&.line-1 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&.line-2 {
@include multi-ellipsis(2);
}
&.line-3 {
@include multi-ellipsis(3);
}
}
.tip-content {
white-space: pre-line;
}
.active {
transform: rotate(-180deg);
}
</style>

View File

@ -39,7 +39,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
requireLogin: true,
hideFooter: true,
id: MENU_GROUP_IDS.AGENT,
isAgentRoute: true
isAgentRoute: true,
hideInMenu: true,
},
},
@ -53,7 +54,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
requireLogin: true,
hideFooter: true,
id: MENU_GROUP_IDS.AGENT,
isAgentRoute: true
isAgentRoute: true,
hideInMenu: true,
},
},
],

View File

@ -22,14 +22,14 @@
:xl="6"
:xxl="4"
v-for="(product, k) in item.agent_products">
<div class="card-container cursor-pointer" @click="goDetail(product?.type, product?.id)">
<div class="card-container cursor-pointer !h-252px" @click="goDetail(product?.type, product?.id)">
<img
class="card-image h-120px object-contain w-100% mb-8px bg-#F0EDFF"
:src="product?.icon_url"
/>
<div class="card-content">
<div class="card-title mb-4px">{{ product?.name }}</div>
<div class="card-description mb-8px">{{ product?.description }}</div>
<TextoverTips :context="product.description" class="card-description mb-8px color-#737478 text-14px lh-22px font-400" :line="2" />
</div>
<div class="card-footer">
@ -64,7 +64,8 @@
<script setup lang="ts">
import { useRouter } from 'vue-router';
import { getAgentList } from '@/api/all/agent';
import { formatNumberShow } from "@/utils/tools"
import { formatNumberShow } from "@/utils/tools";
import TextoverTips from "@/components/text-over-tips";
const router = useRouter();

View File

@ -42,22 +42,13 @@
.card-content {
flex: 1;
overflow: hidden;
// overflow: hidden;
.card-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.card-description {
height: 40px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}
@ -87,7 +78,7 @@
.card-footer {
width: 100%;
height: 100%;
// height: 100%;
display: inline-flex;
justify-content: space-between;
align-items: center;