搜索优化

This commit is contained in:
JenniferW 2025-12-22 13:45:58 +08:00
parent a6c0293205
commit f3b289d16c
1 changed files with 49 additions and 11 deletions

View File

@ -1114,6 +1114,15 @@ const triggerConditionSuggestions = (conditionText) => {
suggestions.value = uniqueSuggestions.slice(0, 8);
}
// searchHint
// 使 keyword
if (conditionText && conditionText.trim()) {
// smart /
disableLocalSuggestions.value = false;
fieldsFromApi.value = false;
scheduleSearchHint(conditionText.trim());
}
};
//
@ -1490,8 +1499,36 @@ const fetchSearchHints = async (keyword) => {
// currentInput.value 使
parsedConditions.value = parseConditions(currentInput.value);
// fieldConditions使
const fieldConditions = parsedConditions.value
//
const cursorIndex = findCursorConditionIndex();
const parts = currentInput.value.split(/[;]/);
const activeIndex =
cursorIndex >= 0 && cursorIndex < parts.length
? cursorIndex
: parts.length - 1;
//
let conditionsToProcess = [...parsedConditions.value];
let reorderedInputWord = currentInput.value.trim();
if (activeIndex >= 0 && activeIndex < conditionsToProcess.length - 1) {
//
const [editedCondition] = conditionsToProcess.splice(activeIndex, 1);
conditionsToProcess.push(editedCondition);
// inputWord
const reorderedParts = parts
.map((p) => p.trim())
.filter((p) => p);
if (activeIndex < reorderedParts.length) {
const [editedPart] = reorderedParts.splice(activeIndex, 1);
reorderedParts.push(editedPart);
reorderedInputWord = reorderedParts.join(";");
}
}
// fieldConditions使
const fieldConditions = conditionsToProcess
.filter((condition) => {
// ":"
return condition.value || (condition.fieldLabel && condition.field);
@ -1552,7 +1589,7 @@ const fetchSearchHints = async (keyword) => {
const payload = {
fieldConditions,
inputWord: currentInput.value.trim(),
inputWord: reorderedInputWord,
page: 0,
size: pageSize.value,
};
@ -1586,12 +1623,7 @@ const fetchSearchHints = async (keyword) => {
// ""
// 使
const parts = currentInput.value.split(/[;]/);
const cursorIndex = findCursorConditionIndex();
const activeIndex =
cursorIndex >= 0 && cursorIndex < parts.length
? cursorIndex
: parts.length - 1;
// partscursorIndexactiveIndex 使
const currentPart = parts[activeIndex]?.trim() || "";
const isEditingExistingField =
cursorIndex >= 0 && cursorIndex < parts.length - 1;
@ -1876,9 +1908,15 @@ const selectSuggestion = (item) => {
parts[targetIndex] = `${fieldPart}${item.label}`;
}
} else {
//
//
if (item.fieldLabel) {
//
parts[targetIndex] = `${item.fieldLabel}:${item.label}`;
} else {
// 使
parts[targetIndex] = item.label;
}
}
//
const lastChar = parts[targetIndex].slice(-1);