mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-10-13 16:57:24 +08:00
fix(frontend): follow configured upload limit in hints (#4110)
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
import { MAX_FILE_SIZE_MB } from '@/utils'
|
||||
</script>
|
||||
<template>
|
||||
<div class="empty">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('knowledgeBase.emptyKnowledgeDragDrop') }}</span>
|
||||
<span class="empty-type-txt">{{ $t('knowledgeBase.pdfDocFormat') }}</span>
|
||||
<span class="empty-type-txt">{{ $t('knowledgeBase.textMarkdownFormat') }}</span>
|
||||
<span class="empty-type-txt">{{ $t('knowledgeBase.pdfDocFormat', { size: MAX_FILE_SIZE_MB }) }}</span>
|
||||
<span class="empty-type-txt">{{ $t('knowledgeBase.textMarkdownFormat', { size: MAX_FILE_SIZE_MB }) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import enUS from '../i18n/locales/en-US.ts'
|
||||
import jaJP from '../i18n/locales/ja-JP.ts'
|
||||
import koKR from '../i18n/locales/ko-KR.ts'
|
||||
import ruRU from '../i18n/locales/ru-RU.ts'
|
||||
import zhCN from '../i18n/locales/zh-CN.ts'
|
||||
import zhTW from '../i18n/locales/zh-TW.ts'
|
||||
|
||||
const messages = {
|
||||
'en-US': enUS,
|
||||
'ja-JP': jaJP,
|
||||
'ko-KR': koKR,
|
||||
'ru-RU': ruRU,
|
||||
'zh-CN': zhCN,
|
||||
'zh-TW': zhTW,
|
||||
}
|
||||
|
||||
test('knowledge upload hints interpolate the configured limit in every locale', () => {
|
||||
const size = 73
|
||||
|
||||
for (const locale of Object.keys(messages)) {
|
||||
const i18n = createI18n({ legacy: false, locale, messages })
|
||||
const pdfDoc = i18n.global.t('knowledgeBase.pdfDocFormat', { size })
|
||||
const textMarkdown = i18n.global.t('knowledgeBase.textMarkdownFormat', { size })
|
||||
|
||||
assert.match(pdfDoc, /73/, `${locale}: pdf/doc hint`)
|
||||
assert.match(textMarkdown, /73/, `${locale}: text/markdown hint`)
|
||||
}
|
||||
})
|
||||
|
||||
test('empty state and drag overlay pass the runtime limit to both upload hints', () => {
|
||||
for (const name of ['empty-knowledge.vue', 'upload-mask.vue']) {
|
||||
const source = readFileSync(new URL(`./${name}`, import.meta.url), 'utf8')
|
||||
|
||||
assert.match(source, /import \{ MAX_FILE_SIZE_MB \} from '@\/utils'/)
|
||||
assert.match(
|
||||
source,
|
||||
/\$t\('knowledgeBase\.pdfDocFormat', \{ size: MAX_FILE_SIZE_MB \}\)/,
|
||||
`${name}: pdf/doc hint`,
|
||||
)
|
||||
assert.match(
|
||||
source,
|
||||
/\$t\('knowledgeBase\.textMarkdownFormat', \{ size: MAX_FILE_SIZE_MB \}\)/,
|
||||
`${name}: text/markdown hint`,
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -1,13 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
import { MAX_FILE_SIZE_MB } from '@/utils'
|
||||
</script>
|
||||
<template>
|
||||
<div class="mask">
|
||||
<img class="upload-mask-img" src="@/assets/img/upload-mask.svg" alt="">
|
||||
<span class="drag-txt">{{ $t('file.upload') }}</span>
|
||||
<span class="drag-type-txt">{{ $t('knowledgeBase.pdfDocFormat') }}</span>
|
||||
<span class="drag-type-txt">{{ $t('knowledgeBase.textMarkdownFormat') }}</span>
|
||||
<span class="drag-type-txt">{{ $t('knowledgeBase.pdfDocFormat', { size: MAX_FILE_SIZE_MB }) }}</span>
|
||||
<span class="drag-type-txt">{{ $t('knowledgeBase.textMarkdownFormat', { size: MAX_FILE_SIZE_MB }) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -973,8 +973,8 @@ export default {
|
||||
statusDraft: 'Draft',
|
||||
noDescription: 'No description',
|
||||
emptyKnowledgeDragDrop: 'Knowledge is empty, drag and drop to upload',
|
||||
pdfDocFormat: 'pdf, doc format files, max 10M',
|
||||
textMarkdownFormat: 'text, markdown format files, max 200K',
|
||||
pdfDocFormat: 'pdf, doc format files, max {size}MB',
|
||||
textMarkdownFormat: 'text, markdown format files, max {size}MB',
|
||||
dragFileNotText: 'Please drag files instead of text or links',
|
||||
searchPlaceholder: 'Search knowledge bases...',
|
||||
docSearchPlaceholder: 'Search document names...',
|
||||
|
||||
@@ -973,8 +973,8 @@ export default {
|
||||
statusDraft: '下書き',
|
||||
noDescription: '説明なし',
|
||||
emptyKnowledgeDragDrop: 'ナレッジがありません。ドラッグ&ドロップでアップロードできます',
|
||||
pdfDocFormat: 'pdf、doc形式のファイル、最大10M',
|
||||
textMarkdownFormat: 'text、markdown形式のファイル、最大200K',
|
||||
pdfDocFormat: 'pdf、doc形式のファイル、最大{size}MB',
|
||||
textMarkdownFormat: 'text、markdown形式のファイル、最大{size}MB',
|
||||
dragFileNotText: 'テキストやリンクではなくファイルをドラッグしてください',
|
||||
searchPlaceholder: 'ナレッジベースを検索...',
|
||||
docSearchPlaceholder: 'ドキュメント名を検索...',
|
||||
|
||||
@@ -7370,8 +7370,8 @@ export default {
|
||||
statusDraft: '초안',
|
||||
noDescription: '설명 없음',
|
||||
emptyKnowledgeDragDrop: '지식이 비어 있음, 드래그 앤 드롭으로 업로드',
|
||||
pdfDocFormat: 'pdf, doc 형식 파일, 최대 10MB',
|
||||
textMarkdownFormat: 'text, markdown 형식 파일, 최대 200KB',
|
||||
pdfDocFormat: 'pdf, doc 형식 파일, 최대 {size}MB',
|
||||
textMarkdownFormat: 'text, markdown 형식 파일, 최대 {size}MB',
|
||||
dragFileNotText: '텍스트나 링크가 아닌 파일을 드래그하세요',
|
||||
searchPlaceholder: '지식베이스 검색...',
|
||||
docSearchPlaceholder: '문서 이름 검색...',
|
||||
|
||||
@@ -7370,8 +7370,8 @@ export default {
|
||||
statusDraft: 'Черновик',
|
||||
noDescription: 'Нет описания',
|
||||
emptyKnowledgeDragDrop: 'База знаний пуста, перетащите файлы для загрузки',
|
||||
pdfDocFormat: 'Файлы pdf, doc формата, не более 10 МБ',
|
||||
textMarkdownFormat: 'Файлы text, markdown формата, не более 200 КБ',
|
||||
pdfDocFormat: 'Файлы pdf, doc формата, не более {size} МБ',
|
||||
textMarkdownFormat: 'Файлы text, markdown формата, не более {size} МБ',
|
||||
dragFileNotText: 'Пожалуйста, перетащите файлы, а не текст или ссылки',
|
||||
searchPlaceholder: 'Поиск по базам знаний...',
|
||||
docSearchPlaceholder: 'Поиск документов...',
|
||||
|
||||
@@ -7372,8 +7372,8 @@ export default {
|
||||
statusDraft: '草稿',
|
||||
noDescription: '无描述',
|
||||
emptyKnowledgeDragDrop: '知识为空,拖放上传',
|
||||
pdfDocFormat: 'pdf、doc 格式文件,不超过10M',
|
||||
textMarkdownFormat: 'text、markdown格式文件,不超过200K',
|
||||
pdfDocFormat: 'pdf、doc 格式文件,不超过{size}M',
|
||||
textMarkdownFormat: 'text、markdown格式文件,不超过{size}M',
|
||||
dragFileNotText: '请拖拽文件而不是文本或链接',
|
||||
searchPlaceholder: '搜索知识库...',
|
||||
docSearchPlaceholder: '搜索文档名称...',
|
||||
|
||||
@@ -7372,8 +7372,8 @@ export default {
|
||||
statusDraft: '草稿',
|
||||
noDescription: '無描述',
|
||||
emptyKnowledgeDragDrop: '知識為空,拖放上傳',
|
||||
pdfDocFormat: 'pdf、doc 格式檔案,不超過10M',
|
||||
textMarkdownFormat: 'text、markdown格式檔案,不超過200K',
|
||||
pdfDocFormat: 'pdf、doc 格式檔案,不超過{size}M',
|
||||
textMarkdownFormat: 'text、markdown格式檔案,不超過{size}M',
|
||||
dragFileNotText: '請拖曳檔案而不是文字或連結',
|
||||
searchPlaceholder: '搜尋知識庫...',
|
||||
docSearchPlaceholder: '搜尋檔案名稱...',
|
||||
|
||||
Reference in New Issue
Block a user