fix: 修复删除后点击取消报错,增加智能检索输入框字符数量限制

This commit is contained in:
wenjinbo 2025-09-24 13:38:16 +08:00
parent f247efbb79
commit 60cb1eef62
2 changed files with 35 additions and 4 deletions

View File

@ -16,8 +16,12 @@
type="text" type="text"
placeholder="请输入您要搜索的内容..." placeholder="请输入您要搜索的内容..."
class="search-input" class="search-input"
maxlength="50"
@keyup.enter="handleSearch" @keyup.enter="handleSearch"
/> />
<div class="char-counter" v-if="searchQuery">
{{ searchQuery.length }}/50
</div>
<button class="search-btn" @click="handleSearch" :disabled="loading"> <button class="search-btn" @click="handleSearch" :disabled="loading">
<svg v-if="!loading" class="search-icon" viewBox="0 0 24 24"> <svg v-if="!loading" class="search-icon" viewBox="0 0 24 24">
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/> <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
@ -426,6 +430,11 @@ const handleSearch = async () => {
return return
} }
if (searchQuery.value.length > 50) {
ElMessage.warning('搜索内容不能超过50个字符')
return
}
if (!searchMethod.value) { if (!searchMethod.value) {
ElMessage.warning('请选择搜索方法') ElMessage.warning('请选择搜索方法')
return return
@ -889,6 +898,22 @@ onMounted(() => {
background: transparent; background: transparent;
} }
.char-counter {
font-size: 12px;
color: #909399;
white-space: nowrap;
margin-right: 8px;
padding: 2px 6px;
background: rgba(0, 0, 0, 0.05);
border-radius: 10px;
font-family: monospace;
transition: all 0.2s ease;
}
.char-counter:hover {
background: rgba(0, 0, 0, 0.1);
}
.search-btn { .search-btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none; border: none;

View File

@ -812,10 +812,6 @@ const handleBatchDelete = async () => {
} }
) )
const handleClose = () => {
previewDrawerVisible.value = false,
segmentList.value = []
}
const loading = ElLoading.service({ const loading = ElLoading.service({
lock: true, lock: true,
text: t('vabI18n.knowledge.document.messages.deleteing'), text: t('vabI18n.knowledge.document.messages.deleteing'),
@ -842,6 +838,11 @@ const handleBatchDelete = async () => {
loading.close() loading.close()
} }
} catch (error) { } catch (error) {
//
if (error === 'cancel') {
//
return
}
console.error('批量删除失败:', error) console.error('批量删除失败:', error)
ElNotification({ ElNotification({
title: t('vabI18n.knowledge.document.errors.deleteFailed'), title: t('vabI18n.knowledge.document.errors.deleteFailed'),
@ -1292,6 +1293,11 @@ const handleDelete = async (row: FileItem) => {
// //
await fetchDocuments() await fetchDocuments()
} catch (error) { } catch (error) {
//
if (error === 'cancel') {
//
return
}
console.error('删除文件失败:', error) console.error('删除文件失败:', error)
ElNotification({ ElNotification({
title: t('vabI18n.knowledge.document.errors.deleteFailed'), title: t('vabI18n.knowledge.document.errors.deleteFailed'),