fix: 修复前端校验兼容与搜索高亮告警
- 为管理端补充 vue-element-plus-x 模块声明与 BotInfo 兼容字段 - 修正用户中心全局搜索高亮片段 key 生成,减少渲染告警风险
This commit is contained in:
6
easyflow-ui-admin/app/src/types/vue-element-plus-x.d.ts
vendored
Normal file
6
easyflow-ui-admin/app/src/types/vue-element-plus-x.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
declare module 'vue-element-plus-x/es/*/index.js' {
|
||||
import type { DefineComponent } from 'vue';
|
||||
|
||||
const component: DefineComponent<Record<string, any>, Record<string, any>, any>;
|
||||
export default component;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ interface BotInfo {
|
||||
icon: string;
|
||||
id: string;
|
||||
modelId: string;
|
||||
name?: string;
|
||||
modelOptions: {
|
||||
maxMessageCount: number;
|
||||
maxReplyLength: number;
|
||||
|
||||
@@ -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="
|
||||
|
||||
Reference in New Issue
Block a user