Commit d65bcde3 authored by nick zheng's avatar nick zheng

Merge branch 'beta' into 'master'

chore: 问答知识库分片增加字数检验

See merge request !180
parents eb631fd0 77c8748e
......@@ -521,7 +521,8 @@ personal_space_module:
add_QA: 'Add Q&A'
add_QA_data: 'Add Q&A data'
edit_QA_data: 'Edit Q&A data'
limit_max_chunk_content_length: 'The number of words in a single cell cannot exceed 300 words. Excess words will be automatically cleared'
limit_max_chunk_content_length: 'Each item should be no more than 850 words, and the total number of words should not exceed 3000 words. (Current word count: {count})'
exceed_max_chunk_content_length: 'The total number of words could not exceed 3000 words, please shorten the content to less than 3000 words'
setting_index_desc: 'The index is an important key field of the knowledge base search slice. Select at least one field as the index.'
select_at_least_one_field_as_the_index: 'Select at least one field as the index'
setting_index: 'Setting Index'
......
......@@ -144,7 +144,7 @@ common_module:
download: '下载'
download_success: '下载成功'
download_fail: '下载失败'
unfold : '展开'
unfold: '展开'
fold: '收起'
dialogue_module:
......@@ -519,7 +519,8 @@ personal_space_module:
add_QA: '新建问答'
add_QA_data: '添加问答数据'
edit_QA_data: '编辑问答数据'
limit_max_chunk_content_length: '单个单元格字数不可超300字,多余字数将自动清除'
limit_max_chunk_content_length: '每项内容请控制在850字以内,且所有内容总字数不超过3000字。(当前字数:{count}字)'
exceed_max_chunk_content_length: '总字数不可超过3000字,请将内容缩短至3000字以内'
setting_index_desc: '索引是知识库检索切片的重要关键字段,至少选择1个字段作为索引'
select_at_least_one_field_as_the_index: '至少选择1个字段作为索引'
setting_index: '设置索引'
......
......@@ -144,7 +144,7 @@ common_module:
download: '下載'
download_success: '下載成功'
download_fail: '下載失敗'
unfold : '展開'
unfold: '展開'
fold: '收起'
dialogue_module:
......@@ -519,7 +519,8 @@ personal_space_module:
add_QA: '新建問答'
add_QA_data: '添加問答數據'
edit_QA_data: '編輯問答數據'
limit_max_chunk_content_length: '單個單元格字數不可超300字,多餘字數將自動清除'
limit_max_chunk_content_length: '每項內容請控制在850字以內,且所有內容總字數不超過3000字。(當前字數:{count}字)'
exceed_max_chunk_content_length: '總字數不可超過3000字,請將內容縮短至3000字以內'
setting_index_desc: '索引是知識庫檢索切片的重要關鍵字段,至少選擇1個字段作為索引'
select_at_least_one_field_as_the_index: '至少選擇1個字段作為索引'
setting_index: '設置索引'
......
......@@ -37,6 +37,16 @@ const dataTableScrollX = computed(() => {
return props.knowledgeChunkKeyList.length * 215
})
const currentWordCount = computed(() => {
return chunkStructList.value.reduce((acc, cur) => {
return acc + cur.content.length
}, 0)
})
const isExceedWordCount = computed(() => {
return currentWordCount.value > 3000
})
watch(
() => isShow.value,
(newVal) => {
......@@ -49,6 +59,10 @@ watch(
)
function handleAddKnowledgeChunk() {
if (isExceedWordCount.value) {
return
}
knowledgeChunkFormRef.value?.validate((valid) => {
if (!valid) {
const newChunkStructInfo = chunkStructList.value.map((chunkItem) => {
......@@ -73,6 +87,10 @@ function handleAddKnowledgeChunk() {
@confirm="handleAddKnowledgeChunk"
>
<template #content>
<p class="text-gray-font-color mb-2.5">
{{ t('personal_space_module.knowledge_module.limit_max_chunk_content_length', { count: currentWordCount }) }}
</p>
<n-scrollbar x-scrollable>
<n-form
ref="knowledgeChunkFormRef"
......@@ -115,15 +133,15 @@ function handleAddKnowledgeChunk() {
minRows: 4,
maxRows: 4,
}"
:maxlength="300"
:maxlength="850"
/>
</div>
</n-form-item>
</n-form>
</n-scrollbar>
<p class="text-gray-font-color mt-2">
{{ t('personal_space_module.knowledge_module.limit_max_chunk_content_length') }}
<p v-show="isExceedWordCount" class="mt-2 text-[#D03050]">
{{ t('personal_space_module.knowledge_module.exceed_max_chunk_content_length') }}
</p>
</template>
</CustomModal>
......
......@@ -38,6 +38,16 @@ const dataTableScrollX = computed(() => {
return props.knowledgeChunkKeyList.length * 215
})
const currentWordCount = computed(() => {
return chunkStructList.value.reduce((acc, cur) => {
return acc + cur.content.length
}, 0)
})
const isExceedWordCount = computed(() => {
return currentWordCount.value > 3000
})
watch(
() => isShow.value,
(newVal) => {
......@@ -79,6 +89,10 @@ function handleAddKnowledgeChunk() {
@confirm="handleAddKnowledgeChunk"
>
<template #content>
<p class="text-gray-font-color mb-2.5">
{{ t('personal_space_module.knowledge_module.limit_max_chunk_content_length', { count: currentWordCount }) }}
</p>
<n-scrollbar x-scrollable>
<n-form
ref="knowledgeChunkFormRef"
......@@ -121,15 +135,15 @@ function handleAddKnowledgeChunk() {
minRows: 4,
maxRows: 4,
}"
:maxlength="300"
:maxlength="850"
/>
</div>
</n-form-item>
</n-form>
</n-scrollbar>
<p class="text-gray-font-color mt-2">
{{ t('personal_space_module.knowledge_module.limit_max_chunk_content_length') }}
<p v-show="isExceedWordCount" class="mt-2 text-[#D03050]">
{{ t('personal_space_module.knowledge_module.exceed_max_chunk_content_length') }}
</p>
</template>
</CustomModal>
......
......@@ -527,6 +527,7 @@ declare namespace I18n {
add_QA_data: string
edit_QA_data: string
limit_max_chunk_content_length: string
exceed_max_chunk_content_length: string
setting_index_desc: string
select_at_least_one_field_as_the_index: string
setting_index: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment