Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7cd6a5d9
authored
Feb 28, 2025
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能新增】AI:知识库文档上传:20%,UploadStep 基本搭建出来
parent
b7d7b11d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
6 deletions
+59
-6
src/utils/index.ts
+58
-0
src/views/ai/knowledge/document/create/UploadStep.vue
+0
-0
src/views/ai/knowledge/document/create/index.vue
+1
-6
No files found.
src/utils/index.ts
View file @
7cd6a5d9
...
@@ -117,6 +117,64 @@ export function toAnyString() {
...
@@ -117,6 +117,64 @@ export function toAnyString() {
}
}
/**
/**
* 根据支持的文件类型生成 accept 属性值
*
* @param supportedFileTypes 支持的文件类型数组,如 ['PDF', 'DOC', 'DOCX']
* @returns 用于文件上传组件 accept 属性的字符串
*/
export
const
generateAcceptedFileTypes
=
(
supportedFileTypes
:
string
[]):
string
=>
{
const
allowedExtensions
=
supportedFileTypes
.
map
((
ext
)
=>
ext
.
toLowerCase
())
const
mimeTypes
:
string
[]
=
[]
// 添加常见的 MIME 类型映射
if
(
allowedExtensions
.
includes
(
'txt'
))
{
mimeTypes
.
push
(
'text/plain'
)
}
if
(
allowedExtensions
.
includes
(
'pdf'
))
{
mimeTypes
.
push
(
'application/pdf'
)
}
if
(
allowedExtensions
.
includes
(
'html'
)
||
allowedExtensions
.
includes
(
'htm'
))
{
mimeTypes
.
push
(
'text/html'
)
}
if
(
allowedExtensions
.
includes
(
'csv'
))
{
mimeTypes
.
push
(
'text/csv'
)
}
if
(
allowedExtensions
.
includes
(
'xlsx'
)
||
allowedExtensions
.
includes
(
'xls'
))
{
mimeTypes
.
push
(
'application/vnd.ms-excel'
)
mimeTypes
.
push
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
}
if
(
allowedExtensions
.
includes
(
'docx'
)
||
allowedExtensions
.
includes
(
'doc'
))
{
mimeTypes
.
push
(
'application/msword'
)
mimeTypes
.
push
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
)
}
if
(
allowedExtensions
.
includes
(
'pptx'
)
||
allowedExtensions
.
includes
(
'ppt'
))
{
mimeTypes
.
push
(
'application/vnd.ms-powerpoint'
)
mimeTypes
.
push
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
)
}
if
(
allowedExtensions
.
includes
(
'xml'
))
{
mimeTypes
.
push
(
'application/xml'
)
mimeTypes
.
push
(
'text/xml'
)
}
if
(
allowedExtensions
.
includes
(
'md'
)
||
allowedExtensions
.
includes
(
'markdown'
))
{
mimeTypes
.
push
(
'text/markdown'
)
}
if
(
allowedExtensions
.
includes
(
'epub'
))
{
mimeTypes
.
push
(
'application/epub+zip'
)
}
if
(
allowedExtensions
.
includes
(
'eml'
))
{
mimeTypes
.
push
(
'message/rfc822'
)
}
if
(
allowedExtensions
.
includes
(
'msg'
))
{
mimeTypes
.
push
(
'application/vnd.ms-outlook'
)
}
// 添加文件扩展名
const
extensions
=
allowedExtensions
.
map
((
ext
)
=>
`.
${
ext
}
`
)
return
[...
mimeTypes
,
...
extensions
].
join
(
','
)
}
/**
* 首字母大写
* 首字母大写
*/
*/
export
function
firstUpperCase
(
str
:
string
)
{
export
function
firstUpperCase
(
str
:
string
)
{
...
...
src/views/ai/knowledge/document/create/UploadStep.vue
View file @
7cd6a5d9
This diff is collapsed.
Click to expand it.
src/views/ai/knowledge/document/create/index.vue
View file @
7cd6a5d9
...
@@ -90,12 +90,7 @@ const steps = [{ title: '上传文档' }, { title: '文档分段' }, { title: '
...
@@ -90,12 +90,7 @@ const steps = [{ title: '上传文档' }, { title: '文档分段' }, { title: '
// 表单数据
// 表单数据
const
formData
=
ref
({
const
formData
=
ref
({
id
:
undefined
,
id
:
undefined
,
name
:
''
,
list
:
[],
// 用于存储上传的文件列表
knowledgeBaseId
:
undefined
,
documentType
:
undefined
,
content
:
''
,
file
:
null
,
segments
:
[],
status
:
0
// 0: 草稿, 1: 处理中, 2: 已完成
status
:
0
// 0: 草稿, 1: 处理中, 2: 已完成
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment