[fix]修复服务启动 (#3)

This commit is contained in:
lanceyq
2025-12-04 18:50:09 +08:00
committed by GitHub
parent b9c705998b
commit 0117194a67
23 changed files with 675 additions and 269 deletions

View File

@@ -58,6 +58,7 @@ interface FolderTreeProps {
style?: CSSProperties;
refreshKey?: number;
onRootLoad?: (nodes: TreeNodeData[] | null) => void;
onFolderPathChange?: (path: Array<{ id: string; name: string }>) => void;
}
const renderIcon = (icon?: string) => {
@@ -271,6 +272,7 @@ const FolderTree: FC<FolderTreeProps> = ({
style,
refreshKey = 0,
onRootLoad,
onFolderPathChange,
}) => {
const [treeData, setTreeData] = useState<TreeNodeData[]>([]);
@@ -347,6 +349,42 @@ const FolderTree: FC<FolderTreeProps> = ({
}
};
// 查找节点路径的辅助函数
const findNodePath = (nodes: TreeNodeData[], targetKey: Key, currentPath: Array<{ id: string; name: string }> = []): Array<{ id: string; name: string }> | null => {
for (const node of nodes) {
const newPath = [...currentPath, { id: String(node.key), name: String(node.title) }];
if (node.key === targetKey) {
return newPath;
}
if (node.children) {
const found = findNodePath(node.children, targetKey, newPath);
if (found) {
return found;
}
}
}
return null;
};
// 处理选择事件,计算并传递路径
const handleSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
if (selectedKeys.length > 0) {
const path = findNodePath(treeData, selectedKeys[0]);
if (path && onFolderPathChange) {
onFolderPathChange(path);
}
} else if (onFolderPathChange) {
onFolderPathChange([]);
}
// 调用原始的 onSelect 回调
if (onSelect) {
onSelect(selectedKeys, info);
}
};
const treeNodes = useMemo(() => transformTreeData(treeData), [treeData]);
return (
@@ -354,7 +392,7 @@ const FolderTree: FC<FolderTreeProps> = ({
multiple={multiple}
className={className}
style={style}
onSelect={onSelect}
onSelect={handleSelect}
onExpand={onExpand}
loadData={onLoadData}
treeData={treeNodes}

View File

@@ -4,7 +4,7 @@
* @Author: yujiangping
* @Date: 2025-11-10 18:52:55
* @LastEditors: yujiangping
* @LastEditTime: 2025-11-25 17:46:36
* @LastEditTime: 2025-12-03 18:44:58
*/
import { forwardRef, useImperativeHandle, useState } from 'react';
import { Switch } from 'antd';
@@ -24,7 +24,7 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
const [messageApi, contextHolder] = message.useMessage();
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false)
const [curIndex, setCurIndex] = useState(9999);
const [curIndex, setCurIndex] = useState(-1);
const [kbId, setKbId] = useState<string>('');
const [spaceIds, setSpaceIds] = useState<string>('');
const [knowledgeBase, setKnowledgeBase] = useState<KnowledgeBase | null>(null);
@@ -32,7 +32,7 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
// 封装取消方法,添加关闭弹窗逻辑
const handleClose = () => {
setCurIndex(9999);
setCurIndex(-1);
setLoading(false)
setVisible(false);
};
@@ -53,8 +53,13 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
// 获取所有 checked 为 true 的数据
const checkedItems = spaceList.filter(item => item.is_active);
debugger
// 获取当前选中的项curIndex 对应的数据)
const selectedItem = curIndex !== 9999 ? spaceList[curIndex] : null;
const selectedItem = curIndex !== -1 ? spaceList[curIndex] : null;
if(!selectedItem){
messageApi.error(t('knowledgeBase.selectSpace'));
return;
}
const payload = {
source_kb_id: kbId ?? '',
target_workspace_id: selectedItem?.id ?? '',