3737 <h3 >{{ tm('search.title') }}</h3 >
3838 <v-card variant =" outlined" class =" mt-2 pa-3" >
3939 <div >
40- <v-text-field v-model =" searchMemoryUserId" :label =" tm('search.userIdLabel')" variant =" outlined" density =" compact" hide-details
41- class =" mb-2" ></v-text-field >
42- <v-text-field v-model =" searchQuery" :label =" tm('search.queryLabel')" variant =" outlined" density =" compact" hide-details
43- @keyup.enter =" searchMemory" class =" mb-2" ></v-text-field >
40+ <v-text-field :model-value =" searchMemoryUserId"
41+ @update:model-value =" onSearchMemoryUserIdInput" :label =" tm('search.userIdLabel')" variant =" outlined" density =" compact" hide-details
42+ class =" mb-2" clearable ></v-text-field >
43+ <v-text-field :model-value =" searchQuery"
44+ @update:model-value =" onSearchQueryInput" :label =" tm('search.queryLabel')" variant =" outlined" density =" compact" hide-details
45+ @keyup.enter =" searchMemory" class =" mb-2" clearable ></v-text-field >
4446 <v-btn color =" info" @click =" searchMemory" :loading =" isSearching" variant =" tonal" >
4547 <v-icon start >mdi-text-search</v-icon >
4648 {{ tm('search.searchButton') }}
254256import axios from ' axios' ;
255257// import * as d3 from "d3"; // npm install d3
256258import { useModuleI18n } from ' @/i18n/composables' ;
259+ import { normalizeTextInput } from ' @/utils/inputValue' ;
257260
258261export default {
259262 name: ' LongTermMemory' ,
@@ -336,9 +339,16 @@ export default {
336339 this .searchResults = [];
337340 },
338341 methods: {
342+ onSearchMemoryUserIdInput (value ) {
343+ this .searchMemoryUserId = normalizeTextInput (value);
344+ },
345+ onSearchQueryInput (value ) {
346+ this .searchQuery = normalizeTextInput (value);
347+ },
339348 // 添加搜索记忆方法
340349 searchMemory () {
341- if (! this .searchQuery .trim ()) {
350+ const query = normalizeTextInput (this .searchQuery ).trim ();
351+ if (! query) {
342352 this .$toast .warning (this .tm (' messages.searchQueryRequired' ));
343353 return ;
344354 }
@@ -349,12 +359,13 @@ export default {
349359
350360 // 构建查询参数
351361 const params = {
352- query: this . searchQuery
362+ query
353363 };
354364
355365 // 如果有选择用户ID,也加入查询参数
356- if (this .searchMemoryUserId ) {
357- params .user_id = this .searchMemoryUserId ;
366+ const normalizedUserId = normalizeTextInput (this .searchMemoryUserId ).trim ();
367+ if (normalizedUserId) {
368+ params .user_id = normalizedUserId;
358369 }
359370
360371 axios .get (' /api/plug/alkaid/ltm/graph/search' , { params })
0 commit comments