feat(ai-web): 完成JPA存储适配

This commit is contained in:
v-zhangjc9
2025-06-23 16:53:34 +08:00
parent e48d7e8649
commit 5b3c27ea48
32 changed files with 458 additions and 493 deletions

View File

@@ -1,6 +1,13 @@
import React from 'react'
import {useNavigate} from 'react-router'
import {amisRender, commonInfo, crudCommonOptions, mappingField, mappingItem} from '../../../util/amis.tsx'
import {
amisRender,
commonInfo,
crudCommonOptions,
mappingField,
mappingItem,
paginationTemplate,
} from '../../../util/amis.tsx'
const strategyMapping = [
mappingItem('文本', 'Cosine'),
@@ -25,62 +32,74 @@ const Knowledge: React.FC = () => {
body: [
{
type: 'crud',
api: `${commonInfo.baseAiUrl}/knowledge/list`,
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/list`,
data: {
page: {
index: '${page}',
size: '${perPage}',
}
}
},
...crudCommonOptions(),
headerToolbar: [
'reload',
{
type: 'action',
label: '',
icon: 'fa fa-plus',
tooltip: '新增',
tooltipPlacement: 'top',
actionType: 'dialog',
dialog: {
title: '新增知识库',
size: 'md',
body: {
type: 'form',
api: {
url: `${commonInfo.baseAiUrl}/knowledge/add`,
dataType: 'form',
...paginationTemplate(
10,
5,
[
{
type: 'action',
label: '',
icon: 'fa fa-plus',
tooltip: '新增',
tooltipPlacement: 'top',
actionType: 'dialog',
dialog: {
title: '新增知识库',
size: 'md',
body: {
type: 'form',
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/save`,
},
body: [
{
type: 'input-text',
name: 'name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
},
{
type: 'select',
name: 'strategy',
label: '类型',
value: 'Cosine',
required: true,
options: [
{
label: '文本',
value: 'Cosine',
},
{
label: '图片',
value: 'Euclid',
disabled: true,
},
],
},
],
},
body: [
{
type: 'input-text',
name: 'name',
label: '名称',
required: true,
},
{
type: 'textarea',
name: 'description',
label: '描述',
required: true,
},
{
type: 'select',
name: 'strategy',
label: '类型',
value: 'Cosine',
required: true,
options: [
{
label: '文本',
value: 'Cosine',
},
{
label: '图片',
value: 'Euclid',
disabled: true,
},
],
},
],
},
},
},
],
],
),
columns: [
{
name: 'name',
@@ -128,13 +147,12 @@ const Knowledge: React.FC = () => {
api: {
method: 'post',
url: `${commonInfo.baseAiUrl}/knowledge/update_description`,
dataType: 'form',
},
mode: 'normal',
body: [
{
type: 'hidden',
name: "id",
name: 'id',
// value: '${id}',
},
{
@@ -142,10 +160,10 @@ const Knowledge: React.FC = () => {
name: 'description',
label: '描述',
required: true,
}
]
}
}
},
],
},
},
},
{
type: 'action',
@@ -192,17 +210,8 @@ const Knowledge: React.FC = () => {
level: 'link',
size: 'sm',
actionType: 'ajax',
api: {
method: 'get',
url: `${commonInfo.baseAiUrl}/knowledge/delete`,
headers: {
'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==',
},
data: {
id: '${id}',
},
},
confirmText: '确认删除',
api: `get:${commonInfo.baseAiUrl}/knowledge/remove/\${id}`,
confirmText: '确认删除知识库:${name}',
confirmTitle: '删除',
},
],