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;
|
icon: string;
|
||||||
id: string;
|
id: string;
|
||||||
modelId: string;
|
modelId: string;
|
||||||
|
name?: string;
|
||||||
modelOptions: {
|
modelOptions: {
|
||||||
maxMessageCount: number;
|
maxMessageCount: number;
|
||||||
maxReplyLength: number;
|
maxReplyLength: number;
|
||||||
|
|||||||
@@ -124,10 +124,10 @@ function getHighlightedChunks(text: string, keyword: string) {
|
|||||||
const queryChars = [...keyword.trim().toLowerCase()];
|
const queryChars = [...keyword.trim().toLowerCase()];
|
||||||
|
|
||||||
if (queryChars.length === 0) {
|
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;
|
let queryIndex = 0;
|
||||||
|
|
||||||
sourceChars.forEach((char, index) => {
|
sourceChars.forEach((char, index) => {
|
||||||
@@ -141,7 +141,11 @@ function getHighlightedChunks(text: string, keyword: string) {
|
|||||||
if (previousChunk && previousChunk.matched === matched) {
|
if (previousChunk && previousChunk.matched === matched) {
|
||||||
previousChunk.text += char;
|
previousChunk.text += char;
|
||||||
} else {
|
} 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))]"
|
class="block truncate text-sm font-medium leading-6 text-[hsl(var(--text-strong))]"
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(chunk, chunkIndex) in getHighlightedChunks(
|
v-for="chunk in getHighlightedChunks(item.name || '', keyword)"
|
||||||
item.name || '',
|
:key="`${item.path}-${chunk.key}`"
|
||||||
keyword,
|
|
||||||
)"
|
|
||||||
:key="`${item.path}-${chunkIndex}`"
|
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
:class="
|
:class="
|
||||||
|
|||||||
Reference in New Issue
Block a user