refactor(knowledge): streamline event handling for tag and search inputs
Updated event handling in KnowledgeBase and FAQEntryManager components to utilize the `@enter` directive for form submissions, enhancing clarity and consistency. Implemented custom keydown handling for the Escape key to improve user experience when editing tags and searching documents. This change simplifies the input event management across various components.
This commit is contained in:
@@ -2211,7 +2211,8 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<div class="tag-edit-input">
|
<div class="tag-edit-input">
|
||||||
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
||||||
:placeholder="$t('knowledgeBase.tagNamePlaceholder')"
|
:placeholder="$t('knowledgeBase.tagNamePlaceholder')"
|
||||||
@keydown.enter.stop.prevent="submitCreateTag" @keydown.esc.stop.prevent="cancelCreateTag" />
|
@enter="submitCreateTag"
|
||||||
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelCreateTag() } }" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag-inline-actions">
|
<div class="tag-inline-actions">
|
||||||
@@ -2235,8 +2236,8 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<template v-if="editingTagId === tag.id">
|
<template v-if="editingTagId === tag.id">
|
||||||
<div class="tag-edit-input" @click.stop>
|
<div class="tag-edit-input" @click.stop>
|
||||||
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
||||||
:maxlength="40" @keydown.enter.stop.prevent="submitEditTag"
|
:maxlength="40" @enter="submitEditTag"
|
||||||
@keydown.esc.stop.prevent="cancelEditTag" />
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelEditTag() } }" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -2298,7 +2299,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<div class="doc-filter-bar">
|
<div class="doc-filter-bar">
|
||||||
<t-input v-model.trim="docSearchKeyword" :placeholder="$t('knowledgeBase.docSearchPlaceholder')"
|
<t-input v-model.trim="docSearchKeyword" :placeholder="$t('knowledgeBase.docSearchPlaceholder')"
|
||||||
clearable class="doc-search-input" @clear="loadKnowledgeFiles(kbId)"
|
clearable class="doc-search-input" @clear="loadKnowledgeFiles(kbId)"
|
||||||
@keydown.enter="loadKnowledgeFiles(kbId)">
|
@enter="loadKnowledgeFiles(kbId)">
|
||||||
<template #prefix-icon>
|
<template #prefix-icon>
|
||||||
<t-icon name="search" size="16px" />
|
<t-icon name="search" size="16px" />
|
||||||
</template>
|
</template>
|
||||||
@@ -2715,7 +2716,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||||||
<div class="url-import-form">
|
<div class="url-import-form">
|
||||||
<div class="url-input-label">{{ $t('knowledgeBase.urlLabel') }}</div>
|
<div class="url-input-label">{{ $t('knowledgeBase.urlLabel') }}</div>
|
||||||
<t-input v-model="urlInputValue" :placeholder="$t('knowledgeBase.urlPlaceholder')" clearable autofocus
|
<t-input v-model="urlInputValue" :placeholder="$t('knowledgeBase.urlPlaceholder')" clearable autofocus
|
||||||
@keydown.enter="handleURLImportConfirm" />
|
@enter="handleURLImportConfirm" />
|
||||||
<div class="url-input-tip">{{ $t('knowledgeBase.urlTip') }}</div>
|
<div class="url-input-tip">{{ $t('knowledgeBase.urlTip') }}</div>
|
||||||
</div>
|
</div>
|
||||||
</t-dialog>
|
</t-dialog>
|
||||||
|
|||||||
@@ -184,7 +184,8 @@
|
|||||||
<div class="tag-edit-input">
|
<div class="tag-edit-input">
|
||||||
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
<t-input ref="newTagInputRef" v-model="newTagName" size="small" :maxlength="40"
|
||||||
:placeholder="$t('knowledgeBase.tagNamePlaceholder')"
|
:placeholder="$t('knowledgeBase.tagNamePlaceholder')"
|
||||||
@keydown.enter.stop.prevent="submitCreateTag" @keydown.esc.stop.prevent="cancelCreateTag" />
|
@enter="submitCreateTag"
|
||||||
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelCreateTag() } }" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag-inline-actions">
|
<div class="tag-inline-actions">
|
||||||
@@ -208,8 +209,8 @@
|
|||||||
<template v-if="editingTagId === tag.id">
|
<template v-if="editingTagId === tag.id">
|
||||||
<div class="tag-edit-input" @click.stop>
|
<div class="tag-edit-input" @click.stop>
|
||||||
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
<t-input :ref="setEditingTagInputRefByTag(tag.id)" v-model="editingTagName" size="small"
|
||||||
:maxlength="40" @keydown.enter.stop.prevent="submitEditTag"
|
:maxlength="40" @enter="submitEditTag"
|
||||||
@keydown.esc.stop.prevent="cancelEditTag" />
|
@keydown="(_v, ctx) => { if (ctx?.e?.key === 'Escape') { ctx.e.stopPropagation(); ctx.e.preventDefault(); cancelEditTag() } }" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -268,7 +269,7 @@
|
|||||||
<!-- 搜索栏与管理 FAQ -->
|
<!-- 搜索栏与管理 FAQ -->
|
||||||
<div class="faq-search-bar">
|
<div class="faq-search-bar">
|
||||||
<t-input v-model.trim="entrySearchKeyword" :placeholder="$t('knowledgeEditor.faq.searchPlaceholder')"
|
<t-input v-model.trim="entrySearchKeyword" :placeholder="$t('knowledgeEditor.faq.searchPlaceholder')"
|
||||||
clearable class="faq-search-input" @clear="loadEntries()" @keydown.enter="loadEntries()">
|
clearable class="faq-search-input" @clear="loadEntries()" @enter="loadEntries()">
|
||||||
<template #prefix-icon>
|
<template #prefix-icon>
|
||||||
<t-icon name="search" size="16px" />
|
<t-icon name="search" size="16px" />
|
||||||
</template>
|
</template>
|
||||||
@@ -529,7 +530,7 @@
|
|||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<div class="full-width-input-wrapper">
|
<div class="full-width-input-wrapper">
|
||||||
<t-input v-model="similarInput" :placeholder="$t('knowledgeEditor.faq.similarPlaceholder')"
|
<t-input v-model="similarInput" :placeholder="$t('knowledgeEditor.faq.similarPlaceholder')"
|
||||||
@keydown.enter.prevent="addSimilar" class="full-width-input" />
|
@enter="addSimilar" class="full-width-input" />
|
||||||
<t-button theme="primary" variant="outline"
|
<t-button theme="primary" variant="outline"
|
||||||
:disabled="!similarInput.trim() || editorForm.similar_questions.length >= 10" @click="addSimilar"
|
:disabled="!similarInput.trim() || editorForm.similar_questions.length >= 10" @click="addSimilar"
|
||||||
class="add-item-btn" size="small">
|
class="add-item-btn" size="small">
|
||||||
@@ -557,7 +558,7 @@
|
|||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<div class="full-width-input-wrapper">
|
<div class="full-width-input-wrapper">
|
||||||
<t-input v-model="negativeInput" :placeholder="$t('knowledgeEditor.faq.negativePlaceholder')"
|
<t-input v-model="negativeInput" :placeholder="$t('knowledgeEditor.faq.negativePlaceholder')"
|
||||||
@keydown.enter.prevent="addNegative" class="full-width-input" />
|
@enter="addNegative" class="full-width-input" />
|
||||||
<t-button theme="primary" variant="outline"
|
<t-button theme="primary" variant="outline"
|
||||||
:disabled="!negativeInput.trim() || editorForm.negative_questions.length >= 10" @click="addNegative"
|
:disabled="!negativeInput.trim() || editorForm.negative_questions.length >= 10" @click="addNegative"
|
||||||
class="add-item-btn" size="small">
|
class="add-item-btn" size="small">
|
||||||
@@ -806,7 +807,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="setting-control">
|
<div class="setting-control">
|
||||||
<t-input v-model="searchForm.query" :placeholder="$t('knowledgeEditor.faq.queryPlaceholder')"
|
<t-input v-model="searchForm.query" :placeholder="$t('knowledgeEditor.faq.queryPlaceholder')"
|
||||||
@keydown.enter.prevent="handleSearch" class="full-width-input" />
|
@enter="handleSearch" class="full-width-input" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user