Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a3fce2130 | |||
| 1d8e8581b8 | |||
| 036fc84fa6 |
@@ -93,13 +93,21 @@ function canManageAdminRole(actingUser, primaryAdmin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
router.post('/games', requireAdmin, async (req, res) => {
|
router.post('/games', requireAdmin, async (req, res) => {
|
||||||
const schema = z.object({ id: z.string().min(1), name: z.string().min(1).max(60) })
|
const schema = z.object({
|
||||||
|
id: z.string().min(1),
|
||||||
|
name: z.string().min(1).max(60),
|
||||||
|
thumbnailSrc: z.string().max(255).optional().default(''),
|
||||||
|
})
|
||||||
const parsed = schema.safeParse(req.body)
|
const parsed = schema.safeParse(req.body)
|
||||||
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
|
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
|
||||||
const exists = await findGameById(parsed.data.id)
|
const exists = await findGameById(parsed.data.id)
|
||||||
if (exists) return res.status(409).json({ error: 'game_id_taken' })
|
if (exists) return res.status(409).json({ error: 'game_id_taken' })
|
||||||
const game = await createGame({ id: parsed.data.id, name: parsed.data.name })
|
const game = await createGame({ id: parsed.data.id, name: parsed.data.name })
|
||||||
res.json({ game })
|
if (parsed.data.thumbnailSrc) {
|
||||||
|
const copiedThumb = await copyUploadIntoGameAsset(parsed.data.thumbnailSrc)
|
||||||
|
await updateGameThumbnail(game.id, copiedThumb)
|
||||||
|
}
|
||||||
|
res.json({ game: await findGameById(game.id) })
|
||||||
})
|
})
|
||||||
|
|
||||||
router.patch('/games/display-order', requireAdmin, async (req, res) => {
|
router.patch('/games/display-order', requireAdmin, async (req, res) => {
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# 의사결정 이력
|
# 의사결정 이력
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.55
|
||||||
|
- 관리자 요청/업로드 배지는 문구만 다르면 빠르게 구분하기 어려우므로, 같은 `pill` 구조를 유지하되 색으로도 역할을 나누는 편이 운영 판단에 더 적합하다고 정리했다.
|
||||||
|
- 신규 템플릿 요청으로 새 게임을 만들 때는 아이템만 가져오고 썸네일이 비어 있으면 식별성이 떨어지므로, 요청 썸네일도 기본값으로 함께 승계하는 편이 맞다고 판단했다.
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.54
|
||||||
|
- 관리자 요청 카드는 운영자가 이미 흐름을 알고 있다는 전제에서, 설명형 힌트보다 즉시 판단에 필요한 메타와 액션만 남기는 편이 더 적합하다고 정리했다.
|
||||||
|
- 요청 종류 표시는 중복 텍스트보다 오른쪽 상단의 짧은 상태 배지 하나로 고정하고, 하단 액션 줄은 `보조 링크는 왼쪽 / 실제 처리 버튼은 오른쪽` 구조가 더 읽기 쉽다고 판단했다.
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.53
|
||||||
|
- 관리자 후속 리팩터링은 남은 큰 액션 묶음인 `상단 고정 게임 정렬`과 `커스텀 아이템 검수`부터 composable로 분리하는 편이 `AdminView.vue` 체감 복잡도를 가장 빨리 낮춘다고 판단했다.
|
||||||
|
- 이 단계에서도 레이아웃이나 문구보다 로직 책임 경계를 먼저 옮기고, 실제 스타일 파일 분리는 그 다음 단계로 이어가는 편이 안전하다고 정리했다.
|
||||||
|
|
||||||
## 2026-04-02 v1.3.52
|
## 2026-04-02 v1.3.52
|
||||||
- 관리자 화면은 본문을 컴포넌트로 나눈 뒤에도 같은 시각 문법을 유지해야 하므로, `scoped`를 유지한 채 각 섹션에 스타일을 복붙하기보다 관리자 범위 공통 스타일로 다시 묶는 편이 더 안전하다고 정리했다.
|
- 관리자 화면은 본문을 컴포넌트로 나눈 뒤에도 같은 시각 문법을 유지해야 하므로, `scoped`를 유지한 채 각 섹션에 스타일을 복붙하기보다 관리자 범위 공통 스타일로 다시 묶는 편이 더 안전하다고 정리했다.
|
||||||
- `템플릿 요청 관리 / 전체 티어표 관리` 내부 모드 값은 URL과 버튼 상태가 어긋나지 않도록 `all` 하나로 통일하는 편이 맞다고 판단했다.
|
- `템플릿 요청 관리 / 전체 티어표 관리` 내부 모드 값은 URL과 버튼 상태가 어긋나지 않도록 `all` 하나로 통일하는 편이 맞다고 판단했다.
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
## 중기 개선
|
## 중기 개선
|
||||||
- 관리자 URL 분리는 시작했으므로, 다음 단계에서는 `AdminView.vue` 단일 대형 파일을 섹션별 뷰/컴포저블로 쪼개고 직접 진입 시 선택 게임/요청 작업 상태 복원 범위도 함께 정리한다.
|
- 관리자 URL 분리는 시작했으므로, 다음 단계에서는 `AdminView.vue` 단일 대형 파일을 섹션별 뷰/컴포저블로 쪼개고 직접 진입 시 선택 게임/요청 작업 상태 복원 범위도 함께 정리한다.
|
||||||
- 관리자 본문 컴포넌트 분리와 `게임/템플릿 요청/회원 관리` composable 분리는 시작했으므로, 다음 단계에서는 `아이템 관리`와 `목록 관리`도 같은 기준으로 옮기고 공통 모달 상태를 어느 계층에서 소유할지 정리한다.
|
- 관리자 본문 컴포넌트 분리와 `게임/템플릿 요청/회원 관리/아이템 관리/목록 관리` composable 분리는 시작했으므로, 다음 단계에서는 공통 모달 상태를 어느 계층에서 소유할지 정리하고 남은 관리자 유틸 함수를 더 줄인다.
|
||||||
- 관리자 화면은 섹션 경로 분리까지 끝났으므로, 다음 단계에서는 `AdminView.vue`를 실제 레이아웃 뷰와 섹션별 라우트 컴포넌트로 더 쪼갤지 결정한다.
|
- 관리자 화면은 섹션 경로 분리까지 끝났으므로, 다음 단계에서는 `AdminView.vue`를 실제 레이아웃 뷰와 섹션별 라우트 컴포넌트로 더 쪼갤지 결정한다.
|
||||||
- 관리자 공통 스타일은 `adminUiScope` 기준으로 다시 묶었으므로, 다음 단계에서는 각 섹션을 별도 파일로 완전히 분리할 때 스타일도 `admin.css` 또는 섹션별 스타일로 옮길지 결정한다.
|
- 관리자 공통 스타일은 `adminUiScope` 기준으로 다시 묶었으므로, 다음 단계에서는 각 섹션을 별도 파일로 완전히 분리할 때 스타일도 `admin.css` 또는 섹션별 스타일로 옮길지 결정한다.
|
||||||
|
- 관리자 요청 카드 밀도는 줄였으므로, 다음 단계에서는 전체 티어표 카드와 요청 카드의 상단/하단 액션 정렬을 한 번 더 통일할지 비교 QA한다.
|
||||||
|
- 신규 템플릿 요청 썸네일 기본 승계는 붙였으므로, 다음 단계에서는 요청 아이템 반영 후 `처리 완료`까지의 관리자 흐름을 실제 데이터로 한 번 더 QA한다.
|
||||||
- 관리자 게임 아이템 순서 저장은 추가됐으므로, 다음 단계에서는 새 아이템 추가 직후 `자동 맨 앞 배치`와 `관리자 수동 고정 순서`의 우선순위를 실제 운영 흐름 기준으로 한 번 더 QA한다.
|
- 관리자 게임 아이템 순서 저장은 추가됐으므로, 다음 단계에서는 새 아이템 추가 직후 `자동 맨 앞 배치`와 `관리자 수동 고정 순서`의 우선순위를 실제 운영 흐름 기준으로 한 번 더 QA한다.
|
||||||
- 관리자 템플릿 요청 미리보기는 실제 완성본 iframe 방식과의 체감 차이를 마지막으로 한 번 더 QA한다.
|
- 관리자 템플릿 요청 미리보기는 실제 완성본 iframe 방식과의 체감 차이를 마지막으로 한 번 더 QA한다.
|
||||||
- 라이트모드/다크모드 2차 보정까지 반영했으므로, 남은 작업은 전체 화면을 실제 사용 흐름으로 돌려 보며 대비·명도·아이콘 가독성을 미세하게 QA하는 최종 테마 점검 단계로 가져간다.
|
- 라이트모드/다크모드 2차 보정까지 반영했으므로, 남은 작업은 전체 화면을 실제 사용 흐름으로 돌려 보며 대비·명도·아이콘 가독성을 미세하게 QA하는 최종 테마 점검 단계로 가져간다.
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# 업데이트 로그
|
# 업데이트 로그
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.55
|
||||||
|
- 관리자 요청 카드 오른쪽 상단의 `신규 템플릿 / 보유 템플릿` 배지는 서로 다른 색상으로 분리해, 카드 타입을 텍스트보다 더 빠르게 구분할 수 있게 조정함.
|
||||||
|
- 게임 관리의 기본 아이템 추가 미리보기에서도 `요청 아이템 / 직접 추가 파일` 배지를 서로 다른 색상으로 구분해, 요청 반영분과 직접 업로드분이 한눈에 섞이지 않도록 정리함.
|
||||||
|
- 신규 템플릿 요청에서 `새 게임 만들기`를 진행할 때는 요청 티어표 대표 썸네일도 함께 새 게임 썸네일로 복사되도록 보강해, 관리자가 이후 수정하더라도 초기 식별용 썸네일은 바로 이어받을 수 있게 함.
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.54
|
||||||
|
- 관리자 `티어표 관리` 요청 카드에서는 사용법 힌트 문구와 중복 타입 텍스트를 제거해, 카드 본문이 관리 정보만 더 빠르게 읽히도록 정리함.
|
||||||
|
- `신규 템플릿 / 보유 템플릿` 구분은 카드 오른쪽 상단의 별도 배지로 옮기고, 기존 `추가 아이템 / 확인함 여부` 배지는 그대로 유지해 정보 계층을 더 단순하게 맞춤.
|
||||||
|
- `요청 티어표 보기` 링크는 하단 액션 줄의 왼쪽으로 옮기고 `확인하기 / 처리 완료` 버튼은 오른쪽에 정렬해, 실제 작업 버튼과 보조 링크의 역할이 한 줄 안에서도 분명하게 보이도록 조정함.
|
||||||
|
|
||||||
|
## 2026-04-02 v1.3.53
|
||||||
|
- 관리자 리팩터링 4차로 `목록 관리` 정렬 로직과 `아이템 관리` 모달/삭제/승격 액션을 각각 `useAdminFeaturedGames`, `useAdminCustomItems` composable로 분리해 `AdminView.vue`의 직접 액션 코드를 더 줄임.
|
||||||
|
- 따라서 관리자 메인 뷰는 섹션 연결과 공통 상태 중심으로 더 가까워졌고, 상단 고정 게임 정렬과 커스텀 아이템 처리 흐름은 각 영역 책임에 맞는 파일로 옮겨 유지보수 범위를 좁힘.
|
||||||
|
|
||||||
## 2026-04-02 v1.3.52
|
## 2026-04-02 v1.3.52
|
||||||
- 관리자 본문 섹션을 컴포넌트로 나눈 뒤 `AdminView.vue` 스타일이 `scoped`에 묶여 자식 컴포넌트까지 제대로 닿지 않던 문제를 정리하고, 관리자 전용 공통 스타일을 `adminUiScope` 범위로 다시 묶어 각 페이지 CSS가 함께 살아나도록 보강함.
|
- 관리자 본문 섹션을 컴포넌트로 나눈 뒤 `AdminView.vue` 스타일이 `scoped`에 묶여 자식 컴포넌트까지 제대로 닿지 않던 문제를 정리하고, 관리자 전용 공통 스타일을 `adminUiScope` 범위로 다시 묶어 각 페이지 CSS가 함께 살아나도록 보강함.
|
||||||
- 템플릿 요청 카드의 신규 게임 입력 영역에는 `게임 이름 / 게임 ID` 필드 스타일을 다시 붙여, 요청 카드만 따로 풀린 것처럼 보이던 레이아웃을 복구함.
|
- 템플릿 요청 카드의 신규 게임 입력 영역에는 `게임 이름 / 게임 ID` 필드 스타일을 다시 붙여, 요청 카드만 따로 풀린 것처럼 보이던 레이아웃을 복구함.
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ const props = defineProps({
|
|||||||
<input v-model="draft.label" class="input input--labelEdit input--dense" maxlength="60" placeholder="아이템 이름" />
|
<input v-model="draft.label" class="input input--labelEdit input--dense" maxlength="60" placeholder="아이템 이름" />
|
||||||
<div class="hint hint--tight">{{ draft.sourceName }}</div>
|
<div class="hint hint--tight">{{ draft.sourceName }}</div>
|
||||||
<div class="itemDraftRow__meta">
|
<div class="itemDraftRow__meta">
|
||||||
<span class="pill pill--soft">{{ draft.kind === 'request' ? '요청 아이템' : '직접 추가 파일' }}</span>
|
<span class="pill" :class="draft.kind === 'request' ? 'pill--requestItem' : 'pill--directFile'">
|
||||||
|
{{ draft.kind === 'request' ? '요청 아이템' : '직접 추가 파일' }}
|
||||||
|
</span>
|
||||||
<button class="btn btn--danger btn--small" type="button" @click="props.removeUploadDraft(draft)">제외</button>
|
<button class="btn btn--danger btn--small" type="button" @click="props.removeUploadDraft(draft)">제외</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ const props = defineProps({
|
|||||||
tierlistsMode: { type: String, required: true },
|
tierlistsMode: { type: String, required: true },
|
||||||
templateRequests: { type: Array, required: true },
|
templateRequests: { type: Array, required: true },
|
||||||
openTemplateRequestPreview: { type: Function, required: true },
|
openTemplateRequestPreview: { type: Function, required: true },
|
||||||
templateRequestTypeLabel: { type: Function, required: true },
|
|
||||||
fmt: { type: Function, required: true },
|
fmt: { type: Function, required: true },
|
||||||
templateRequestTargetLabel: { type: Function, required: true },
|
templateRequestTargetLabel: { type: Function, required: true },
|
||||||
templateRequestStatusLabel: { type: Function, required: true },
|
templateRequestStatusLabel: { type: Function, required: true },
|
||||||
templateRequestSourceUrl: { type: Function, required: true },
|
templateRequestSourceUrl: { type: Function, required: true },
|
||||||
templateRequestReviewHint: { type: Function, required: true },
|
|
||||||
startTemplateRequestReview: { type: Function, required: true },
|
startTemplateRequestReview: { type: Function, required: true },
|
||||||
completeTemplateRequest: { type: Function, required: true },
|
completeTemplateRequest: { type: Function, required: true },
|
||||||
adminTierLists: { type: Array, required: true },
|
adminTierLists: { type: Array, required: true },
|
||||||
@@ -32,7 +30,6 @@ const props = defineProps({
|
|||||||
<div class="sectionHeader">
|
<div class="sectionHeader">
|
||||||
<div>
|
<div>
|
||||||
<div class="panel__title">사용자 요청</div>
|
<div class="panel__title">사용자 요청</div>
|
||||||
<div class="hint hint--tight">요청 카드는 미확인/확인함 상태로 관리하고, 실제 아이템 반영은 게임 관리 화면에서 직접 진행합니다. 처리 완료를 눌러야 카드가 목록에서 빠져요.</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -67,10 +64,16 @@ const props = defineProps({
|
|||||||
<div class="tierAdminCard__body">
|
<div class="tierAdminCard__body">
|
||||||
<div class="tierAdminCard__head">
|
<div class="tierAdminCard__head">
|
||||||
<div>
|
<div>
|
||||||
|
<span
|
||||||
|
class="pill templateRequestCard__cornerBadge"
|
||||||
|
:class="request.type === 'create' ? 'pill--create' : 'pill--owned'"
|
||||||
|
>
|
||||||
|
{{ request.type === 'create' ? '신규 템플릿' : '보유 템플릿' }}
|
||||||
|
</span>
|
||||||
<div class="tierAdminCard__title">{{ request.sourceTierListTitle }}</div>
|
<div class="tierAdminCard__title">{{ request.sourceTierListTitle }}</div>
|
||||||
<div v-if="request.sourceDescription" class="tierAdminCard__desc">{{ request.sourceDescription }}</div>
|
<div v-if="request.sourceDescription" class="tierAdminCard__desc">{{ request.sourceDescription }}</div>
|
||||||
<div class="tierAdminCard__meta">
|
<div class="tierAdminCard__meta">
|
||||||
{{ props.templateRequestTypeLabel(request) }} · {{ request.requesterName }} · {{ props.fmt(request.createdAt) }}
|
{{ request.requesterName }} · {{ props.fmt(request.createdAt) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="tierAdminCard__meta">{{ props.templateRequestTargetLabel(request) }}</div>
|
<div class="tierAdminCard__meta">{{ props.templateRequestTargetLabel(request) }}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,7 +81,6 @@ const props = defineProps({
|
|||||||
|
|
||||||
<div class="tierAdminCard__stats">
|
<div class="tierAdminCard__stats">
|
||||||
<span class="pill">추가 아이템 {{ request.items?.length || 0 }}개</span>
|
<span class="pill">추가 아이템 {{ request.items?.length || 0 }}개</span>
|
||||||
<span class="pill">{{ request.type === 'create' ? '새 템플릿' : '기존 템플릿 업데이트' }}</span>
|
|
||||||
<span class="pill" :class="{ 'pill--accent': request.status === 'reviewing' }">{{ props.templateRequestStatusLabel(request) }}</span>
|
<span class="pill" :class="{ 'pill--accent': request.status === 'reviewing' }">{{ props.templateRequestStatusLabel(request) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -89,24 +91,24 @@ const props = defineProps({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="templateRequestCard__links">
|
<div class="templateRequestCard__footer">
|
||||||
<a
|
<div class="templateRequestCard__footerLeft">
|
||||||
v-if="props.templateRequestSourceUrl(request)"
|
<a
|
||||||
class="btn btn--ghost btn--small"
|
v-if="props.templateRequestSourceUrl(request)"
|
||||||
:href="props.templateRequestSourceUrl(request)"
|
class="btn btn--ghost btn--small"
|
||||||
target="_blank"
|
:href="props.templateRequestSourceUrl(request)"
|
||||||
rel="noreferrer"
|
target="_blank"
|
||||||
>
|
rel="noreferrer"
|
||||||
요청 티어표 보기
|
>
|
||||||
</a>
|
요청 티어표 보기
|
||||||
<div class="hint hint--tight">{{ props.templateRequestReviewHint(request) }}</div>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="templateRequestCard__actions">
|
||||||
<div class="templateRequestCard__actions">
|
<button class="btn btn--primary" :disabled="request.isHandling" @click="props.startTemplateRequestReview(request)">
|
||||||
<button class="btn btn--primary" :disabled="request.isHandling" @click="props.startTemplateRequestReview(request)">
|
{{ request.isHandling ? '이동중...' : '확인하기' }}
|
||||||
{{ request.isHandling ? '이동중...' : '확인하기' }}
|
</button>
|
||||||
</button>
|
<button class="btn btn--ghost" :disabled="request.isHandling || request.status !== 'reviewing'" @click="props.completeTemplateRequest(request)">처리 완료</button>
|
||||||
<button class="btn btn--ghost" :disabled="request.isHandling || request.status !== 'reviewing'" @click="props.completeTemplateRequest(request)">처리 완료</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@@ -117,7 +119,6 @@ const props = defineProps({
|
|||||||
<div class="sectionHeader">
|
<div class="sectionHeader">
|
||||||
<div>
|
<div>
|
||||||
<div class="panel__title">전체 티어표 관리</div>
|
<div class="panel__title">전체 티어표 관리</div>
|
||||||
<div class="hint hint--tight">공개/비공개를 포함한 최근 티어표를 모두 확인하고, 추가 아이템을 기존 게임 템플릿으로 승격하거나 커스텀 티어표를 새 게임 템플릿으로 만들 수 있어요. 여기는 요청 목록과 별개로 전체 저장 티어표를 보는 영역입니다.</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
203
frontend/src/composables/useAdminCustomItems.js
Normal file
203
frontend/src/composables/useAdminCustomItems.js
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
|
export function useAdminCustomItems({
|
||||||
|
api,
|
||||||
|
toast,
|
||||||
|
customItems,
|
||||||
|
customItemPage,
|
||||||
|
customItemLimit,
|
||||||
|
customItemPageCount,
|
||||||
|
customItemQuery,
|
||||||
|
customItemOrphanOnly,
|
||||||
|
customItemModalOpen,
|
||||||
|
customItemDeleteModalOpen,
|
||||||
|
customItemModalHistoryActive,
|
||||||
|
modalTargetCustomItem,
|
||||||
|
customItemModalDraftLabel,
|
||||||
|
customItemModalLabelSaving,
|
||||||
|
customItemModalTargetGameId,
|
||||||
|
customItemModalGameQuery,
|
||||||
|
customItemModalGameSort,
|
||||||
|
games,
|
||||||
|
selectedGameId,
|
||||||
|
refreshCustomItems,
|
||||||
|
loadGame,
|
||||||
|
setTab,
|
||||||
|
selectAdminGame,
|
||||||
|
resetMessages,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
}) {
|
||||||
|
function submitCustomItemSearch() {
|
||||||
|
customItemPage.value = 1
|
||||||
|
refreshCustomItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCustomItemOrphanOnly() {
|
||||||
|
customItemPage.value = 1
|
||||||
|
refreshCustomItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeCustomItemLimit(limit) {
|
||||||
|
customItemLimit.value = limit
|
||||||
|
customItemPage.value = 1
|
||||||
|
refreshCustomItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveCustomItemPage(direction) {
|
||||||
|
const nextPage = customItemPage.value + direction
|
||||||
|
if (nextPage < 1 || nextPage > customItemPageCount.value) return
|
||||||
|
customItemPage.value = nextPage
|
||||||
|
refreshCustomItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushCustomItemModalHistoryState() {
|
||||||
|
if (typeof window === 'undefined') return
|
||||||
|
window.history.pushState({ ...(window.history.state || {}), adminCustomItemModal: true }, '', window.location.href)
|
||||||
|
customItemModalHistoryActive.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCustomItemModal(item) {
|
||||||
|
modalTargetCustomItem.value = item || null
|
||||||
|
customItemModalDraftLabel.value = item?.label || ''
|
||||||
|
customItemModalTargetGameId.value = ''
|
||||||
|
customItemModalGameQuery.value = ''
|
||||||
|
customItemModalGameSort.value = 'recent'
|
||||||
|
customItemModalOpen.value = true
|
||||||
|
pushCustomItemModalHistoryState()
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCustomItemModal({ fromPopState = false } = {}) {
|
||||||
|
customItemModalOpen.value = false
|
||||||
|
customItemDeleteModalOpen.value = false
|
||||||
|
modalTargetCustomItem.value = null
|
||||||
|
customItemModalDraftLabel.value = ''
|
||||||
|
customItemModalLabelSaving.value = false
|
||||||
|
customItemModalTargetGameId.value = ''
|
||||||
|
customItemModalGameQuery.value = ''
|
||||||
|
customItemModalGameSort.value = 'recent'
|
||||||
|
|
||||||
|
if (fromPopState) {
|
||||||
|
customItemModalHistoryActive.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (customItemModalHistoryActive.value && typeof window !== 'undefined') {
|
||||||
|
customItemModalHistoryActive.value = false
|
||||||
|
window.history.back()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCustomItemDeleteModal(item) {
|
||||||
|
if (!item) return
|
||||||
|
if (item.sourceType === 'user' && (item.usageCount > 0 || item.linkedGames.length > 0)) {
|
||||||
|
error.value = '사용 중이거나 템플릿에 연결된 사용자 업로드 이미지는 먼저 참조를 정리해야 삭제할 수 있어요.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
modalTargetCustomItem.value = item
|
||||||
|
customItemDeleteModalOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCustomItemDeleteModal() {
|
||||||
|
customItemDeleteModalOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function jumpToGameAdmin(gameId) {
|
||||||
|
if (!gameId) return
|
||||||
|
closeCustomItemModal()
|
||||||
|
setTab('game-admin')
|
||||||
|
nextTick(() => {
|
||||||
|
selectAdminGame(gameId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeCustomItem(item = modalTargetCustomItem.value) {
|
||||||
|
resetMessages()
|
||||||
|
if (!item) return
|
||||||
|
if (item.sourceType === 'user' && (item.usageCount > 0 || item.linkedGames.length > 0)) {
|
||||||
|
error.value = '사용 중이거나 템플릿에 연결된 사용자 업로드 이미지는 먼저 참조를 정리해야 삭제할 수 있어요.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await api.deleteAdminCustomItem(item.id)
|
||||||
|
closeCustomItemDeleteModal()
|
||||||
|
closeCustomItemModal()
|
||||||
|
await refreshCustomItems()
|
||||||
|
success.value = item.sourceType === 'template' ? '선택한 템플릿 아이템을 제거했어요.' : '사용자 업로드 이미지를 삭제했어요.'
|
||||||
|
} catch (e) {
|
||||||
|
error.value = item.sourceType === 'template' ? '템플릿 아이템 제거에 실패했어요.' : '사용자 업로드 이미지 삭제에 실패했어요.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeUnusedCustomItems() {
|
||||||
|
resetMessages()
|
||||||
|
const ok = window.confirm('현재 검색 조건에 맞는 미사용 커스텀 이미지를 모두 삭제할까요?')
|
||||||
|
if (!ok) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await api.deleteAdminUnusedCustomItems({ q: customItemQuery.value })
|
||||||
|
await refreshCustomItems()
|
||||||
|
success.value = `${data.deletedCount || 0}개의 미사용 사용자 업로드 이미지를 삭제했어요.`
|
||||||
|
} catch (e) {
|
||||||
|
error.value = '미사용 커스텀 이미지 일괄 삭제에 실패했어요.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveCustomItemModalLabel() {
|
||||||
|
const item = modalTargetCustomItem.value
|
||||||
|
const nextLabel = customItemModalDraftLabel.value.trim().slice(0, 60)
|
||||||
|
if (!item || !nextLabel || nextLabel === item.label || customItemModalLabelSaving.value) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
customItemModalLabelSaving.value = true
|
||||||
|
const data = await api.updateAdminCustomItemLabel(item.id, { label: nextLabel, sourceType: item.sourceType })
|
||||||
|
item.label = data.item?.label || nextLabel
|
||||||
|
customItemModalDraftLabel.value = item.label
|
||||||
|
customItems.value = customItems.value.map((entry) => (entry.id === item.id ? { ...entry, label: item.label } : entry))
|
||||||
|
toast.success('아이템 이름을 변경했어요.')
|
||||||
|
} catch (e) {
|
||||||
|
error.value = '아이템 이름 변경에 실패했어요.'
|
||||||
|
} finally {
|
||||||
|
customItemModalLabelSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function promoteCustomItem(item) {
|
||||||
|
resetMessages()
|
||||||
|
if (!customItemModalTargetGameId.value) {
|
||||||
|
error.value = '추가할 게임을 먼저 선택해주세요.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
item.isPromoting = true
|
||||||
|
await api.promoteAdminCustomItem(item.id, { gameId: customItemModalTargetGameId.value })
|
||||||
|
const targetGameName = games.value.find((game) => game.id === customItemModalTargetGameId.value)?.name || customItemModalTargetGameId.value
|
||||||
|
if (selectedGameId.value === customItemModalTargetGameId.value) await loadGame()
|
||||||
|
closeCustomItemModal()
|
||||||
|
success.value = `"${item.label}" 이미지를 ${targetGameName} 템플릿으로 추가했어요.`
|
||||||
|
} catch (e) {
|
||||||
|
error.value = '선택한 이미지를 템플릿으로 추가하지 못했어요.'
|
||||||
|
} finally {
|
||||||
|
item.isPromoting = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
submitCustomItemSearch,
|
||||||
|
toggleCustomItemOrphanOnly,
|
||||||
|
changeCustomItemLimit,
|
||||||
|
moveCustomItemPage,
|
||||||
|
pushCustomItemModalHistoryState,
|
||||||
|
openCustomItemModal,
|
||||||
|
closeCustomItemModal,
|
||||||
|
openCustomItemDeleteModal,
|
||||||
|
closeCustomItemDeleteModal,
|
||||||
|
jumpToGameAdmin,
|
||||||
|
removeCustomItem,
|
||||||
|
removeUnusedCustomItems,
|
||||||
|
saveCustomItemModalLabel,
|
||||||
|
promoteCustomItem,
|
||||||
|
}
|
||||||
|
}
|
||||||
93
frontend/src/composables/useAdminFeaturedGames.js
Normal file
93
frontend/src/composables/useAdminFeaturedGames.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import { nextTick } from 'vue'
|
||||||
|
import Sortable from 'sortablejs'
|
||||||
|
|
||||||
|
export function useAdminFeaturedGames({
|
||||||
|
api,
|
||||||
|
featuredListEl,
|
||||||
|
featuredSortable,
|
||||||
|
featuredGameIds,
|
||||||
|
games,
|
||||||
|
resetMessages,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
}) {
|
||||||
|
function destroyFeaturedSortable() {
|
||||||
|
if (featuredSortable.value) {
|
||||||
|
featuredSortable.value.destroy()
|
||||||
|
featuredSortable.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncFeaturedSortable() {
|
||||||
|
await nextTick()
|
||||||
|
destroyFeaturedSortable()
|
||||||
|
if (!featuredListEl.value) return
|
||||||
|
|
||||||
|
featuredSortable.value = Sortable.create(featuredListEl.value, {
|
||||||
|
animation: 160,
|
||||||
|
draggable: '[data-featured-id]',
|
||||||
|
handle: '[data-featured-handle]',
|
||||||
|
ghostClass: 'ghost',
|
||||||
|
chosenClass: 'chosen',
|
||||||
|
onEnd: (evt) => {
|
||||||
|
if (evt.oldIndex == null || evt.newIndex == null || evt.oldIndex === evt.newIndex) return
|
||||||
|
const nextIds = [...featuredGameIds.value]
|
||||||
|
const [moved] = nextIds.splice(evt.oldIndex, 1)
|
||||||
|
nextIds.splice(evt.newIndex, 0, moved)
|
||||||
|
featuredGameIds.value = nextIds
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFeaturedGame(gameId) {
|
||||||
|
resetMessages()
|
||||||
|
if (!gameId || featuredGameIds.value.includes(gameId)) return
|
||||||
|
if (featuredGameIds.value.length >= 50) {
|
||||||
|
error.value = '상단 고정 게임은 최대 50개까지만 설정할 수 있어요.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
featuredGameIds.value = [...featuredGameIds.value, gameId]
|
||||||
|
syncFeaturedSortable()
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeFeaturedGame(gameId) {
|
||||||
|
resetMessages()
|
||||||
|
featuredGameIds.value = featuredGameIds.value.filter((id) => id !== gameId)
|
||||||
|
syncFeaturedSortable()
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveFeaturedGame(gameId, direction) {
|
||||||
|
const currentIndex = featuredGameIds.value.indexOf(gameId)
|
||||||
|
const nextIndex = currentIndex + direction
|
||||||
|
if (currentIndex < 0 || nextIndex < 0 || nextIndex >= featuredGameIds.value.length) return
|
||||||
|
const nextIds = [...featuredGameIds.value]
|
||||||
|
const [moved] = nextIds.splice(currentIndex, 1)
|
||||||
|
nextIds.splice(nextIndex, 0, moved)
|
||||||
|
featuredGameIds.value = nextIds
|
||||||
|
syncFeaturedSortable()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveFeaturedOrder() {
|
||||||
|
resetMessages()
|
||||||
|
try {
|
||||||
|
const data = await api.updateAdminGameDisplayOrder({ gameIds: featuredGameIds.value })
|
||||||
|
games.value = data.games || []
|
||||||
|
featuredGameIds.value = games.value
|
||||||
|
.filter((game) => game.displayRank != null)
|
||||||
|
.sort((a, b) => a.displayRank - b.displayRank)
|
||||||
|
.map((game) => game.id)
|
||||||
|
success.value = '홈 화면 게임 순서를 저장했어요.'
|
||||||
|
} catch (e) {
|
||||||
|
error.value = '게임 순서 저장에 실패했어요.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
destroyFeaturedSortable,
|
||||||
|
syncFeaturedSortable,
|
||||||
|
addFeaturedGame,
|
||||||
|
removeFeaturedGame,
|
||||||
|
moveFeaturedGame,
|
||||||
|
saveFeaturedOrder,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -135,7 +135,11 @@ export function useAdminGameManager({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ id: newGameId.value.trim(), name: newGameName.value.trim() }),
|
body: JSON.stringify({
|
||||||
|
id: newGameId.value.trim(),
|
||||||
|
name: newGameName.value.trim(),
|
||||||
|
thumbnailSrc: activeTemplateRequest.value?.type === 'create' ? (activeTemplateRequest.value?.thumbnailSrc || '') : '',
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
if (!res.ok) throw new Error('failed')
|
if (!res.ok) throw new Error('failed')
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export function useAdminTemplateRequests({
|
|||||||
id: request.id,
|
id: request.id,
|
||||||
type: request.type,
|
type: request.type,
|
||||||
status: request.status,
|
status: request.status,
|
||||||
|
thumbnailSrc: request.thumbnailSrc || '',
|
||||||
draftGameId: request.draftGameId || '',
|
draftGameId: request.draftGameId || '',
|
||||||
draftGameName: request.draftGameName || '',
|
draftGameName: request.draftGameName || '',
|
||||||
sourceTierListId: request.sourceTierListId || '',
|
sourceTierListId: request.sourceTierListId || '',
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Teleport, computed, inject, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
import { Teleport, computed, inject, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import Sortable from 'sortablejs'
|
|
||||||
import { api } from '../lib/api'
|
import { api } from '../lib/api'
|
||||||
import { toApiUrl } from '../lib/runtime'
|
import { toApiUrl } from '../lib/runtime'
|
||||||
import lockResetIcon from '../assets/icons/lock_reset.svg'
|
import lockResetIcon from '../assets/icons/lock_reset.svg'
|
||||||
@@ -12,6 +11,8 @@ import AdminGamesSection from '../components/admin/AdminGamesSection.vue'
|
|||||||
import AdminItemsSection from '../components/admin/AdminItemsSection.vue'
|
import AdminItemsSection from '../components/admin/AdminItemsSection.vue'
|
||||||
import AdminTierlistsSection from '../components/admin/AdminTierlistsSection.vue'
|
import AdminTierlistsSection from '../components/admin/AdminTierlistsSection.vue'
|
||||||
import AdminUsersSection from '../components/admin/AdminUsersSection.vue'
|
import AdminUsersSection from '../components/admin/AdminUsersSection.vue'
|
||||||
|
import { useAdminCustomItems } from '../composables/useAdminCustomItems'
|
||||||
|
import { useAdminFeaturedGames } from '../composables/useAdminFeaturedGames'
|
||||||
import { useAdminGameManager } from '../composables/useAdminGameManager'
|
import { useAdminGameManager } from '../composables/useAdminGameManager'
|
||||||
import { useAdminTemplateRequests } from '../composables/useAdminTemplateRequests'
|
import { useAdminTemplateRequests } from '../composables/useAdminTemplateRequests'
|
||||||
import { useAdminUsers } from '../composables/useAdminUsers'
|
import { useAdminUsers } from '../composables/useAdminUsers'
|
||||||
@@ -647,34 +648,6 @@ async function refreshGames() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroyFeaturedSortable() {
|
|
||||||
if (featuredSortable.value) {
|
|
||||||
featuredSortable.value.destroy()
|
|
||||||
featuredSortable.value = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function syncFeaturedSortable() {
|
|
||||||
await nextTick()
|
|
||||||
destroyFeaturedSortable()
|
|
||||||
if (!featuredListEl.value) return
|
|
||||||
|
|
||||||
featuredSortable.value = Sortable.create(featuredListEl.value, {
|
|
||||||
animation: 160,
|
|
||||||
draggable: '[data-featured-id]',
|
|
||||||
handle: '[data-featured-handle]',
|
|
||||||
ghostClass: 'ghost',
|
|
||||||
chosenClass: 'chosen',
|
|
||||||
onEnd: (evt) => {
|
|
||||||
if (evt.oldIndex == null || evt.newIndex == null || evt.oldIndex === evt.newIndex) return
|
|
||||||
const nextIds = [...featuredGameIds.value]
|
|
||||||
const [moved] = nextIds.splice(evt.oldIndex, 1)
|
|
||||||
nextIds.splice(evt.newIndex, 0, moved)
|
|
||||||
featuredGameIds.value = nextIds
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function refreshCustomItems() {
|
async function refreshCustomItems() {
|
||||||
if (!auth.user?.isAdmin) return
|
if (!auth.user?.isAdmin) return
|
||||||
try {
|
try {
|
||||||
@@ -753,6 +726,24 @@ function resetUploadState() {
|
|||||||
clearPreviewUrl('thumb')
|
clearPreviewUrl('thumb')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
destroyFeaturedSortable,
|
||||||
|
syncFeaturedSortable,
|
||||||
|
addFeaturedGame,
|
||||||
|
removeFeaturedGame,
|
||||||
|
moveFeaturedGame,
|
||||||
|
saveFeaturedOrder,
|
||||||
|
} = useAdminFeaturedGames({
|
||||||
|
api,
|
||||||
|
featuredListEl,
|
||||||
|
featuredSortable,
|
||||||
|
featuredGameIds,
|
||||||
|
games,
|
||||||
|
resetMessages,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
destroyGameItemSortable,
|
destroyGameItemSortable,
|
||||||
mergeRequestItemsIntoDrafts,
|
mergeRequestItemsIntoDrafts,
|
||||||
@@ -816,6 +807,49 @@ const {
|
|||||||
error,
|
error,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
submitCustomItemSearch,
|
||||||
|
toggleCustomItemOrphanOnly,
|
||||||
|
changeCustomItemLimit,
|
||||||
|
moveCustomItemPage,
|
||||||
|
openCustomItemModal,
|
||||||
|
closeCustomItemModal,
|
||||||
|
openCustomItemDeleteModal,
|
||||||
|
closeCustomItemDeleteModal,
|
||||||
|
jumpToGameAdmin,
|
||||||
|
removeCustomItem,
|
||||||
|
removeUnusedCustomItems,
|
||||||
|
saveCustomItemModalLabel,
|
||||||
|
promoteCustomItem,
|
||||||
|
} = useAdminCustomItems({
|
||||||
|
api,
|
||||||
|
toast,
|
||||||
|
customItems,
|
||||||
|
customItemPage,
|
||||||
|
customItemLimit,
|
||||||
|
customItemPageCount,
|
||||||
|
customItemQuery,
|
||||||
|
customItemOrphanOnly,
|
||||||
|
customItemModalOpen,
|
||||||
|
customItemDeleteModalOpen,
|
||||||
|
customItemModalHistoryActive,
|
||||||
|
modalTargetCustomItem,
|
||||||
|
customItemModalDraftLabel,
|
||||||
|
customItemModalLabelSaving,
|
||||||
|
customItemModalTargetGameId,
|
||||||
|
customItemModalGameQuery,
|
||||||
|
customItemModalGameSort,
|
||||||
|
games,
|
||||||
|
selectedGameId,
|
||||||
|
refreshCustomItems,
|
||||||
|
loadGame,
|
||||||
|
setTab,
|
||||||
|
selectAdminGame,
|
||||||
|
resetMessages,
|
||||||
|
success,
|
||||||
|
error,
|
||||||
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
setUserAvatarInput,
|
setUserAvatarInput,
|
||||||
canManageModalRole,
|
canManageModalRole,
|
||||||
@@ -1013,22 +1047,6 @@ async function removeGame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitCustomItemSearch() {
|
|
||||||
customItemPage.value = 1
|
|
||||||
refreshCustomItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleCustomItemOrphanOnly() {
|
|
||||||
customItemPage.value = 1
|
|
||||||
refreshCustomItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeCustomItemLimit(limit) {
|
|
||||||
customItemLimit.value = limit
|
|
||||||
customItemPage.value = 1
|
|
||||||
refreshCustomItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitAdminTierListSearch() {
|
function submitAdminTierListSearch() {
|
||||||
adminTierListPage.value = 1
|
adminTierListPage.value = 1
|
||||||
refreshAdminTierLists()
|
refreshAdminTierLists()
|
||||||
@@ -1047,146 +1065,6 @@ function moveAdminTierListPage(direction) {
|
|||||||
refreshAdminTierLists()
|
refreshAdminTierLists()
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveCustomItemPage(direction) {
|
|
||||||
const nextPage = customItemPage.value + direction
|
|
||||||
if (nextPage < 1 || nextPage > customItemPageCount.value) return
|
|
||||||
customItemPage.value = nextPage
|
|
||||||
refreshCustomItems()
|
|
||||||
}
|
|
||||||
|
|
||||||
function pushCustomItemModalHistoryState() {
|
|
||||||
if (typeof window === 'undefined') return
|
|
||||||
window.history.pushState({ ...(window.history.state || {}), adminCustomItemModal: true }, '', window.location.href)
|
|
||||||
customItemModalHistoryActive.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCustomItemModal(item) {
|
|
||||||
modalTargetCustomItem.value = item || null
|
|
||||||
customItemModalDraftLabel.value = item?.label || ''
|
|
||||||
customItemModalTargetGameId.value = ''
|
|
||||||
customItemModalGameQuery.value = ''
|
|
||||||
customItemModalGameSort.value = 'recent'
|
|
||||||
customItemModalOpen.value = true
|
|
||||||
pushCustomItemModalHistoryState()
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeCustomItemModal({ fromPopState = false } = {}) {
|
|
||||||
customItemModalOpen.value = false
|
|
||||||
customItemDeleteModalOpen.value = false
|
|
||||||
modalTargetCustomItem.value = null
|
|
||||||
customItemModalDraftLabel.value = ''
|
|
||||||
customItemModalLabelSaving.value = false
|
|
||||||
customItemModalTargetGameId.value = ''
|
|
||||||
customItemModalGameQuery.value = ''
|
|
||||||
customItemModalGameSort.value = 'recent'
|
|
||||||
|
|
||||||
if (fromPopState) {
|
|
||||||
customItemModalHistoryActive.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customItemModalHistoryActive.value && typeof window !== 'undefined') {
|
|
||||||
customItemModalHistoryActive.value = false
|
|
||||||
window.history.back()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCustomItemDeleteModal(item) {
|
|
||||||
if (!item) return
|
|
||||||
if (item.sourceType === 'user' && (item.usageCount > 0 || item.linkedGames.length > 0)) {
|
|
||||||
error.value = '사용 중이거나 템플릿에 연결된 사용자 업로드 이미지는 먼저 참조를 정리해야 삭제할 수 있어요.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
modalTargetCustomItem.value = item
|
|
||||||
customItemDeleteModalOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeCustomItemDeleteModal() {
|
|
||||||
customItemDeleteModalOpen.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function jumpToGameAdmin(gameId) {
|
|
||||||
if (!gameId) return
|
|
||||||
closeCustomItemModal()
|
|
||||||
setTab('game-admin')
|
|
||||||
nextTick(() => {
|
|
||||||
selectAdminGame(gameId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeCustomItem(item = modalTargetCustomItem.value) {
|
|
||||||
resetMessages()
|
|
||||||
if (!item) return
|
|
||||||
if (item.sourceType === 'user' && (item.usageCount > 0 || item.linkedGames.length > 0)) {
|
|
||||||
error.value = '사용 중이거나 템플릿에 연결된 사용자 업로드 이미지는 먼저 참조를 정리해야 삭제할 수 있어요.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await api.deleteAdminCustomItem(item.id)
|
|
||||||
closeCustomItemDeleteModal()
|
|
||||||
closeCustomItemModal()
|
|
||||||
await refreshCustomItems()
|
|
||||||
success.value = item.sourceType === 'template' ? '선택한 템플릿 아이템을 제거했어요.' : '사용자 업로드 이미지를 삭제했어요.'
|
|
||||||
} catch (e) {
|
|
||||||
error.value = item.sourceType === 'template' ? '템플릿 아이템 제거에 실패했어요.' : '사용자 업로드 이미지 삭제에 실패했어요.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeUnusedCustomItems() {
|
|
||||||
resetMessages()
|
|
||||||
const ok = window.confirm('현재 검색 조건에 맞는 미사용 커스텀 이미지를 모두 삭제할까요?')
|
|
||||||
if (!ok) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
const data = await api.deleteAdminUnusedCustomItems({ q: customItemQuery.value })
|
|
||||||
await refreshCustomItems()
|
|
||||||
success.value = `${data.deletedCount || 0}개의 미사용 사용자 업로드 이미지를 삭제했어요.`
|
|
||||||
} catch (e) {
|
|
||||||
error.value = '미사용 커스텀 이미지 일괄 삭제에 실패했어요.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveCustomItemModalLabel() {
|
|
||||||
const item = modalTargetCustomItem.value
|
|
||||||
const nextLabel = customItemModalDraftLabel.value.trim().slice(0, 60)
|
|
||||||
if (!item || !nextLabel || nextLabel === item.label || customItemModalLabelSaving.value) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
customItemModalLabelSaving.value = true
|
|
||||||
const data = await api.updateAdminCustomItemLabel(item.id, { label: nextLabel, sourceType: item.sourceType })
|
|
||||||
item.label = data.item?.label || nextLabel
|
|
||||||
customItemModalDraftLabel.value = item.label
|
|
||||||
customItems.value = customItems.value.map((entry) => (entry.id === item.id ? { ...entry, label: item.label } : entry))
|
|
||||||
toast.success('아이템 이름을 변경했어요.')
|
|
||||||
} catch (e) {
|
|
||||||
error.value = '아이템 이름 변경에 실패했어요.'
|
|
||||||
} finally {
|
|
||||||
customItemModalLabelSaving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function promoteCustomItem(item) {
|
|
||||||
resetMessages()
|
|
||||||
if (!customItemModalTargetGameId.value) {
|
|
||||||
error.value = '추가할 게임을 먼저 선택해주세요.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
item.isPromoting = true
|
|
||||||
await api.promoteAdminCustomItem(item.id, { gameId: customItemModalTargetGameId.value })
|
|
||||||
const targetGameName = games.value.find((game) => game.id === customItemModalTargetGameId.value)?.name || customItemModalTargetGameId.value
|
|
||||||
if (selectedGameId.value === customItemModalTargetGameId.value) await loadGame()
|
|
||||||
closeCustomItemModal()
|
|
||||||
success.value = `"${item.label}" 이미지를 ${targetGameName} 템플릿으로 추가했어요.`
|
|
||||||
} catch (e) {
|
|
||||||
error.value = '선택한 이미지를 템플릿으로 추가하지 못했어요.'
|
|
||||||
} finally {
|
|
||||||
item.isPromoting = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function buildModalItemFromTierListItem(item, tierList) {
|
function buildModalItemFromTierListItem(item, tierList) {
|
||||||
const matchedItem = customItems.value.find((entry) => entry.id === item?.id || entry.src === item?.src)
|
const matchedItem = customItems.value.find((entry) => entry.id === item?.id || entry.src === item?.src)
|
||||||
@@ -1414,48 +1292,6 @@ function userAvatarFallback(user) {
|
|||||||
return (user?.email?.trim()?.[0] || '?').toUpperCase()
|
return (user?.email?.trim()?.[0] || '?').toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFeaturedGame(gameId) {
|
|
||||||
resetMessages()
|
|
||||||
if (!gameId || featuredGameIds.value.includes(gameId)) return
|
|
||||||
if (featuredGameIds.value.length >= 50) {
|
|
||||||
error.value = '상단 고정 게임은 최대 50개까지만 설정할 수 있어요.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
featuredGameIds.value = [...featuredGameIds.value, gameId]
|
|
||||||
syncFeaturedSortable()
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFeaturedGame(gameId) {
|
|
||||||
resetMessages()
|
|
||||||
featuredGameIds.value = featuredGameIds.value.filter((id) => id !== gameId)
|
|
||||||
syncFeaturedSortable()
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveFeaturedGame(gameId, direction) {
|
|
||||||
const currentIndex = featuredGameIds.value.indexOf(gameId)
|
|
||||||
const nextIndex = currentIndex + direction
|
|
||||||
if (currentIndex < 0 || nextIndex < 0 || nextIndex >= featuredGameIds.value.length) return
|
|
||||||
const nextIds = [...featuredGameIds.value]
|
|
||||||
const [moved] = nextIds.splice(currentIndex, 1)
|
|
||||||
nextIds.splice(nextIndex, 0, moved)
|
|
||||||
featuredGameIds.value = nextIds
|
|
||||||
syncFeaturedSortable()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveFeaturedOrder() {
|
|
||||||
resetMessages()
|
|
||||||
try {
|
|
||||||
const data = await api.updateAdminGameDisplayOrder({ gameIds: featuredGameIds.value })
|
|
||||||
games.value = data.games || []
|
|
||||||
featuredGameIds.value = games.value
|
|
||||||
.filter((game) => game.displayRank != null)
|
|
||||||
.sort((a, b) => a.displayRank - b.displayRank)
|
|
||||||
.map((game) => game.id)
|
|
||||||
success.value = '홈 화면 게임 순서를 저장했어요.'
|
|
||||||
} catch (e) {
|
|
||||||
error.value = '게임 순서 저장에 실패했어요.'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -1538,12 +1374,10 @@ async function saveFeaturedOrder() {
|
|||||||
:tierlists-mode="tierlistsMode"
|
:tierlists-mode="tierlistsMode"
|
||||||
:template-requests="templateRequests"
|
:template-requests="templateRequests"
|
||||||
:open-template-request-preview="openTemplateRequestPreview"
|
:open-template-request-preview="openTemplateRequestPreview"
|
||||||
:template-request-type-label="templateRequestTypeLabel"
|
|
||||||
:fmt="fmt"
|
:fmt="fmt"
|
||||||
:template-request-target-label="templateRequestTargetLabel"
|
:template-request-target-label="templateRequestTargetLabel"
|
||||||
:template-request-status-label="templateRequestStatusLabel"
|
:template-request-status-label="templateRequestStatusLabel"
|
||||||
:template-request-source-url="templateRequestSourceUrl"
|
:template-request-source-url="templateRequestSourceUrl"
|
||||||
:template-request-review-hint="templateRequestReviewHint"
|
|
||||||
:start-template-request-review="startTemplateRequestReview"
|
:start-template-request-review="startTemplateRequestReview"
|
||||||
:complete-template-request="completeTemplateRequest"
|
:complete-template-request="completeTemplateRequest"
|
||||||
:admin-tier-lists="adminTierLists"
|
:admin-tier-lists="adminTierLists"
|
||||||
@@ -2930,6 +2764,26 @@ async function saveFeaturedOrder() {
|
|||||||
.adminUiScope .pill--soft {
|
.adminUiScope .pill--soft {
|
||||||
background: rgba(255, 255, 255, 0.08);
|
background: rgba(255, 255, 255, 0.08);
|
||||||
}
|
}
|
||||||
|
.adminUiScope .pill--create {
|
||||||
|
border-color: rgba(56, 189, 248, 0.36);
|
||||||
|
background: rgba(56, 189, 248, 0.16);
|
||||||
|
color: rgba(224, 242, 254, 0.98);
|
||||||
|
}
|
||||||
|
.adminUiScope .pill--owned {
|
||||||
|
border-color: rgba(167, 139, 250, 0.34);
|
||||||
|
background: rgba(167, 139, 250, 0.14);
|
||||||
|
color: rgba(243, 232, 255, 0.98);
|
||||||
|
}
|
||||||
|
.adminUiScope .pill--requestItem {
|
||||||
|
border-color: rgba(250, 204, 21, 0.34);
|
||||||
|
background: rgba(250, 204, 21, 0.14);
|
||||||
|
color: rgba(254, 249, 195, 0.98);
|
||||||
|
}
|
||||||
|
.adminUiScope .pill--directFile {
|
||||||
|
border-color: rgba(52, 211, 153, 0.34);
|
||||||
|
background: rgba(52, 211, 153, 0.14);
|
||||||
|
color: rgba(209, 250, 229, 0.98);
|
||||||
|
}
|
||||||
.adminUiScope .requestWorkspace {
|
.adminUiScope .requestWorkspace {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
@@ -3532,9 +3386,17 @@ async function saveFeaturedOrder() {
|
|||||||
.adminUiScope .templateRequestCard__items {
|
.adminUiScope .templateRequestCard__items {
|
||||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
||||||
}
|
}
|
||||||
.adminUiScope .templateRequestCard__links {
|
.adminUiScope .templateRequestCard__footer {
|
||||||
display: grid;
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.adminUiScope .templateRequestCard__footerLeft {
|
||||||
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
.adminUiScope .templateRequestCard__actions {
|
.adminUiScope .templateRequestCard__actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -3721,6 +3583,7 @@ async function saveFeaturedOrder() {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
.adminUiScope .tierAdminCard__head {
|
.adminUiScope .tierAdminCard__head {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -3728,9 +3591,15 @@ async function saveFeaturedOrder() {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
.adminUiScope .templateRequestCard__cornerBadge {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
.adminUiScope .tierAdminCard__title {
|
.adminUiScope .tierAdminCard__title {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
|
padding-right: 132px;
|
||||||
}
|
}
|
||||||
.adminUiScope .tierAdminCard__desc {
|
.adminUiScope .tierAdminCard__desc {
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
|
|||||||
Reference in New Issue
Block a user