Commit da918964 by YunaiV

【功能新增】AI:知识库文档上传:50%,SplitStep 基本完成

parent aeb59de6
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
:accept="acceptedFileTypes" :accept="acceptedFileTypes"
> >
<div class="flex flex-col items-center justify-center py-20px"> <div class="flex flex-col items-center justify-center py-20px">
<el-icon class="text-[48px] text-[#c0c4cc] mb-10px"><upload-filled /></el-icon> <Icon icon="ep:upload-filled" class="text-[48px] text-[#c0c4cc] mb-10px" />
<div class="el-upload__text text-[16px] text-[#606266]" <div class="el-upload__text text-[16px] text-[#606266]">
>拖拽文件至此,或者 拖拽文件至此,或者
<em class="text-[#409eff] not-italic cursor-pointer">选择文件</em></div <em class="text-[#409eff] not-italic cursor-pointer">选择文件</em>
> </div>
<div class="el-upload__tip mt-10px text-[#909399] text-[12px]"> <div class="el-upload__tip mt-10px text-[#909399] text-[12px]">
已支持 {{ supportedFileTypes.join('、') }},每个文件不超过 {{ maxFileSize }} MB。 已支持 {{ supportedFileTypes.join('、') }},每个文件不超过 {{ maxFileSize }} MB。
</div> </div>
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
class="flex justify-between items-center py-4px px-12px border-l-4 border-l-[#409eff] rounded-sm shadow-sm hover:bg-[#ecf5ff] transition-all duration-300" class="flex justify-between items-center py-4px px-12px border-l-4 border-l-[#409eff] rounded-sm shadow-sm hover:bg-[#ecf5ff] transition-all duration-300"
> >
<div class="flex items-center"> <div class="flex items-center">
<el-icon class="mr-8px text-[#409eff]"><document /></el-icon> <Icon icon="ep:document" class="mr-8px text-[#409eff]" />
<span class="text-[13px] text-[#303133] break-all">{{ file.name }}</span> <span class="text-[13px] text-[#303133] break-all">{{ file.name }}</span>
</div> </div>
<el-button type="danger" link @click="removeFile(index)" class="ml-2"> <el-button type="danger" link @click="removeFile(index)" class="ml-2">
<el-icon><delete /></el-icon> <Icon icon="ep:delete" />
</el-button> </el-button>
</div> </div>
</div> </div>
...@@ -69,10 +69,10 @@ ...@@ -69,10 +69,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import { PropType, ref, computed, inject, getCurrentInstance, onMounted } from 'vue' import { PropType, ref, computed, inject, getCurrentInstance, onMounted } from 'vue'
import { Document, Delete } from '@element-plus/icons-vue' // TODO @芋艿:晚点改
import { useMessage } from '@/hooks/web/useMessage' import { useMessage } from '@/hooks/web/useMessage'
import { useUpload } from '@/components/UploadFile/src/useUpload' import { useUpload } from '@/components/UploadFile/src/useUpload'
import { generateAcceptedFileTypes } from '@/utils' import { generateAcceptedFileTypes } from '@/utils'
import { Icon } from '@/components/Icon'
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
...@@ -173,8 +173,8 @@ const beforeUpload = (file) => { ...@@ -173,8 +173,8 @@ const beforeUpload = (file) => {
* @param file 上传的文件 * @param file 上传的文件
*/ */
const handleUploadSuccess = (response, file) => { const handleUploadSuccess = (response, file) => {
// 添加到文件列表
if (response && response.data) { if (response && response.data) {
// 添加到文件列表
ensureListExists() ensureListExists()
emit('update:modelValue', { emit('update:modelValue', {
...props.modelValue, ...props.modelValue,
......
...@@ -89,19 +89,42 @@ const steps = [{ title: '上传文档' }, { title: '文档分段' }, { title: ' ...@@ -89,19 +89,42 @@ const steps = [{ title: '上传文档' }, { title: '文档分段' }, { title: '
// 表单数据 // 表单数据
const formData = ref({ const formData = ref({
id: undefined, knowlegeId: undefined, // 知识库编号
list: [], // 用于存储上传的文件列表 id: undefined, // 文档编号(documentId)
segmentMaxTokens: 500, // 分段最大 token 数
list: [] as Array<{
name: string
url: string
segments: Array<{
content?: string
contentLength?: number
tokens?: number
}>
}>, // 用于存储上传的文件列表
status: 0 // 0: 草稿, 1: 处理中, 2: 已完成 status: 0 // 0: 草稿, 1: 处理中, 2: 已完成
}) })
/** 初始化数据 */ /** 初始化数据 */
const initData = async () => { const initData = async () => {
// TODO @芋艿:knowlegeId 解析
const documentId = route.params.id as string const documentId = route.params.id as string
if (documentId) { if (documentId) {
// 修改场景 // 修改场景
// 这里需要调用API获取文档数据 // 这里需要调用API获取文档数据
// formData.value = await DocumentApi.getDocument(documentId) // formData.value = await DocumentApi.getDocument(documentId)
} }
// TODO @芋艿:为了开发方便,强制设置
if (false) {
formData.value.list = [
{
name: '项目说明文档.pdf',
url: 'https://static.iocoder.cn/README_yudao.md',
segments: []
}
]
goToNextStep()
}
} }
/** 切换到下一步 */ /** 切换到下一步 */
......
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 sign in to comment