feat: 优化FAQ工具提示样式和知识库卡片UI设计

This commit is contained in:
wizardchen
2025-11-20 01:25:31 +08:00
parent 5965afa899
commit 884a765f3a
3 changed files with 181 additions and 230 deletions
+36 -141
View File
@@ -163,16 +163,17 @@ watch(showTooltip, (newVal) => {
.faq-tag-tooltip { .faq-tag-tooltip {
position: fixed; position: fixed;
z-index: 9999; z-index: 9999;
max-width: 360px; max-width: 320px;
min-width: 120px; min-width: 100px;
padding: 12px 16px; padding: 10px 14px;
background: #FFFFFF; background: #FFFFFF;
color: #111827; color: #000000e6;
border: 1px solid #E7E7E7; border: 1px solid #e7ebf0;
border-radius: 8px; border-radius: 6px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.08);
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 13px; font-size: 12px;
font-weight: 400;
line-height: 1.6; line-height: 1.6;
word-break: break-word; word-break: break-word;
pointer-events: none; pointer-events: none;
@@ -182,206 +183,100 @@ watch(showTooltip, (newVal) => {
position: absolute; position: absolute;
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 5px solid transparent;
} }
&.placement-top::before { &.placement-top::before {
bottom: -12px; bottom: -10px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
border-top-color: #E7E7E7; border-top-color: #e7ebf0;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
} }
&.placement-top::after { &.placement-top::after {
content: ''; content: '';
position: absolute; position: absolute;
bottom: -11px; bottom: -9px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 5px solid transparent;
border-top-color: #FFFFFF; border-top-color: #FFFFFF;
} }
&.placement-bottom::before { &.placement-bottom::before {
top: -12px; top: -10px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
border-bottom-color: #E7E7E7; border-bottom-color: #e7ebf0;
filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.08));
} }
&.placement-bottom::after { &.placement-bottom::after {
content: ''; content: '';
position: absolute; position: absolute;
top: -11px; top: -9px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 5px solid transparent;
border-bottom-color: #FFFFFF; border-bottom-color: #FFFFFF;
} }
&.placement-left::before { &.placement-left::before {
right: -12px; right: -10px;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
border-left-color: #E7E7E7; border-left-color: #e7ebf0;
filter: drop-shadow(2px 0 4px rgba(0, 0, 0, 0.08));
} }
&.placement-left::after { &.placement-left::after {
content: ''; content: '';
position: absolute; position: absolute;
right: -11px; right: -9px;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 5px solid transparent;
border-left-color: #FFFFFF; border-left-color: #FFFFFF;
} }
&.placement-right::before { &.placement-right::before {
left: -12px; left: -10px;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
border-right-color: #E7E7E7; border-right-color: #e7ebf0;
filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.08));
} }
&.placement-right::after { &.placement-right::after {
content: ''; content: '';
position: absolute; position: absolute;
left: -11px; left: -9px;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
width: 0; width: 0;
height: 0; height: 0;
border: 6px solid transparent; border: 5px solid transparent;
border-right-color: #FFFFFF; border-right-color: #FFFFFF;
} }
&.tooltip-answer { // 所有类型使用统一的常规边框颜色
border-color: #07C05F; &.tooltip-answer,
background: #FFFFFF; &.tooltip-similar,
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
}
&.tooltip-similar {
border-color: #07C05F;
background: #FFFFFF;
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
}
&.tooltip-negative { &.tooltip-negative {
border-color: #07C05F; // 边框和箭头颜色已在主样式中定义为 #e7ebf0
background: #FFFFFF; // 无需额外覆盖
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
} }
} }
.tooltip-content { .tooltip-content {
color: #111827; color: #000000e6;
font-family: "PingFang SC";
font-size: 12px;
font-weight: 400;
line-height: 1.6;
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-word; word-break: break-word;
} }
@@ -74,6 +74,7 @@
<!-- 卡片底部 --> <!-- 卡片底部 -->
<div class="card-bottom"> <div class="card-bottom">
<div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }"> <div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }">
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'file'" size="14px" />
<span>{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}</span> <span>{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}</span>
</div> </div>
<span class="card-time">{{ kb.updated_at }}</span> <span class="card-time">{{ kb.updated_at }}</span>
@@ -294,10 +295,9 @@ const handleKBEditorSuccess = (kbId: string) => {
.create-btn { .create-btn {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 8px;
padding: 8px 20px; padding: 10px 24px;
height: 36px; height: 40px;
border: 1px solid transparent;
border-radius: 8px; border-radius: 8px;
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 14px; font-size: 14px;
@@ -307,36 +307,50 @@ const handleKBEditorSuccess = (kbId: string) => {
.btn-icon { .btn-icon {
flex-shrink: 0; flex-shrink: 0;
font-size: 16px;
} }
} }
.create-btn.primary { .create-btn.primary {
background: #07c05f; background: #07c05f;
color: #fff; color: #fff;
border-color: #07c05f; border: none;
box-shadow: 0 2px 6px 0 rgba(7, 192, 95, 0.2);
&:hover { &:hover {
background: #05a04f; background: #05a855;
border-color: #05a04f; box-shadow: 0 3px 8px 0 rgba(7, 192, 95, 0.28);
} }
&:active { &:active {
background: #048f45; background: #048f45;
border-color: #048f45;
} }
} }
.create-btn.ghost { .create-btn.ghost {
background: transparent; background: #ffffff;
color: #07c05f; color: #07c05f;
border-color: #07c05f; border: 1.5px solid #d4edde;
box-shadow: none;
.btn-icon {
color: #07c05f;
font-weight: 600;
}
&:hover { &:hover {
background: #07c05f1a; background: #f6fdf9;
border-color: #07c05f;
color: #059669;
.btn-icon {
color: #059669;
}
} }
&:active { &:active {
background: #07c05f33; background: #ecfdf5;
border-color: #05a855;
} }
} }
@@ -388,41 +402,57 @@ const handleKBEditorSuccess = (kbId: string) => {
opacity: 0.9; opacity: 0.9;
} }
// 文档类型背景图案 // 文档类型样式
&.kb-type-document::before { &.kb-type-document {
content: ''; background: linear-gradient(135deg, #ffffff 0%, #f8fcfa 100%);
position: absolute; border-color: #e8f5ed;
top: 0;
right: 0; &:hover {
width: 100%; border-color: #07c05f;
height: 100%; background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V8L14 2Z' stroke='%2307C05F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M14 2V8H20' stroke='%2307C05F' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
background-repeat: repeat;
background-size: 32px 32px; // 右上角装饰
background-position: top right; &::after {
opacity: 0.06; content: '';
pointer-events: none; position: absolute;
z-index: 0; top: 0;
right: 0;
width: 60px;
height: 60px;
background: linear-gradient(135deg, rgba(7, 192, 95, 0.08) 0%, transparent 100%);
border-radius: 0 6px 0 100%;
pointer-events: none;
z-index: 0;
}
} }
// 问答类型背景图案 // 问答类型样式
&.kb-type-faq::before { &.kb-type-faq {
content: ''; background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
position: absolute; border-color: #e6f0ff;
top: 0;
right: 0; &:hover {
width: 100%; border-color: #0052d9;
height: 100%; background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z' stroke='%231890FF' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M9.09 9C9.3251 8.33167 9.78915 7.76811 10.4 7.40913C11.0108 7.05016 11.7289 6.91894 12.4272 7.03871C13.1255 7.15849 13.7588 7.52152 14.2151 8.06353C14.6713 8.60553 14.9211 9.29152 14.92 10C14.92 12 11.92 13 11.92 13' stroke='%231890FF' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12 17H12.01' stroke='%231890FF' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
background-repeat: repeat;
background-size: 32px 32px; // 右上角装饰
background-position: top right; &::after {
opacity: 0.06; content: '';
pointer-events: none; position: absolute;
z-index: 0; top: 0;
right: 0;
width: 60px;
height: 60px;
background: linear-gradient(135deg, rgba(0, 82, 217, 0.08) 0%, transparent 100%);
border-radius: 0 6px 0 100%;
pointer-events: none;
z-index: 0;
}
} }
// 确保内容在背景图案之上 // 确保内容在装饰之上
.card-header, .card-header,
.card-content, .card-content,
.card-bottom { .card-bottom {
@@ -453,25 +483,29 @@ const handleKBEditorSuccess = (kbId: string) => {
.more-wrap { .more-wrap {
display: flex; display: flex;
width: 28px; width: 32px;
height: 28px; height: 32px;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
border-radius: 3px; border-radius: 6px;
cursor: pointer; cursor: pointer;
flex-shrink: 0; flex-shrink: 0;
transition: all 0.2s ease;
opacity: 0.7;
&:hover { &:hover {
background: #e7e7e7; background: rgba(0, 0, 0, 0.06);
opacity: 1;
} }
&.active-more { &.active-more {
background: #e7e7e7; background: rgba(0, 0, 0, 0.08);
opacity: 1;
} }
.more-icon { .more-icon {
width: 14px; width: 16px;
height: 14px; height: 16px;
} }
} }
@@ -504,23 +538,26 @@ const handleKBEditorSuccess = (kbId: string) => {
} }
.type-badge { .type-badge {
display: flex; display: inline-flex;
align-items: center; align-items: center;
gap: 3px; gap: 4px;
padding: 2px 8px; padding: 3px 10px;
border-radius: 3px; border-radius: 4px;
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
line-height: 18px;
&.document { &.document {
background: #07c05f1a; background: rgba(7, 192, 95, 0.1);
color: #07c05f; color: #059669;
border: 1px solid rgba(7, 192, 95, 0.2);
} }
&.faq { &.faq {
background: #1890ff1a; background: rgba(0, 82, 217, 0.1);
color: #1890ff; color: #0052d9;
border: 1px solid rgba(0, 82, 217, 0.2);
} }
} }
@@ -674,9 +711,12 @@ const handleKBEditorSuccess = (kbId: string) => {
z-index: 99 !important; z-index: 99 !important;
.t-popup__content { .t-popup__content {
padding: 4px 0 !important; padding: 6px 0 !important;
margin-top: 4px !important; margin-top: 6px !important;
min-width: 120px; min-width: 140px;
border-radius: 6px !important;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1) !important;
border: 1px solid #e7ebf0 !important;
} }
} }
@@ -688,21 +728,29 @@ const handleKBEditorSuccess = (kbId: string) => {
.popup-menu-item { .popup-menu-item {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 8px 16px; gap: 10px;
padding: 10px 16px;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
color: #000000e6; color: #000000e6;
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
line-height: 20px;
.menu-icon { .menu-icon {
margin-right: 8px;
font-size: 16px; font-size: 16px;
flex-shrink: 0;
color: #00000099;
transition: color 0.2s ease;
} }
&:hover { &:hover {
background: #f5f5f5; background: #f7f9fc;
.menu-icon {
color: #000000e6;
}
} }
&.delete { &.delete {
@@ -710,14 +758,14 @@ const handleKBEditorSuccess = (kbId: string) => {
&:hover { &:hover {
background: #fff1f0; background: #fff1f0;
color: #FA5151; color: #fa5151;
.menu-icon { .menu-icon {
color: #FA5151; color: #fa5151;
}
} }
} }
} }
}
// 创建对话框样式优化 // 创建对话框样式优化
.create-kb-dialog { .create-kb-dialog {
@@ -2769,18 +2769,20 @@ watch(() => entries.value.map(e => ({
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 8px;
padding-top: 12px; padding: 10px 16px;
border-top: 1px solid #F3F4F6; margin: 0 -16px -12px;
flex-wrap: wrap; background: rgba(48, 50, 54, 0.02);
border-top: 1px solid #f5f5f5;
flex-wrap: nowrap;
} }
.faq-card-status { .faq-card-status {
display: flex; display: flex;
flex-wrap: wrap; align-items: center;
gap: 8px; gap: 6px;
flex: 1; flex-shrink: 0;
min-width: 0; margin-left: auto;
} }
.status-item { .status-item {
@@ -2813,16 +2815,15 @@ watch(() => entries.value.map(e => ({
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
padding: 4px 8px; padding: 2px 4px;
border-radius: 6px; border-radius: 4px;
background: #F9FAFB; background: transparent;
border: 1px solid #EEF2F7; border: none;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
&:hover { &:hover {
background: #F3F4F6; background: rgba(0, 0, 0, 0.04);
border-color: #D1D5DB;
} }
.status-icon { .status-icon {
@@ -2846,19 +2847,24 @@ watch(() => entries.value.map(e => ({
.faq-card-tag { .faq-card-tag {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: flex-start;
flex-shrink: 0; flex: 1;
min-width: 0;
:deep(.t-tag) { :deep(.t-tag) {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
max-width: 170px; max-width: 140px;
border-radius: 999px; height: 22px;
border-radius: 4px;
border-color: #e5e7eb; border-color: #e5e7eb;
color: #374151; color: #00000066;
padding: 0 12px; padding: 0 8px;
background: #f9fafb; background: #3032360f;
font-size: 12px;
font-weight: 400;
font-family: "PingFang SC";
transition: all 0.2s ease; transition: all 0.2s ease;
&:hover { &:hover {
@@ -2875,11 +2881,13 @@ watch(() => entries.value.map(e => ({
cursor: pointer; cursor: pointer;
.tag-text { .tag-text {
max-width: 160px; max-width: 120px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
font-size: 12px; font-size: 12px;
font-weight: 400;
color: #00000066;
} }
} }