Skip to content

Commit d0fa9e1

Browse files
authored
Merge pull request #91 from DMU-DebugVisual/inseong
비효율 개선
2 parents 90b16ad + f72ccbd commit d0fa9e1

File tree

3 files changed

+61
-7
lines changed

3 files changed

+61
-7
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
"web-vitals": "^2.1.4"
2222
},
2323
"scripts": {
24-
"prestart": "node scripts/generate-examples.js",
25-
"prebuild": "node scripts/generate-examples.js",
2624
"start": "react-scripts start",
2725
"build": "react-scripts build",
2826
"test": "react-scripts test",

src/components/ide/IDE.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Editor from '@monaco-editor/react';
66
import VisualizationModal from './VisualizationModal';
77
import './IDE.css';
88
import config from '../../config';
9-
import { jsonExamples } from '../../generated-examples.js';
9+
import { jsonExamples } from './mockData/index.js';
1010

1111
// 🎨 Feather Icons CDN 로드
1212
if (!document.querySelector('script[src*="feather"]')) {

src/components/ide/mockData/index.js

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,68 @@
66
* 🗂️ JSON 기반 Mock 데이터 매니저
77
*/
88

9-
// JSON 파일들을 동적으로 import하는 함수
9+
// JSON 파일들 직접 import
10+
import binaryTreeJson from './binaryTree.json';
11+
import bubbleSortJson from './bubbleSort.json';
12+
import fibonacciJson from './fibonacci.json';
13+
import graphJson from './graph.json';
14+
import heapJson from './heap.json';
15+
import linkedListJson from './linkedList.json';
16+
17+
// JSON 예제 파일들을 객체 형태로 export
18+
export const jsonExamples = [
19+
{
20+
name: 'binaryTree.json',
21+
type: 'json',
22+
code: JSON.stringify(binaryTreeJson, null, 2)
23+
},
24+
{
25+
name: 'bubbleSort.json',
26+
type: 'json',
27+
code: JSON.stringify(bubbleSortJson, null, 2)
28+
},
29+
{
30+
name: 'fibonacci.json',
31+
type: 'json',
32+
code: JSON.stringify(fibonacciJson, null, 2)
33+
},
34+
{
35+
name: 'graph.json',
36+
type: 'json',
37+
code: JSON.stringify(graphJson, null, 2)
38+
},
39+
{
40+
name: 'heap.json',
41+
type: 'json',
42+
code: JSON.stringify(heapJson, null, 2)
43+
},
44+
{
45+
name: 'linkedList.json',
46+
type: 'json',
47+
code: JSON.stringify(linkedListJson, null, 2)
48+
}
49+
];
50+
51+
// JSON 데이터 객체 매핑 (파일명 -> 원본 JSON 데이터)
52+
const jsonDataMap = {
53+
'binaryTree': binaryTreeJson,
54+
'bubbleSort': bubbleSortJson,
55+
'fibonacci': fibonacciJson,
56+
'graph': graphJson,
57+
'heap': heapJson,
58+
'linkedList': linkedListJson
59+
};
60+
61+
// JSON 파일들을 동적으로 import하는 함수 (호환성 유지)
1062
const importJsonFile = async (filename) => {
1163
try {
12-
// 동적 import로 JSON 파일 로드
13-
const module = await import(`./${filename}.json`);
14-
return module.default;
64+
// 캐시된 데이터에서 찾기
65+
const jsonData = jsonDataMap[filename];
66+
if (jsonData) {
67+
return jsonData;
68+
}
69+
console.warn(`⚠️ JSON 파일을 찾을 수 없습니다: ${filename}.json`);
70+
return null;
1571
} catch (error) {
1672
console.warn(`⚠️ JSON 파일 로드 실패: ${filename}.json`, error);
1773
return null;

0 commit comments

Comments
 (0)