홈/콘텐츠 placement별 가로형 서브 배너의 목록·생성·수정·삭제 UI를 추가한다. - 관리자 API(/admin/sub-banners) 호출 모듈 추가 - 주소 trim/blank→null 정규화, 최소 1개 주소 및 scheme 검증 - KST yyyy-MM-dd HH:mm 분 단위 기간 직렬화(생략 보존, 명시적 null 해제) - 수정 시 image 생략으로 기존 이미지 유지, 실패 시 입력·이미지 상태 보존 - 라우터/사이드 메뉴 항목 및 test:sub-banner 스크립트 등록
301 lines
10 KiB
Vue
301 lines
10 KiB
Vue
<template>
|
|
<v-navigation-drawer
|
|
app
|
|
clipped
|
|
color="black"
|
|
dark
|
|
permanent
|
|
>
|
|
<v-layout
|
|
column
|
|
fill-height
|
|
>
|
|
<v-list
|
|
v-for="item in items"
|
|
:key="item.title"
|
|
class="py-0"
|
|
>
|
|
<div v-if="!item.items">
|
|
<v-list-item
|
|
:to="item.route"
|
|
active-class="blue white--text"
|
|
>
|
|
<v-list-item-icon>
|
|
<v-icon>{{ item.icon }}</v-icon>
|
|
</v-list-item-icon>
|
|
|
|
<v-list-item-title>{{ item.title }}</v-list-item-title>
|
|
</v-list-item>
|
|
</div>
|
|
|
|
<v-list-group
|
|
v-else
|
|
:prepend-icon="item.icon"
|
|
no-action
|
|
>
|
|
<template v-slot:activator>
|
|
<v-list-item-title>{{ item.title }}</v-list-item-title>
|
|
</template>
|
|
|
|
<div
|
|
v-for="childItem in item.items"
|
|
:key="childItem.title"
|
|
>
|
|
<v-list-item
|
|
:to="childItem.route"
|
|
:exact="childItem.route === '/character'"
|
|
active-class="blue white--text"
|
|
>
|
|
<v-list-item-title>{{ childItem.title }}</v-list-item-title>
|
|
</v-list-item>
|
|
</div>
|
|
</v-list-group>
|
|
</v-list>
|
|
<v-spacer />
|
|
<v-list>
|
|
<v-list-item @click="logout">
|
|
<v-list-item-icon>
|
|
<v-icon>mdi-logout</v-icon>
|
|
</v-list-item-icon>
|
|
|
|
<v-list-item-title>로그아웃</v-list-item-title>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-layout>
|
|
</v-navigation-drawer>
|
|
</template>
|
|
|
|
<script>
|
|
import * as api from '@/api/menu'
|
|
|
|
export default {
|
|
name: "SideMenu",
|
|
data() {
|
|
return {
|
|
isLoading: false,
|
|
items: [],
|
|
}
|
|
},
|
|
|
|
async created() {
|
|
await this.getMenus()
|
|
},
|
|
|
|
methods: {
|
|
notifyError(message) {
|
|
this.$dialog.notify.error(message)
|
|
},
|
|
|
|
notifySuccess(message) {
|
|
this.$dialog.notify.success(message)
|
|
},
|
|
|
|
async getMenus() {
|
|
this.isLoading = true
|
|
try {
|
|
let res = await api.getMenus();
|
|
if (res.status === 200 && res.data.success === true) {
|
|
// 기본 메뉴 설정 (API 결과가 비어있을 수 있음)
|
|
this.items = Array.isArray(res.data.data) ? res.data.data : []
|
|
|
|
// 현재 사용자 역할 확인
|
|
const role = (this.$store && this.$store.state && this.$store.state.accountStore && this.$store.state.accountStore.role)
|
|
|| localStorage.role
|
|
|
|
// ADMIN 권한 전용 추가 메뉴들
|
|
if (role === 'ADMIN') {
|
|
const giftMenu = this.items.find(m => m && m.title === '선물함 관리')
|
|
if (giftMenu) {
|
|
if (!Array.isArray(giftMenu.items)) {
|
|
this.$set(giftMenu, 'items', giftMenu.items ? [].concat(giftMenu.items) : [])
|
|
}
|
|
if (!giftMenu.items.some(item => item && item.route === '/gift/list')) {
|
|
giftMenu.items.push({ title: '선물함 리스트', route: '/gift/list', items: null })
|
|
}
|
|
if (!giftMenu.items.some(item => item && item.route === '/gift/category')) {
|
|
giftMenu.items.push({ title: '선물 카테고리', route: '/gift/category', items: null })
|
|
}
|
|
if (!giftMenu.items.some(item => item && item.route === '/gift/size')) {
|
|
giftMenu.items.push({ title: '선물 사이즈', route: '/gift/size', items: null })
|
|
}
|
|
if (!giftMenu.items.some(item => item && item.route === '/gift/mailbox')) {
|
|
giftMenu.items.push({ title: '받을 주소', route: '/gift/mailbox', items: null })
|
|
}
|
|
} else {
|
|
this.items.push({
|
|
title: '선물함 관리',
|
|
route: null,
|
|
icon: 'mdi-gift',
|
|
items: [
|
|
{ title: '선물함 리스트', route: '/gift/list', items: null },
|
|
{ title: '선물 카테고리', route: '/gift/category', items: null },
|
|
{ title: '선물 사이즈', route: '/gift/size', items: null },
|
|
{ title: '받을 주소', route: '/gift/mailbox', items: null }
|
|
]
|
|
})
|
|
}
|
|
|
|
// '시리즈 관리' 메뉴에 '배너 등록' 하위 메뉴 추가
|
|
try {
|
|
const seriesMenu = this.items.find(m => m && m.title === '시리즈 관리')
|
|
if (seriesMenu) {
|
|
if (!Array.isArray(seriesMenu.items)) {
|
|
seriesMenu.items = seriesMenu.items ? [].concat(seriesMenu.items) : []
|
|
}
|
|
const exists = seriesMenu.items.some(ci => ci && ci.route === '/content/series/banner')
|
|
if (!exists) {
|
|
seriesMenu.items.push({
|
|
title: '배너 등록',
|
|
route: '/content/series/banner',
|
|
items: null
|
|
})
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
|
|
// 프로모션 메뉴에 '가로형 서브 배너' 하위 메뉴 추가
|
|
try {
|
|
const promotionMenu = this.items.find(m => m && Array.isArray(m.items)
|
|
&& m.items.some(ci => ci && ci.route === '/promotion/event'))
|
|
const subBannerItem = { title: '가로형 서브 배너', route: '/promotion/sub-banner', items: null }
|
|
|
|
if (promotionMenu) {
|
|
if (!promotionMenu.items.some(ci => ci && ci.route === subBannerItem.route)) {
|
|
promotionMenu.items.push(subBannerItem)
|
|
}
|
|
} else {
|
|
this.items.push({
|
|
title: '프로모션 관리',
|
|
route: null,
|
|
icon: 'mdi-bullhorn',
|
|
items: [subBannerItem]
|
|
})
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
|
|
// 캐릭터 챗봇 메뉴 추가
|
|
this.items.push({
|
|
title: '캐릭터 챗봇',
|
|
route: null,
|
|
items: [
|
|
{
|
|
title: '배너 등록',
|
|
route: '/character/banner',
|
|
items: null
|
|
},
|
|
{
|
|
title: '캐릭터 리스트',
|
|
route: '/character',
|
|
items: null
|
|
},
|
|
{
|
|
title: '큐레이션',
|
|
route: '/character/curation',
|
|
items: null
|
|
},
|
|
{
|
|
title: '정산',
|
|
route: '/character/calculate',
|
|
items: null
|
|
},
|
|
{
|
|
title: '원작',
|
|
route: '/original-work',
|
|
items: null
|
|
},
|
|
]
|
|
})
|
|
|
|
// 에이전트 관리 메뉴를 '크리에이터 관리' 바로 아래에 추가
|
|
try {
|
|
const insertAfterTitle = '크리에이터 관리'
|
|
const agentMenu = {
|
|
title: '에이전트 관리',
|
|
route: null,
|
|
items: [
|
|
{ title: '에이전트 리스트', route: '/agent/list', items: null },
|
|
{ title: '에이전트 정산 비율', route: '/agent/settlement-ratio', items: null },
|
|
]
|
|
}
|
|
|
|
const idx = this.items.findIndex(m => m && m.title === insertAfterTitle)
|
|
if (idx >= 0) {
|
|
this.items.splice(idx + 1, 0, agentMenu)
|
|
} else {
|
|
// 기준 메뉴가 없으면 하단에 추가
|
|
this.items.push(agentMenu)
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
|
|
// 정산현황 메뉴에 '채널 후원 정산' 및 '오리지널 시리즈 정산' 추가
|
|
try {
|
|
const calculateMenu = this.items.find(m => m && m.title === '정산현황')
|
|
if (calculateMenu) {
|
|
if (!Array.isArray(calculateMenu.items)) {
|
|
calculateMenu.items = calculateMenu.items ? [].concat(calculateMenu.items) : []
|
|
}
|
|
const exists = calculateMenu.items.some(ci => ci && ci.route === '/calculate/channel-donation')
|
|
if (!exists) {
|
|
calculateMenu.items.push({
|
|
title: '채널 후원 정산',
|
|
route: '/calculate/channel-donation',
|
|
items: null
|
|
})
|
|
}
|
|
|
|
const existsOriginal = calculateMenu.items.some(ci => ci && ci.route === '/calculate/original-series')
|
|
if (!existsOriginal) {
|
|
calculateMenu.items.push({
|
|
title: '오리지널 시리즈 정산',
|
|
route: '/calculate/original-series',
|
|
items: null
|
|
})
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
}
|
|
|
|
// 조회한 메뉴가 비어 있고, 콘텐츠 매니저라면 기본 메뉴 추가
|
|
if (this.items.length === 0 && role === 'CONTENT_MANAGER') {
|
|
this.items.push({
|
|
title: '콘텐츠 리스트',
|
|
route: '/content/list',
|
|
items: null
|
|
})
|
|
}
|
|
|
|
// 그래도 비어있다면 이전 동작과 동일하게 처리
|
|
if (this.items.length === 0) {
|
|
this.notifyError("알 수 없는 오류가 발생했습니다. 다시 로그인 해주세요!")
|
|
this.logout();
|
|
}
|
|
} else {
|
|
this.notifyError("알 수 없는 오류가 발생했습니다. 다시 로그인 해주세요!")
|
|
this.logout();
|
|
}
|
|
} catch (e) {
|
|
this.notifyError("알 수 없는 오류가 발생했습니다. 다시 로그인 해주세요!")
|
|
this.logout();
|
|
} finally {
|
|
this.isLoading = false
|
|
}
|
|
},
|
|
|
|
logout() {
|
|
this.$store.dispatch('accountStore/LOGOUT')
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
</style>
|