diff --git a/docs/20260413_에이전트용메뉴추가.md b/docs/20260413_에이전트용메뉴추가.md new file mode 100644 index 0000000..b8f926d --- /dev/null +++ b/docs/20260413_에이전트용메뉴추가.md @@ -0,0 +1,25 @@ +# 에이전트용 메뉴 추가 (기본 메뉴 생성) + +- [x] SideMenu에서 getMenus 결과가 빈 배열일 때 기본 메뉴로 대체한다. + - [x] 기본 메뉴 항목: `{ title: '소속 크리에이터', route: '/agent/creators' }` +- [x] 라우터에 `/agent/creators` 경로를 추가한다. (DefaultLayout 하위) +- [x] 페이지 컴포넌트를 생성한다. (`src/views/Agent/Creators.vue`), 내용은 placeholder로 둔다. + +## 배경/의도 +- 에이전트용 메뉴가 아직 백엔드에 없어서 메뉴 조회 시 빈 배열이 내려올 가능성이 높다. +- 빈 배열일 때는 로그아웃 처리 대신 기본 단독 메뉴 ‘소속 크리에이터’를 제공해 접근할 수 있도록 한다. + +## 구현 체크리스트 +- [x] `SideMenu.vue`의 `getMenus()`에서 성공(200/success)이고 `data.length === 0`이면 기본 메뉴로 할당 +- [x] 기존처럼 성공 + 데이터 존재 시에는 응답 데이터를 그대로 사용 +- [x] 라우터 `index.js`에 `/agent/creators` children route 추가 +- [x] `src/views/Agent/Creators.vue` 생성 및 라우터 연동 + +## 검증 기록 +### 1차 구현 +- 무엇을: 빈 메뉴 응답 시 기본 메뉴 노출 및 라우팅 동작 확인 +- 왜: 에이전트용 메뉴가 없어도 최소 탐색 경로를 제공하기 위함 +- 어떻게: + - 가정: API 응답이 `{ success: true, data: [] }` + - 기대: 사이드 메뉴에 ‘소속 크리에이터’ 단일 항목 표시, 클릭 시 `/agent/creators`로 이동하여 placeholder 화면 노출 + - 결과: 로컬에서 메뉴가 빈 배열일 때 사이드 메뉴에 ‘소속 크리에이터’가 표시되고 클릭 시 `/agent/creators`로 이동하여 placeholder 화면이 노출됨을 확인함(수동 확인) diff --git a/src/components/SideMenu.vue b/src/components/SideMenu.vue index ba7ea0a..f6c0def 100644 --- a/src/components/SideMenu.vue +++ b/src/components/SideMenu.vue @@ -92,8 +92,15 @@ export default { this.isLoading = true try { let res = await api.getMenus(); - if (res.status === 200 && res.data.success === true && res.data.data.length > 0) { - this.items = res.data.data + if (res.status === 200 && res.data.success === true) { + if (res.data.data && res.data.data.length > 0) { + this.items = res.data.data + } else { + // 빈 메뉴일 경우 기본 단독 메뉴를 제공한다. + this.items = [ + { title: '소속 크리에이터', route: '/agent/creators' } + ] + } } else { this.notifyError("알 수 없는 오류가 발생했습니다. 다시 로그인 해주세요!") this.logoutWithoutNetwork(); diff --git a/src/router/index.js b/src/router/index.js index b5444eb..386007f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -20,6 +20,11 @@ const routes = [ name: 'ContentList', component: () => import(/* webpackChunkName: "content" */ '../views/Content/ContentList.vue') }, + { + path: '/agent/creators', + name: 'AgentCreators', + component: () => import(/* webpackChunkName: "agent" */ '../views/Agent/Creators.vue') + }, { path: '/content/category/list', name: 'ContentCategoryList', diff --git a/src/views/Agent/Creators.vue b/src/views/Agent/Creators.vue new file mode 100644 index 0000000..36b794a --- /dev/null +++ b/src/views/Agent/Creators.vue @@ -0,0 +1,21 @@ + + + + +