fix: 修复前端校验兼容与搜索高亮告警

- 为管理端补充 vue-element-plus-x 模块声明与 BotInfo 兼容字段

- 修正用户中心全局搜索高亮片段 key 生成,减少渲染告警风险
This commit is contained in:
2026-03-18 22:26:21 +08:00
parent cff4fe8da9
commit 39a6daf8fe
3 changed files with 16 additions and 8 deletions

View File

@@ -124,10 +124,10 @@ function getHighlightedChunks(text: string, keyword: string) {
const queryChars = [...keyword.trim().toLowerCase()];
if (queryChars.length === 0) {
return [{ text, matched: false }];
return [{ key: '0', text, matched: false }];
}
const chunks: Array<{ matched: boolean; text: string }> = [];
const chunks: Array<{ key: string; matched: boolean; text: string }> = [];
let queryIndex = 0;
sourceChars.forEach((char, index) => {
@@ -141,7 +141,11 @@ function getHighlightedChunks(text: string, keyword: string) {
if (previousChunk && previousChunk.matched === matched) {
previousChunk.text += char;
} else {
chunks.push({ matched, text: char });
chunks.push({
key: `${index}-${matched ? '1' : '0'}`,
matched,
text: char,
});
}
});
@@ -237,11 +241,8 @@ onMounted(() => {
class="block truncate text-sm font-medium leading-6 text-[hsl(var(--text-strong))]"
>
<template
v-for="(chunk, chunkIndex) in getHighlightedChunks(
item.name || '',
keyword,
)"
:key="`${item.path}-${chunkIndex}`"
v-for="chunk in getHighlightedChunks(item.name || '', keyword)"
:key="`${item.path}-${chunk.key}`"
>
<span
:class="