fix(web): add loading

This commit is contained in:
zhaoying
2026-03-19 17:14:43 +08:00
parent f045b59b2d
commit 6bc4f04293
4 changed files with 18 additions and 2 deletions

View File

@@ -1564,6 +1564,7 @@ export const en = {
summary: 'Summary', summary: 'Summary',
core_entities: 'Core Entities', core_entities: 'Core Entities',
communityDetailEmptyDesc: 'Click on a community in the chart on the left to view details', communityDetailEmptyDesc: 'Click on a community in the chart on the left to view details',
communityLoadingTip: 'Generating community graph',
}, },
space: { space: {
createSpace: 'Create Space', createSpace: 'Create Space',

View File

@@ -1562,6 +1562,7 @@ export const zh = {
summary: '摘要', summary: '摘要',
core_entities: '核心实体', core_entities: '核心实体',
communityDetailEmptyDesc: '点击左侧图表中的社区查看详情', communityDetailEmptyDesc: '点击左侧图表中的社区查看详情',
communityLoadingTip: '社区图谱生成中',
}, },
space: { space: {
createSpace: '创建空间', createSpace: '创建空间',

View File

@@ -2,7 +2,7 @@
* @Author: ZhaoYing * @Author: ZhaoYing
* @Date: 2026-02-03 16:27:52 * @Date: 2026-02-03 16:27:52
* @Last Modified by: ZhaoYing * @Last Modified by: ZhaoYing
* @Last Modified time: 2026-03-18 21:25:23 * @Last Modified time: 2026-03-19 17:13:54
*/ */
import { type FC, useRef, useMemo, useCallback } from 'react'; import { type FC, useRef, useMemo, useCallback } from 'react';
import { useNavigate, useParams } from 'react-router-dom'; import { useNavigate, useParams } from 'react-router-dom';
@@ -212,7 +212,7 @@ const ConfigHeader: FC<ConfigHeaderProps> = ({
className={styles.tabs} className={styles.tabs}
/> />
</div> </div>
{application?.type === 'workflow' && source !== 'sharing' {application?.type === 'workflow' && source !== 'sharing' && activeTab === 'arrangement'
? <div className="rb:h-8 rb:flex rb:items-center rb:justify-end rb:gap-2.5"> ? <div className="rb:h-8 rb:flex rb:items-center rb:justify-end rb:gap-2.5">
<FeaturesConfig source={application?.type} value={features as FeaturesConfigForm} refresh={handleSaveFeaturesConfig} /> <FeaturesConfig source={application?.type} value={features as FeaturesConfigForm} refresh={handleSaveFeaturesConfig} />
<Button onClick={clear}>{t('workflow.clear')}</Button> <Button onClick={clear}>{t('workflow.clear')}</Button>

View File

@@ -1,6 +1,8 @@
import React, { useState, type FC, useEffect } from 'react' import React, { useState, type FC, useEffect } from 'react'
import { useParams } from 'react-router-dom' import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { Spin, Flex } from 'antd';
import type { CommunityD3Node, CommunityGraphData, RawCommunityGraphData, RawCommunityNode } from '@/components/D3Graph/types' import type { CommunityD3Node, CommunityGraphData, RawCommunityGraphData, RawCommunityNode } from '@/components/D3Graph/types'
import { buildCommunityGraphData } from '@/components/D3Graph/utils' import { buildCommunityGraphData } from '@/components/D3Graph/utils'
import CommunityGraph from '@/components/D3Graph/CommunityGraph' import CommunityGraph from '@/components/D3Graph/CommunityGraph'
@@ -40,14 +42,17 @@ const NodeTooltip: FC<{ node: CommunityD3Node }> = ({ node }) => {
const CommunityNetwork: FC<{ onSelectCommunity?: (node: RawCommunityNode) => void }> = ({ onSelectCommunity }) => { const CommunityNetwork: FC<{ onSelectCommunity?: (node: RawCommunityNode) => void }> = ({ onSelectCommunity }) => {
const { id } = useParams() const { id } = useParams()
const { t } = useTranslation()
const [graphData, setGraphData] = useState<CommunityGraphData | null>(null) const [graphData, setGraphData] = useState<CommunityGraphData | null>(null)
const [empty, setEmpty] = useState(false) const [empty, setEmpty] = useState(false)
const [loading, setLoading] = useState(false)
useEffect(() => { useEffect(() => {
if (!id) return if (!id) return
const controller = new AbortController() const controller = new AbortController()
setEmpty(false) setEmpty(false)
setGraphData(null) setGraphData(null)
setLoading(true)
getMemoryCommunityGraph(id, { signal: controller.signal }).then(res => { getMemoryCommunityGraph(id, { signal: controller.signal }).then(res => {
const raw = res as RawCommunityGraphData const raw = res as RawCommunityGraphData
if (!raw.nodes?.length) { setEmpty(true); return } if (!raw.nodes?.length) { setEmpty(true); return }
@@ -55,9 +60,18 @@ const CommunityNetwork: FC<{ onSelectCommunity?: (node: RawCommunityNode) => voi
if (!built) { setEmpty(true); return } if (!built) { setEmpty(true); return }
setGraphData(built) setGraphData(built)
}).catch((e) => { if (e?.code !== 'ERR_CANCELED') setEmpty(true) }) }).catch((e) => { if (e?.code !== 'ERR_CANCELED') setEmpty(true) })
.finally(() => setLoading(false))
return () => controller.abort() return () => controller.abort()
}, [id]) }, [id])
if (loading) {
return <Flex align="center" justify="center" className="rb:w-full rb:h-full">
<Spin tip={t('userMemory.communityLoadingTip')} size="large">
<div className="rb:w-64 rb:h-64" />
</Spin>
</Flex>
}
return ( return (
<CommunityGraph <CommunityGraph
data={graphData} data={graphData}