Skip to content

Commit df1c006

Browse files
committed
Merge remote-tracking branch 'origin/dongjun'
2 parents d82c75c + 9799218 commit df1c006

3 files changed

Lines changed: 59 additions & 114 deletions

File tree

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/ide/IDE.css

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,12 @@ input:checked + .slider:before {
254254
width: 100%;
255255
}
256256

257-
/* 인증 사이드바 스타일 */
257+
/* 인증 사이드바 스타일 - 수정됨 */
258258
.auth-sidebar {
259259
display: flex;
260260
flex-direction: column;
261261
height: 100%;
262+
padding: 0;
262263
}
263264

264265
.auth-header {
@@ -280,23 +281,23 @@ input:checked + .slider:before {
280281
flex: 1;
281282
display: flex;
282283
flex-direction: column;
283-
padding: 20px;
284-
/* justify-content: center; 제거 */
284+
padding: 24px 20px;
285285
align-items: center;
286-
gap: 20px;
287-
padding-top: 40px; /* 상단 패딩 추가 */
288286
}
289287

290288
.auth-message {
291289
text-align: center;
292290
color: var(--text-light);
293291
font-size: 14px;
294292
line-height: 1.6;
295-
margin-bottom: 20px; /* 여백 증가 */
293+
margin-bottom: 15px;
296294
}
297295

298-
.auth-message p {
299-
margin-bottom: 10px;
296+
.auth-buttons {
297+
display: flex;
298+
flex-direction: column;
299+
gap: 12px;
300+
width: 100%;
300301
}
301302

302303
.auth-button {
@@ -312,6 +313,7 @@ input:checked + .slider:before {
312313
cursor: pointer;
313314
transition: var(--transition);
314315
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
316+
border: none;
315317
}
316318

317319
.login-button.auth-button {
@@ -327,13 +329,14 @@ input:checked + .slider:before {
327329
}
328330

329331
.signup-button.auth-button {
330-
background-color: #333333;
332+
background-color: rgba(126, 87, 194, 0.15);
331333
color: var(--primary);
332-
border: 1px solid var(--primary);
334+
border: 1px solid rgba(126, 87, 194, 0.3);
333335
}
334336

335337
.signup-button.auth-button:hover {
336-
background-color: rgba(126, 87, 194, 0.15);
338+
background-color: rgba(126, 87, 194, 0.25);
339+
transform: translateY(-1px);
337340
}
338341

339342
.main-header {

src/components/ide/IDE.jsx

Lines changed: 44 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,14 @@ const IDE = () => {
143143
// 비회원이면 API 호출 안함
144144
if (!isLoggedIn) return;
145145

146-
try {
147-
const response = await fetch('/api/files');
148-
149-
if (!response.ok) {
150-
throw new Error('파일 목록 불러오기 실패');
151-
}
152-
153-
const files = await response.json();
154-
setSavedFiles(files);
155-
} catch (error) {
156-
console.error('파일 목록 불러오기 오류:', error);
157-
// 오류 시 기본 파일 목록 유지
158-
}
146+
// 임시 로컬 파일 목록 사용
147+
const localFiles = [
148+
{ name: "untitled.py", code: '# 여기에 코드를 입력하세요' },
149+
{ name: "example.py", code: 'print("Hello, World!")' },
150+
{ name: "test.js", code: 'console.log("Testing JavaScript");' }
151+
];
152+
153+
setSavedFiles(localFiles);
159154
};
160155

161156
// 회원 상태가 변경될 때 파일 목록 갱신
@@ -217,26 +212,32 @@ const IDE = () => {
217212
// 현재 에디터의 값을 가져옴
218213
const currentCode = editorRef.current.getValue();
219214

220-
// API 호출
221-
const response = await fetch('/api/execute', {
215+
// HTML 예시처럼 API 호출
216+
const response = await fetch('http://localhost:4000/api/run', {
222217
method: 'POST',
223218
headers: {
224219
'Content-Type': 'application/json',
225220
},
226221
body: JSON.stringify({
227222
code: currentCode,
228-
language: selectedLanguage,
229-
fileName: fileName,
223+
lang: selectedLanguage,
230224
input: input
231225
}),
232226
});
233227

228+
console.log('보내는 데이터:', JSON.stringify({
229+
code: currentCode,
230+
lang: selectedLanguage,
231+
input: input
232+
}));
233+
234234
if (!response.ok) {
235235
throw new Error('API 호출 실패');
236236
}
237237

238-
const result = await response.json();
239-
setOutput(result.output || "실행 결과가 없습니다.");
238+
// HTML 예시처럼 text로 응답을 받음
239+
const result = await response.text();
240+
setOutput(result || "실행 결과가 없습니다.");
240241
} catch (error) {
241242
console.error('코드 실행 중 오류:', error);
242243

@@ -297,7 +298,7 @@ const IDE = () => {
297298
};
298299

299300
// 파일 저장 함수
300-
const handleSave = async () => {
301+
const handleSave = () => {
301302
// 비회원은 로그인 유도
302303
if (!isLoggedIn) {
303304
alert("로그인 후 이용 가능한 기능입니다.");
@@ -308,27 +309,6 @@ const IDE = () => {
308309
// 현재 에디터의 값을 가져옴
309310
const currentCode = editorRef.current.getValue();
310311

311-
// API 호출
312-
const response = await fetch('/api/save', {
313-
method: 'POST',
314-
headers: {
315-
'Content-Type': 'application/json',
316-
},
317-
body: JSON.stringify({
318-
code: currentCode,
319-
fileName: fileName,
320-
language: selectedLanguage
321-
}),
322-
});
323-
324-
if (!response.ok) {
325-
throw new Error('파일 저장 실패');
326-
}
327-
328-
// 저장 성공
329-
setIsSaved(true);
330-
setCode(currentCode);
331-
332312
// 로컬 상태 업데이트
333313
const existingFileIndex = savedFiles.findIndex((file) => file.name === fileName);
334314

@@ -342,78 +322,38 @@ const IDE = () => {
342322
setSavedFiles([...savedFiles, { name: fileName, code: currentCode }]);
343323
}
344324

325+
setIsSaved(true);
326+
setCode(currentCode);
345327
toast("파일이 저장되었습니다.");
346328
} catch (error) {
347329
console.error('파일 저장 중 오류:', error);
348-
349-
// API 오류 시 로컬만 업데이트
350-
const currentCode = editorRef.current.getValue();
351-
const existingFileIndex = savedFiles.findIndex((file) => file.name === fileName);
352-
353-
if (existingFileIndex >= 0) {
354-
// 기존 파일 업데이트
355-
const updatedFiles = [...savedFiles];
356-
updatedFiles[existingFileIndex] = { name: fileName, code: currentCode };
357-
setSavedFiles(updatedFiles);
358-
} else {
359-
// 새 파일 추가
360-
setSavedFiles([...savedFiles, { name: fileName, code: currentCode }]);
361-
}
362-
363-
setIsSaved(true);
364-
setCode(currentCode);
365-
toast("API 연결 실패. 임시로 저장되었습니다.");
330+
toast("저장 중 오류가 발생했습니다.");
366331
}
367332
};
368333

369334
// 파일 선택 함수
370-
const handleFileSelect = async (name) => {
335+
const handleFileSelect = (name) => {
371336
// 현재 파일에 변경사항이 있으면 저장
372337
if (!isSaved) {
373338
const shouldSave = window.confirm('변경 사항을 저장하시겠습니까?');
374339
if (shouldSave) {
375-
await handleSave();
340+
handleSave();
376341
}
377342
}
378343

379-
try {
380-
// API에서 파일 내용 불러오기
381-
const response = await fetch(`/api/files/${name}`);
382-
383-
if (!response.ok) {
384-
throw new Error('파일 불러오기 실패');
385-
}
386-
387-
const fileData = await response.json();
388-
setFileName(fileData.name);
389-
setCode(fileData.code);
390-
setActiveFile(fileData.name);
344+
// 로컬 상태에서 파일 찾기
345+
const selectedFile = savedFiles.find((file) => file.name === name);
346+
if (selectedFile) {
347+
setFileName(selectedFile.name);
348+
setCode(selectedFile.code);
349+
setActiveFile(selectedFile.name);
391350
setIsSaved(true);
392351

393352
// 파일 확장자에 맞는 언어 설정
394-
const fileExtension = fileData.name.split('.').pop().toLowerCase();
395-
const langId = getLanguageFromFileName(fileData.name);
353+
const langId = getLanguageFromFileName(selectedFile.name);
396354
if (langId) {
397355
setSelectedLanguage(langId);
398356
}
399-
} catch (error) {
400-
console.error('파일 불러오기 오류:', error);
401-
402-
// API 호출 실패 시 로컬 상태에서 불러오기 시도
403-
const selectedFile = savedFiles.find((file) => file.name === name);
404-
if (selectedFile) {
405-
setFileName(selectedFile.name);
406-
setCode(selectedFile.code);
407-
setActiveFile(selectedFile.name);
408-
setIsSaved(true);
409-
410-
// 파일 확장자에 맞는 언어 설정
411-
const fileExtension = selectedFile.name.split('.').pop().toLowerCase();
412-
const langId = getLanguageFromFileName(selectedFile.name);
413-
if (langId) {
414-
setSelectedLanguage(langId);
415-
}
416-
}
417357
}
418358
};
419359

@@ -490,7 +430,7 @@ const IDE = () => {
490430
</div>
491431
</>
492432
) : (
493-
// 비회원용 사이드바 - 로그인/회원가입 버튼
433+
// 비회원용 사이드바 - 로그인/회원가입 버튼 (수정된 부분)
494434
<div className="auth-sidebar">
495435
<div className="auth-header">
496436
<div className="auth-title">
@@ -500,17 +440,18 @@ const IDE = () => {
500440
</div>
501441
<div className="auth-content">
502442
<div className="auth-message">
503-
<p>코드 저장 및 관리를 위해 로그인하세요.</p>
504443
<p>아직 계정이 없으신가요?</p>
505444
</div>
506-
<button className="login-button auth-button">
507-
<span className="icon-small">🔑</span>
508-
로그인
509-
</button>
510-
<button className="signup-button auth-button">
511-
<span className="icon-small">✏️</span>
512-
회원가입
513-
</button>
445+
<div className="auth-buttons">
446+
<button className="login-button auth-button">
447+
<span className="icon-small">🔑</span>
448+
로그인
449+
</button>
450+
<button className="signup-button auth-button">
451+
<span className="icon-small">✏️</span>
452+
회원가입
453+
</button>
454+
</div>
514455
</div>
515456
</div>
516457
)}

0 commit comments

Comments
 (0)