# 2026-03-10 작업 내역

## 1. 채팅 기능 PHP → Vue3 Socket.io 동기화

### 수정 파일
- `components/common/ChatSection.vue`
  - 335개 더미 메시지 제거
  - Socket.io 이벤트 연동 추가
    - `chat:history` - 채팅 히스토리 로드
    - `chat:message` - 새 메시지 수신
    - `chat:online` - 온라인 사용자 수
    - `chat:sent` - 메시지 전송 완료
  - useSocket, useAuth composable 추가
  - 아바타 경로 수정: `default_avatar_${message.avatar || '01'}.png`

### 생성 파일
- `api/ranking.php`
  - 랭킹 데이터 제공 (기간별 필터: all/day/week/month)
  - 수익, 승률, 총 배팅 수 집계

- `api/game_history.php`
  - 최근 게임 결과 조회 (limit 파라미터)
  - result, start_price, end_price, created_at 제공

### 수정된 컴포넌트
- `components/main/RankingHistory.vue`
  - 더미 데이터 제거
  - API 연동으로 실제 랭킹 표시
  - 기간별 필터 기능 추가

## 2. 게임 히스토리 실시간 업데이트

### 수정 파일
- `components/main/ChartSection.vue`
  - **문제**: apiClient is not defined 오류
  - **해결**: `import apiClient from "@/composables/common/axios";` 추가
  - `fetchHistoryData()` 수정
    - 초기 로드: API에서 최근 10개 조회
    - 실시간 업데이트: Socket.io `game:result` 이벤트
  - 게임 종료 후 즉시 히스토리 표시 (새로고침 불필요)

## 3. 세션 만료 처리

### 문제
- 12시간 후 로그인 상태 표시되지만 배팅 시 "로그인 필요" 오류
- localStorage는 유지되지만 PHP 세션은 만료됨

### 해결
- `composables/common/axios.js` 수정
  - 401 응답 interceptor 추가
  - localStorage 자동 정리 (`auth-login-status`, `auth-user`)
  - `/auth?session_expired=1`로 자동 리다이렉트
  - `_retry` 플래그로 무한 루프 방지

```javascript
if (response?.status === 401 && !originalRequest._retry && isMyApi) {
  originalRequest._retry = true;
  localStorage.removeItem('auth-login-status');
  localStorage.removeItem('auth-user');
  if (!window.location.pathname.includes('/auth')) {
    window.location.href = '/auth?session_expired=1';
  }
}
```

## 4. 아이콘 시스템 변경

### 문제
- chat-toggle 버튼의 Bootstrap Icons가 표시되지 않음

### 해결
- Bootstrap Icons CDN 제거
- dd 폴더 방식과 동일하게 커스텀 SVG 아이콘 시스템 사용
- `assets/scss/base/_icons.scss`의 아이콘 맵 활용
- `ico-chat`, `ico-close` 클래스로 변경

## 5. 채팅 UI 구조 변경 (dd 폴더 방식)

### 제거 항목
- `pages/index.vue`에서 chat-toggle 플로팅 버튼 제거
- `assets/scss/pages/main.scss`에서 .chat-toggle 스타일 제거

### 변경 사항
- 헤더의 채팅 아이콘으로만 채팅창 열기
- 모바일/데스크톱 모두 동일한 방식
- dd 폴더 샘플과 동일한 구조

## 6. 서버 설정 및 포트 관리

### 문제 해결
- 포트 3000에 여러 Node 프로세스 충돌
  - PID 7964 (dd 서버 잔여 프로세스) 종료
  - PID 12280 (upbitfront-main) 유지
- Apache 재시작
  - 경로: `C:\laragon\bin\apache\httpd-2.4.47-win64-VS16\bin\httpd.exe`
  - 포트 80, 8000에서 실행

### 최종 구성
- **upbitfront-main**: http://localhost:3000
- **Apache**: 포트 80, 8000 (프록시)
- **도메인**: test.cm-vw.com → Apache → upbitfront-main

## 7. 빌드 및 배포

### 빌드 정보
```
✓ Client built in ~11.3s
✓ Server built in ~9.0s
Σ Total size: 5.38 MB (1.18 MB gzip)
```

### 실행 명령
```bash
cd C:\Users\Administrator\Desktop\dev\upbitfront-main\upbitfront-main
node .output/server/index.mjs
```

## 주요 수정 파일 목록

1. `components/common/ChatSection.vue` - Socket.io 통합
2. `components/main/ChartSection.vue` - apiClient 추가, 히스토리 로드
3. `components/main/RankingHistory.vue` - API 연동
4. `composables/common/axios.js` - 401 interceptor
5. `pages/index.vue` - chat-toggle 제거
6. `assets/scss/pages/main.scss` - chat-toggle 스타일 제거
7. `nuxt.config.ts` - Bootstrap Icons CDN 제거
8. `api/ranking.php` - 신규 생성
9. `api/game_history.php` - 신규 생성

## 남은 작업

1. 채팅 메시지 실시간 수신 테스트
2. 게임 히스토리 실시간 업데이트 확인
3. 세션 만료 시나리오 테스트
4. 랭킹 데이터 정확성 검증
5. 모바일 환경 채팅 UI 테스트

## 테스트 URL

- 개발 서버: http://localhost:3000
- 프로덕션: https://test.cm-vw.com
- API 엔드포인트: /api/ranking.php, /api/game_history.php
