feat(knowledge): 完成知识库基本功能开发

This commit is contained in:
v-zhangjc9
2025-05-28 15:06:30 +08:00
parent f7ed3bd270
commit 3ee6303cf5
30 changed files with 1787 additions and 273 deletions

View File

@@ -10,12 +10,37 @@ const ImportDataDiv = styled.div`
`
const DataImport: React.FC = () => {
const {name} = useParams()
const {knowledge_id} = useParams()
return (
<ImportDataDiv className="import-data h-full">
{amisRender({
type: 'page',
title: `数据导入 (知识库:${name}`,
title: {
type: 'wrapper',
size: 'none',
body: [
'数据导入 (知识库:',
{
type: 'service',
className: 'inline',
api: {
method: 'get',
url: 'http://127.0.0.1:8080/knowledge/name',
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
data: {
id: knowledge_id,
},
},
body: {
type: 'tpl',
tpl: '${name}',
},
},
'',
],
},
body: [
[
{
@@ -53,7 +78,7 @@ const DataImport: React.FC = () => {
name: 'type',
type: 'radios',
label: '数据形式',
value: 'text',
value: 'file',
options: [
{
value: 'text',
@@ -62,7 +87,6 @@ const DataImport: React.FC = () => {
{
value: 'file',
label: '文件',
disabled: true,
},
],
},
@@ -82,10 +106,38 @@ const DataImport: React.FC = () => {
type: 'input-file',
name: 'files',
label: '数据文件',
accept: '.txt,.csv',
autoUpload: false,
drag: true,
multiple: true,
useChunk: true,
accept: '*',
// 5MB 5242880
// 100MB 104857600
// 500MB 524288000
// 1GB 1073741824
maxSize: '',
maxLength: 0,
startChunkApi: {
method: 'post',
url: 'http://127.0.0.1:8080/upload/start',
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
},
chunkApi: {
method: 'post',
url: 'http://127.0.0.1:8080/upload/slice',
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
},
finishChunkApi: {
method: 'post',
url: 'http://127.0.0.1:8080/upload/finish',
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
},
},
{
className: 'text-right',
@@ -103,16 +155,10 @@ const DataImport: React.FC = () => {
},
dataType: 'form',
data: {
mode: '${mode}',
type: '${type}',
content: '${content}',
},
// @ts-ignore
adaptor: (payload, response, api, context) => {
console.log(payload)
return {
items: payload,
}
mode: '${mode|default:undefined}',
type: '${type|default:undefined}',
content: '${content|default:undefined}',
files: '${files|default:undefined}',
},
},
reload: 'preview_list?rows=${items}',
@@ -121,6 +167,22 @@ const DataImport: React.FC = () => {
type: 'submit',
label: '提交',
level: 'primary',
actionType: 'ajax',
api: {
method: 'post',
url: 'http://127.0.0.1:8080/knowledge/submit_text',
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
dataType: 'form',
data: {
id: knowledge_id,
mode: '${mode|default:undefined}',
type: '${type|default:undefined}',
content: '${content|default:undefined}',
files: '${files|default:undefined}',
},
},
},
],
},
@@ -155,6 +217,7 @@ const DataImport: React.FC = () => {
],
listItem: {
body: {
className: 'white-space-pre-line',
type: 'tpl',
tpl: '${text}',
},