set port (#39)

* set port

* add knowledge-search

* update text
This commit is contained in:
yqj123
2024-01-19 18:35:24 +08:00
committed by GitHub
parent 103e12b7c2
commit f3dd131403
15 changed files with 534 additions and 31 deletions

View File

@ -1,5 +1,5 @@
import { connect, useNavigate, useLocation, Dispatch } from 'umi'
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useMemo } from 'react';
import type { MenuProps } from 'antd';
import { Menu } from 'antd';
import {
@ -70,8 +70,10 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
label: React.ReactNode,
key: React.Key,
icon?: React.ReactNode,
disabled?: boolean,
children?: MenuItem[],
type?: 'group',
): MenuItem {
return {
key,
@ -79,13 +81,17 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
children,
label,
type,
disabled
} as MenuItem;
}
const items: MenuItem[] = [
getItem('配置', 'setting', <ToolOutlined />),
getItem('知识库', 'file', <BarsOutlined />),
getItem('搜索测试', 'search', <SearchOutlined />),
];
const items: MenuItem[] = useMemo(() => {
const disabled = !id
return [
getItem('配置', 'setting', <ToolOutlined />),
getItem('知识库', 'file', <BarsOutlined />, disabled),
getItem('搜索测试', 'search', <SearchOutlined />, disabled),
]
}, [id]);
const handleSelect: MenuProps['onSelect'] = (e) => {
navigate(`/knowledge/add/setting?activeKey=${e.key}&id=${id}`);
}
@ -105,7 +111,7 @@ const Index: React.FC<kAProps> = ({ kAModel, dispatch }) => {
<div className={styles.content}>
{activeKey === 'file' && !doc_id && <File kb_id={id} />}
{activeKey === 'setting' && <Setting kb_id={id} />}
{activeKey === 'search' && <Search />}
{activeKey === 'search' && <Search kb_id={id} />}
{activeKey === 'file' && !!doc_id && <Chunk doc_id={doc_id} />}
</div>