Skip to content

Commit de0321f

Browse files
committed
refactor: 更新组件导入路径
1 parent 8e4e30c commit de0321f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { AlgorithmProvider, useAlgorithm } from './context/AlgorithmContext';
1+
import { AlgorithmProvider } from './context/AlgorithmContext';
2+
import { useAlgorithm } from './context/useAlgorithm';
23
import { Header } from './components/Header';
34
import { DataInput } from './components/DataInput';
45
import { CodePanel } from './components/CodePanel';

src/components/CodePanel/CodePanel.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef } from 'react';
1+
import { useEffect, useRef, useMemo } from 'react';
22
import Prism from 'prismjs';
33
import 'prismjs/components/prism-java';
44
import 'prismjs/components/prism-python';
@@ -59,9 +59,12 @@ export function CodePanel({ currentStep, selectedLanguage, onLanguageChange }: C
5959

6060
const snippet = codeSnippets.find(s => s.language === selectedLanguage);
6161
const codeLines = snippet?.code.split('\n') || [];
62-
const highlightedLines = currentStep
63-
? getHighlightedLines(selectedLanguage, currentStep.type)
64-
: [];
62+
63+
const highlightedLines = useMemo(() => {
64+
return currentStep
65+
? getHighlightedLines(selectedLanguage, currentStep.type)
66+
: [];
67+
}, [currentStep, selectedLanguage]);
6568

6669
useEffect(() => {
6770
if (codeRef.current) {

0 commit comments

Comments
 (0)