Skip to content

Commit ed7b99d

Browse files
committed
fix(viewer): 英文版 bundled 项目正确加载精挑布局(用 activeRepoId 而非 manifest.repo)
1 parent dd01140 commit ed7b99d

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

viewer/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ export default function App() {
536536
<div className="relative flex-1">
537537
{file ? (
538538
<ReactFlowProvider key={activeRepoId ?? 'default'}>
539-
<GraphCanvas file={file} />
539+
<GraphCanvas file={file} activeRepoId={activeRepoId} />
540540
</ReactFlowProvider>
541541
) : (
542542
<EmptyState

viewer/src/graph/GraphCanvas.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import type { LaidOutNode, LayoutGroup } from './layout'
4747

4848
interface Props {
4949
file: FeaturesFile
50+
/** 上层传入的项目 id(用于 bundled 项目识别 + localStorage 分桶)。
51+
* 没有时退化为 file.manifest.repo。 */
52+
activeRepoId?: string | null
5053
}
5154

5255
const nodeTypes = {
@@ -64,11 +67,11 @@ function viewKeyOf(state: FcgViewState): string {
6467
: state.mode
6568
}
6669

67-
export function GraphCanvas({ file }: Props) {
68-
return <GraphInner file={file} />
70+
export function GraphCanvas({ file, activeRepoId }: Props) {
71+
return <GraphInner file={file} activeRepoId={activeRepoId} />
6972
}
7073

71-
function GraphInner({ file }: Props) {
74+
function GraphInner({ file, activeRepoId }: Props) {
7275
const [state, setState] = useState<FcgViewState>({ mode: 'overview' })
7376
const [selectedId, setSelectedId] = useState<string | null>(null)
7477
/** hover 节点 id:用于实时降噪——hover 时其他节点和边淡出,相关边加亮 */
@@ -78,10 +81,10 @@ function GraphInner({ file }: Props) {
7881
const view = useMemo(() => buildView(file, state), [file, state])
7982
const viewKey = viewKeyOf(state)
8083

81-
// 项目标识:用于 localStorage 分桶
84+
// 项目标识:上层传入优先(bundled 项目用 bundled:slug 作识别),回退到 manifest.repo
8285
const repoId = useMemo(
83-
() => file.manifest.repo ?? 'default',
84-
[file.manifest.repo],
86+
() => activeRepoId ?? file.manifest.repo ?? 'default',
87+
[activeRepoId, file.manifest.repo],
8588
)
8689

8790
// 节点位置缓存(按 viewKey 分桶):启动时从 localStorage 加载(草稿)

0 commit comments

Comments
 (0)