update pay function

This commit is contained in:
2025-11-20 16:59:09 +08:00
parent 7c8310eeb6
commit 8dfd344806
3 changed files with 88 additions and 17 deletions

View File

@@ -87,16 +87,18 @@ export const fetchCategoryTree = async (
* 获取特定节点及其子树
* @param path 节点完整路径(用 | 分隔)
* @param source 数据源类型 ('SMM' | 'Mysteel')
* @param maxDepth 返回的子树最大层级深度默认1层只返回直接子节点
* @returns 节点数据及其子树
*/
export const fetchCategoryNode = async (
path: string,
source: 'SMM' | 'Mysteel'
source: 'SMM' | 'Mysteel',
maxDepth: number = 1
): Promise<TreeNode> => {
try {
const encodedPath = encodeURIComponent(path);
const response = await fetch(
`/category-api/api/category-tree/node?path=${encodedPath}&source=${source}`,
`/category-api/api/category-tree/node?path=${encodedPath}&source=${source}&max_depth=${maxDepth}`,
{
method: 'GET',
headers: {

View File

@@ -349,10 +349,11 @@ const DataBrowser: React.FC = () => {
return newSet;
});
} else {
// 展开节点 - 检查是否需要加载子节点
const needsLoading = !node.children || node.children.length === 0;
// 展开节点 - 始终尝试加载子节点(如果还没加载过)
const hasChildren = node.children && node.children.length > 0;
if (needsLoading) {
// 如果没有子节点数据,尝试从服务器加载
if (!hasChildren) {
// 添加加载状态
setLoadingNodes((prev) => new Set(prev).add(node.path));
@@ -711,6 +712,14 @@ const DataBrowser: React.FC = () => {
unit: result.unit,
description: result.description,
};
// 更新面包屑导航为搜索结果的路径
const pathParts = result.category_path.split(' > ');
setBreadcrumbs(pathParts);
// 清空搜索框,显示树结构
setSearchQuery('');
handleMetricClick(metric);
}}
>