릴리스: v0.1.13 관리자 탭과 가변 티어 행 추가
This commit is contained in:
@@ -7,13 +7,21 @@ import { useAuthStore } from '../stores/auth'
|
||||
const auth = useAuthStore()
|
||||
const isAdmin = computed(() => !!auth.user?.isAdmin)
|
||||
|
||||
const activeTab = ref('games')
|
||||
const gameMode = ref('existing')
|
||||
|
||||
const games = ref([])
|
||||
const customItems = ref([])
|
||||
const users = ref([])
|
||||
const adminMode = ref('existing')
|
||||
const selectedGameId = ref('')
|
||||
const selectedGame = ref(null)
|
||||
|
||||
const customItems = ref([])
|
||||
const customItemQuery = ref('')
|
||||
const customItemPage = ref(1)
|
||||
const customItemLimit = ref(50)
|
||||
const customItemTotal = ref(0)
|
||||
|
||||
const users = ref([])
|
||||
|
||||
const error = ref('')
|
||||
const success = ref('')
|
||||
|
||||
@@ -31,6 +39,7 @@ const thumbFileInput = ref(null)
|
||||
const hasSelectedGame = computed(() => !!selectedGame.value?.game?.id)
|
||||
const canApplyThumbnail = computed(() => !!thumbFile.value && !!selectedGameId.value)
|
||||
const canAddItem = computed(() => !!uploadFile.value && !!selectedGameId.value)
|
||||
const customItemPageCount = computed(() => Math.max(1, Math.ceil(customItemTotal.value / customItemLimit.value)))
|
||||
|
||||
onMounted(async () => {
|
||||
await auth.refresh()
|
||||
@@ -42,6 +51,16 @@ onUnmounted(() => {
|
||||
clearPreviewUrl('thumb')
|
||||
})
|
||||
|
||||
function resetMessages() {
|
||||
error.value = ''
|
||||
success.value = ''
|
||||
}
|
||||
|
||||
function setTab(tab) {
|
||||
resetMessages()
|
||||
activeTab.value = tab
|
||||
}
|
||||
|
||||
async function refreshGames() {
|
||||
try {
|
||||
const data = await api.listGames()
|
||||
@@ -54,8 +73,15 @@ async function refreshGames() {
|
||||
async function refreshCustomItems() {
|
||||
if (!auth.user?.isAdmin) return
|
||||
try {
|
||||
const data = await api.listAdminCustomItems()
|
||||
const data = await api.listAdminCustomItems({
|
||||
q: customItemQuery.value,
|
||||
page: customItemPage.value,
|
||||
limit: customItemLimit.value,
|
||||
})
|
||||
customItems.value = data.items || []
|
||||
customItemTotal.value = data.total || 0
|
||||
customItemPage.value = data.page || 1
|
||||
customItemLimit.value = data.limit || customItemLimit.value
|
||||
} catch (e) {
|
||||
error.value = '사용자 커스텀 아이템을 불러오지 못했어요.'
|
||||
}
|
||||
@@ -70,17 +96,13 @@ async function refreshUsers() {
|
||||
draftEmail: user.email,
|
||||
draftNickname: user.nickname || '',
|
||||
draftIsAdmin: !!user.isAdmin,
|
||||
draftPassword: '',
|
||||
}))
|
||||
} catch (e) {
|
||||
error.value = '회원 목록을 불러오지 못했어요.'
|
||||
}
|
||||
}
|
||||
|
||||
function resetMessages() {
|
||||
error.value = ''
|
||||
success.value = ''
|
||||
}
|
||||
|
||||
function resetUploadState() {
|
||||
uploadLabel.value = ''
|
||||
uploadFile.value = null
|
||||
@@ -91,9 +113,9 @@ function resetUploadState() {
|
||||
clearPreviewUrl('thumb')
|
||||
}
|
||||
|
||||
function setMode(mode) {
|
||||
function setGameMode(mode) {
|
||||
resetMessages()
|
||||
adminMode.value = mode
|
||||
gameMode.value = mode
|
||||
selectedGameId.value = ''
|
||||
selectedGame.value = null
|
||||
newGameId.value = ''
|
||||
@@ -113,12 +135,8 @@ function clearPreviewUrl(type) {
|
||||
}
|
||||
|
||||
function resetFileInput(type) {
|
||||
if (type === 'item' && itemFileInput.value) {
|
||||
itemFileInput.value.value = ''
|
||||
}
|
||||
if (type === 'thumb' && thumbFileInput.value) {
|
||||
thumbFileInput.value.value = ''
|
||||
}
|
||||
if (type === 'item' && itemFileInput.value) itemFileInput.value.value = ''
|
||||
if (type === 'thumb' && thumbFileInput.value) thumbFileInput.value.value = ''
|
||||
}
|
||||
|
||||
async function loadGame() {
|
||||
@@ -151,7 +169,7 @@ async function createGame() {
|
||||
|
||||
const data = await res.json()
|
||||
await refreshGames()
|
||||
adminMode.value = 'existing'
|
||||
gameMode.value = 'existing'
|
||||
selectedGameId.value = data.game.id
|
||||
await loadGame()
|
||||
success.value = '게임이 생성됐어요. 이어서 썸네일과 아이템을 관리할 수 있어요.'
|
||||
@@ -163,17 +181,13 @@ async function createGame() {
|
||||
function onThumb(event) {
|
||||
thumbFile.value = event.target.files && event.target.files[0] ? event.target.files[0] : null
|
||||
clearPreviewUrl('thumb')
|
||||
if (thumbFile.value) {
|
||||
thumbPreviewUrl.value = URL.createObjectURL(thumbFile.value)
|
||||
}
|
||||
if (thumbFile.value) thumbPreviewUrl.value = URL.createObjectURL(thumbFile.value)
|
||||
}
|
||||
|
||||
function onFile(event) {
|
||||
uploadFile.value = event.target.files && event.target.files[0] ? event.target.files[0] : null
|
||||
clearPreviewUrl('item')
|
||||
if (uploadFile.value) {
|
||||
itemPreviewUrl.value = URL.createObjectURL(uploadFile.value)
|
||||
}
|
||||
if (uploadFile.value) itemPreviewUrl.value = URL.createObjectURL(uploadFile.value)
|
||||
}
|
||||
|
||||
async function uploadThumbnail() {
|
||||
@@ -224,13 +238,13 @@ async function uploadItem() {
|
||||
|
||||
resetUploadState()
|
||||
await loadGame()
|
||||
success.value = '아이템이 추가됐어요.'
|
||||
success.value = '게임 기본 아이템이 추가됐어요.'
|
||||
} catch (e) {
|
||||
error.value = '아이템 추가 실패(관리자 권한/파일 크기 확인)'
|
||||
}
|
||||
}
|
||||
|
||||
async function removeItem(itemId) {
|
||||
async function removeGameItem(itemId) {
|
||||
resetMessages()
|
||||
try {
|
||||
const res = await fetch(
|
||||
@@ -243,9 +257,9 @@ async function removeItem(itemId) {
|
||||
if (!res.ok) throw new Error('failed')
|
||||
|
||||
await loadGame()
|
||||
success.value = '아이템을 삭제했어요.'
|
||||
success.value = '게임 기본 아이템을 삭제했어요.'
|
||||
} catch (e) {
|
||||
error.value = '아이템 삭제에 실패했어요.'
|
||||
error.value = '게임 기본 아이템 삭제에 실패했어요.'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +267,7 @@ async function removeGame() {
|
||||
resetMessages()
|
||||
if (!selectedGameId.value || !selectedGame.value?.game) return
|
||||
|
||||
const ok = window.confirm(`"${selectedGame.value.game.name}" 게임을 삭제할까요? 관련 아이템과 티어표도 함께 삭제됩니다.`)
|
||||
const ok = window.confirm(`"${selectedGame.value.game.name}" 게임을 삭제할까요? 관련 기본 아이템과 티어표도 함께 삭제됩니다.`)
|
||||
if (!ok) return
|
||||
|
||||
try {
|
||||
@@ -285,12 +299,7 @@ async function saveUser(user) {
|
||||
const updated = data.user
|
||||
users.value = users.value.map((entry) =>
|
||||
entry.id === updated.id
|
||||
? {
|
||||
...updated,
|
||||
draftEmail: updated.email,
|
||||
draftNickname: updated.nickname || '',
|
||||
draftIsAdmin: !!updated.isAdmin,
|
||||
}
|
||||
? { ...entry, ...updated, draftEmail: updated.email, draftNickname: updated.nickname || '', draftIsAdmin: !!updated.isAdmin }
|
||||
: entry
|
||||
)
|
||||
success.value = '회원 정보를 저장했어요.'
|
||||
@@ -299,6 +308,22 @@ async function saveUser(user) {
|
||||
}
|
||||
}
|
||||
|
||||
async function resetUserPassword(user) {
|
||||
resetMessages()
|
||||
if (!(user.draftPassword || '').trim()) {
|
||||
error.value = '새 비밀번호를 입력해주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await api.updateAdminUserPassword(user.id, { password: user.draftPassword })
|
||||
user.draftPassword = ''
|
||||
success.value = '비밀번호를 초기화했어요.'
|
||||
} catch (e) {
|
||||
error.value = '비밀번호 초기화에 실패했어요.'
|
||||
}
|
||||
}
|
||||
|
||||
async function removeUser(user) {
|
||||
resetMessages()
|
||||
if (user.id === auth.user?.id) {
|
||||
@@ -318,6 +343,24 @@ async function removeUser(user) {
|
||||
}
|
||||
}
|
||||
|
||||
function submitCustomItemSearch() {
|
||||
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()
|
||||
}
|
||||
|
||||
const displayThumbnailUrl = computed(() => {
|
||||
if (thumbPreviewUrl.value) return thumbPreviewUrl.value
|
||||
if (selectedGame.value?.game?.thumbnailSrc) return toApiUrl(selectedGame.value.game.thumbnailSrc)
|
||||
@@ -339,162 +382,192 @@ function fmt(ts) {
|
||||
<section class="wrap">
|
||||
<h2 class="title">관리자</h2>
|
||||
<div class="card">
|
||||
<div class="desc">작업 종류를 먼저 고르고, 선택한 게임의 관리 화면만 집중해서 정리합니다.</div>
|
||||
<div class="desc">기능이 많아진 만큼 관리 영역을 게임, 아이템, 회원 관리로 나눠서 정리합니다.</div>
|
||||
<div v-if="!auth.user" class="warn">로그인이 필요해요.</div>
|
||||
<div v-else-if="!isAdmin" class="warn">이 계정은 관리자 권한이 없어요.</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="modeTabs">
|
||||
<button class="modeTab" :class="{ 'modeTab--active': adminMode === 'existing' }" @click="setMode('existing')">
|
||||
등록된 게임 선택
|
||||
</button>
|
||||
<button class="modeTab" :class="{ 'modeTab--active': adminMode === 'new' }" @click="setMode('new')">
|
||||
새 게임 추가
|
||||
</button>
|
||||
<div class="tabs">
|
||||
<button class="tab" :class="{ 'tab--active': activeTab === 'games' }" @click="setTab('games')">게임 관리</button>
|
||||
<button class="tab" :class="{ 'tab--active': activeTab === 'items' }" @click="setTab('items')">아이템 관리</button>
|
||||
<button class="tab" :class="{ 'tab--active': activeTab === 'users' }" @click="setTab('users')">회원 관리</button>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="error">{{ error }}</div>
|
||||
<div v-if="success" class="success">{{ success }}</div>
|
||||
|
||||
<div class="panel panel--compact">
|
||||
<template v-if="adminMode === 'existing'">
|
||||
<div class="panel__title">등록된 게임 선택</div>
|
||||
<select v-model="selectedGameId" class="select" @change="loadGame">
|
||||
<option value="">게임을 선택해주세요</option>
|
||||
<option v-for="game in games" :key="game.id" :value="game.id">{{ game.name }} ({{ game.id }})</option>
|
||||
</select>
|
||||
<div class="hint">게임을 고르면 아래에서 썸네일, 아이템 관리, 삭제 작업을 할 수 있어요.</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="panel__title">새 게임 정보 입력</div>
|
||||
<input v-model="newGameId" class="input" placeholder="game id (영문/숫자)" />
|
||||
<input v-model="newGameName" class="input" placeholder="게임 이름" />
|
||||
<button class="btn btn--primary" @click="createGame">게임 생성</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="hasSelectedGame" class="panel panel--detail">
|
||||
<div class="detailHead">
|
||||
<div>
|
||||
<div class="panel__title">선택된 게임 정보</div>
|
||||
<div class="selectedGame__name">{{ selectedGame.game.name }}</div>
|
||||
<div class="selectedGame__id">{{ selectedGame.game.id }}</div>
|
||||
</div>
|
||||
<div class="detailHead__actions">
|
||||
<button class="btn btn--danger" @click="removeGame">게임 삭제</button>
|
||||
</div>
|
||||
<template v-if="activeTab === 'games'">
|
||||
<div class="modeTabs">
|
||||
<button class="modeTab" :class="{ 'modeTab--active': gameMode === 'existing' }" @click="setGameMode('existing')">
|
||||
등록된 게임 선택
|
||||
</button>
|
||||
<button class="modeTab" :class="{ 'modeTab--active': gameMode === 'new' }" @click="setGameMode('new')">
|
||||
새 게임 추가
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="section section--topGrid">
|
||||
<section class="adminCard">
|
||||
<div class="section__title">썸네일 적용</div>
|
||||
<div class="uploadPreviewCard">
|
||||
<img
|
||||
v-if="displayThumbnailUrl"
|
||||
class="selectedThumb"
|
||||
:src="displayThumbnailUrl"
|
||||
:alt="selectedGame.game.name"
|
||||
/>
|
||||
<div v-else class="selectedThumb selectedThumb--empty">썸네일 미리보기</div>
|
||||
</div>
|
||||
<div class="uploadControls">
|
||||
<input ref="thumbFileInput" type="file" accept="image/*" class="inputFile" @change="onThumb" />
|
||||
<button class="btn" :disabled="!canApplyThumbnail" @click="uploadThumbnail">썸네일 적용</button>
|
||||
</div>
|
||||
</section>
|
||||
<div class="panel panel--compact">
|
||||
<template v-if="gameMode === 'existing'">
|
||||
<div class="panel__title">등록된 게임 선택</div>
|
||||
<select v-model="selectedGameId" class="select" @change="loadGame">
|
||||
<option value="">게임을 선택해주세요</option>
|
||||
<option v-for="game in games" :key="game.id" :value="game.id">{{ game.name }} ({{ game.id }})</option>
|
||||
</select>
|
||||
<div class="hint">이 영역은 게임 자체와 관리자 기본 아이템만 관리합니다. 여기서 아이템을 삭제해도 사용자 커스텀 이미지는 삭제되지 않아요.</div>
|
||||
</template>
|
||||
|
||||
<section class="adminCard">
|
||||
<div class="section__title">아이템 추가</div>
|
||||
<div class="itemComposer">
|
||||
<div class="itemComposer__form">
|
||||
<input v-model="uploadLabel" class="input input--compact" placeholder="아이템 이름" />
|
||||
<input ref="itemFileInput" type="file" accept="image/*" class="inputFile inputFile--tight" @change="onFile" />
|
||||
<button class="btn" :disabled="!canAddItem" @click="uploadItem">아이템 추가</button>
|
||||
<template v-else>
|
||||
<div class="panel__title">새 게임 정보 입력</div>
|
||||
<input v-model="newGameId" class="input" placeholder="game id (영문/숫자)" />
|
||||
<input v-model="newGameName" class="input" placeholder="게임 이름" />
|
||||
<button class="btn btn--primary" @click="createGame">게임 생성</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="hasSelectedGame" class="panel">
|
||||
<div class="detailHead">
|
||||
<div>
|
||||
<div class="panel__title">선택된 게임 정보</div>
|
||||
<div class="selectedGame__name">{{ selectedGame.game.name }}</div>
|
||||
<div class="selectedGame__id">{{ selectedGame.game.id }}</div>
|
||||
</div>
|
||||
<div class="detailHead__actions">
|
||||
<button class="btn btn--danger" @click="removeGame">게임 삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section section--topGrid">
|
||||
<section class="adminCard">
|
||||
<div class="section__title">썸네일 적용</div>
|
||||
<div class="uploadPreviewCard">
|
||||
<img v-if="displayThumbnailUrl" class="selectedThumb" :src="displayThumbnailUrl" :alt="selectedGame.game.name" />
|
||||
<div v-else class="selectedThumb selectedThumb--empty">썸네일 미리보기</div>
|
||||
</div>
|
||||
<div class="itemPreviewCard">
|
||||
<div class="itemPreviewFrame">
|
||||
<img v-if="itemPreviewUrl" class="itemPreviewImage" :src="itemPreviewUrl" alt="item preview" />
|
||||
<div v-else class="itemPreviewEmpty">이미지를 선택해주세요</div>
|
||||
<div class="uploadControls">
|
||||
<input ref="thumbFileInput" type="file" accept="image/*" class="inputFile" @change="onThumb" />
|
||||
<button class="btn" :disabled="!canApplyThumbnail" @click="uploadThumbnail">썸네일 적용</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="adminCard">
|
||||
<div class="section__title">기본 아이템 추가</div>
|
||||
<div class="itemComposer">
|
||||
<div class="itemComposer__form">
|
||||
<input v-model="uploadLabel" class="input input--compact" placeholder="아이템 이름" />
|
||||
<input ref="itemFileInput" type="file" accept="image/*" class="inputFile inputFile--tight" @change="onFile" />
|
||||
<button class="btn" :disabled="!canAddItem" @click="uploadItem">아이템 추가</button>
|
||||
</div>
|
||||
<div class="thumbLabel thumbLabel--preview">{{ uploadLabel || '아이템 이름 미리보기' }}</div>
|
||||
<div class="itemPreviewCard">
|
||||
<div class="itemPreviewFrame">
|
||||
<img v-if="itemPreviewUrl" class="itemPreviewImage" :src="itemPreviewUrl" alt="item preview" />
|
||||
<div v-else class="itemPreviewEmpty">이미지를 선택해주세요</div>
|
||||
</div>
|
||||
<div class="thumbLabel thumbLabel--preview">{{ uploadLabel || '아이템 이름 미리보기' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section__title">현재 기본 아이템 목록</div>
|
||||
<div v-if="!selectedGame?.items?.length" class="hint">아직 등록된 기본 아이템이 없어요.</div>
|
||||
<div v-else class="thumbGrid">
|
||||
<div v-for="item in selectedGame.items" :key="item.id" class="thumbCard">
|
||||
<img class="thumb thumb--game" :src="toApiUrl(item.src)" :alt="item.label" />
|
||||
<div class="thumbLabel">{{ item.label }}</div>
|
||||
<button class="btn btn--danger btn--small" @click="removeGameItem(item.id)">아이템 삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="section">
|
||||
<div class="section__title">현재 아이템 목록</div>
|
||||
<div v-if="!selectedGame?.items?.length" class="hint">아직 등록된 아이템이 없어요.</div>
|
||||
<div v-else class="thumbGrid">
|
||||
<div v-for="item in selectedGame.items" :key="item.id" class="thumbCard">
|
||||
<img class="thumb" :src="toApiUrl(item.src)" :alt="item.label" />
|
||||
<div class="thumbLabel">{{ item.label }}</div>
|
||||
<button class="btn btn--danger btn--small" @click="removeItem(item.id)">아이템 삭제</button>
|
||||
<template v-else-if="activeTab === 'items'">
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
<div class="panel__title">사용자 커스텀 아이템 관리</div>
|
||||
<div class="hint hint--tight">사용자가 업로드한 이미지를 파일명/라벨 기준으로 검색하고, 한 번에 50개 또는 200개씩 페이지 형태로 확인할 수 있어요.</div>
|
||||
</div>
|
||||
<button class="btn btn--ghost" @click="refreshCustomItems">새로고침</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
<div class="panel__title">사용자 커스텀 아이템</div>
|
||||
<div class="hint hint--tight">사용자가 직접 올린 이미지를 훑어보고, 필요하면 다운로드해 기본 템플릿으로 재구성할 수 있어요.</div>
|
||||
<div class="toolbar">
|
||||
<input v-model="customItemQuery" class="input toolbar__search" placeholder="파일명, 라벨, 업로더 검색" @keydown.enter.prevent="submitCustomItemSearch" />
|
||||
<button class="btn btn--ghost toolbar__button" @click="submitCustomItemSearch">검색</button>
|
||||
<select :value="customItemLimit" class="select toolbar__select" @change="changeCustomItemLimit(Number($event.target.value))">
|
||||
<option :value="50">50개씩 보기</option>
|
||||
<option :value="200">200개씩 보기</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn--ghost" @click="refreshCustomItems">새로고침</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!customItems.length" class="hint">아직 업로드된 사용자 커스텀 아이템이 없어요.</div>
|
||||
<div v-else class="customItemGrid">
|
||||
<article v-for="item in customItems" :key="item.id" class="customItemCard">
|
||||
<img class="customItemCard__image" :src="toApiUrl(item.src)" :alt="item.label" />
|
||||
<div class="customItemCard__body">
|
||||
<div class="customItemCard__title">{{ item.label }}</div>
|
||||
<div class="customItemCard__meta">업로더: {{ item.ownerName }}</div>
|
||||
<div class="customItemCard__meta">{{ fmt(item.createdAt) }}</div>
|
||||
<a class="btn btn--small btn--ghost" :href="toApiUrl(item.src)" :download="item.label">이미지 다운로드</a>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hint">현재 목록은 사용자 커스텀 이미지 전용입니다. 여기서 보는 항목은 게임 기본 아이템 삭제와 연결되지 않아요.</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
<div class="panel__title">회원 관리</div>
|
||||
<div class="hint hint--tight">가입한 계정의 이메일, 닉네임, 관리자 권한을 수정하거나 계정을 삭제할 수 있어요.</div>
|
||||
</div>
|
||||
<button class="btn btn--ghost" @click="refreshUsers">새로고침</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!users.length" class="hint">아직 가입한 회원이 없어요.</div>
|
||||
<div v-else class="userList">
|
||||
<article v-for="user in users" :key="user.id" class="userCard">
|
||||
<div class="userCard__head">
|
||||
<div>
|
||||
<div class="userCard__title">{{ user.nickname || '닉네임 없음' }}</div>
|
||||
<div class="userCard__meta">{{ fmt(user.createdAt) }}</div>
|
||||
<div v-if="!customItems.length" class="hint">조건에 맞는 커스텀 아이템이 없어요.</div>
|
||||
<div v-else class="customItemGrid">
|
||||
<article v-for="item in customItems" :key="item.id" class="customItemCard">
|
||||
<img class="customItemCard__image" :src="toApiUrl(item.src)" :alt="item.label" />
|
||||
<div class="customItemCard__body">
|
||||
<div class="customItemCard__title">{{ item.label }}</div>
|
||||
<div class="customItemCard__meta">파일: {{ item.src.split('/').pop() }}</div>
|
||||
<div class="customItemCard__meta">업로더: {{ item.ownerName }}</div>
|
||||
<div class="customItemCard__meta">{{ fmt(item.createdAt) }}</div>
|
||||
<a class="btn btn--small btn--ghost" :href="toApiUrl(item.src)" :download="item.label">이미지 다운로드</a>
|
||||
</div>
|
||||
<span class="roleBadge" :class="{ 'roleBadge--admin': user.draftIsAdmin }">
|
||||
{{ user.draftIsAdmin ? '관리자' : '일반 회원' }}
|
||||
</span>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<input v-model="user.draftEmail" class="input" placeholder="이메일" />
|
||||
<input v-model="user.draftNickname" class="input" placeholder="닉네임" />
|
||||
<label class="checkRow">
|
||||
<input v-model="user.draftIsAdmin" type="checkbox" :disabled="user.id === auth.user?.id" />
|
||||
<span>관리자 권한</span>
|
||||
</label>
|
||||
|
||||
<div class="userCard__actions">
|
||||
<button class="btn btn--ghost" @click="saveUser(user)">회원 저장</button>
|
||||
<button class="btn btn--danger" :disabled="user.id === auth.user?.id" @click="removeUser(user)">회원 삭제</button>
|
||||
</div>
|
||||
</article>
|
||||
<div class="pager">
|
||||
<button class="btn btn--ghost" :disabled="customItemPage <= 1" @click="moveCustomItemPage(-1)">이전</button>
|
||||
<div class="pager__info">{{ customItemPage }} / {{ customItemPageCount }} 페이지 · 총 {{ customItemTotal }}개</div>
|
||||
<button class="btn btn--ghost" :disabled="customItemPage >= customItemPageCount" @click="moveCustomItemPage(1)">다음</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
<div class="panel__title">회원 관리</div>
|
||||
<div class="hint hint--tight">이메일, 닉네임, 관리자 권한을 수정하고 비밀번호도 직접 초기화할 수 있어요.</div>
|
||||
</div>
|
||||
<button class="btn btn--ghost" @click="refreshUsers">새로고침</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!users.length" class="hint">아직 가입한 회원이 없어요.</div>
|
||||
<div v-else class="userList">
|
||||
<article v-for="user in users" :key="user.id" class="userCard">
|
||||
<div class="userCard__head">
|
||||
<div>
|
||||
<div class="userCard__title">{{ user.nickname || '닉네임 없음' }}</div>
|
||||
<div class="userCard__meta">{{ fmt(user.createdAt) }}</div>
|
||||
</div>
|
||||
<span class="roleBadge" :class="{ 'roleBadge--admin': user.draftIsAdmin }">
|
||||
{{ user.draftIsAdmin ? '관리자' : '일반 회원' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<input v-model="user.draftEmail" class="input" placeholder="이메일" />
|
||||
<input v-model="user.draftNickname" class="input" placeholder="닉네임" />
|
||||
<label class="checkRow">
|
||||
<input v-model="user.draftIsAdmin" type="checkbox" :disabled="user.id === auth.user?.id" />
|
||||
<span>관리자 권한</span>
|
||||
</label>
|
||||
|
||||
<div class="passwordBox">
|
||||
<input v-model="user.draftPassword" class="input" type="text" placeholder="새 비밀번호 직접 입력" />
|
||||
<button class="btn btn--ghost" @click="resetUserPassword(user)">비밀번호 초기화</button>
|
||||
</div>
|
||||
|
||||
<div class="userCard__actions">
|
||||
<button class="btn btn--ghost" @click="saveUser(user)">회원 저장</button>
|
||||
<button class="btn btn--danger" :disabled="user.id === auth.user?.id" @click="removeUser(user)">회원 삭제</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
@@ -538,12 +611,14 @@ function fmt(ts) {
|
||||
border: 1px solid rgba(52, 211, 153, 0.32);
|
||||
background: rgba(52, 211, 153, 0.14);
|
||||
}
|
||||
.tabs,
|
||||
.modeTabs {
|
||||
margin-top: 14px;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tab,
|
||||
.modeTab {
|
||||
padding: 10px 14px;
|
||||
border-radius: 12px;
|
||||
@@ -553,6 +628,7 @@ function fmt(ts) {
|
||||
cursor: pointer;
|
||||
font-weight: 800;
|
||||
}
|
||||
.tab--active,
|
||||
.modeTab--active {
|
||||
background: rgba(96, 165, 250, 0.2);
|
||||
}
|
||||
@@ -564,7 +640,7 @@ function fmt(ts) {
|
||||
padding: 14px;
|
||||
}
|
||||
.panel--compact {
|
||||
max-width: 640px;
|
||||
max-width: 760px;
|
||||
}
|
||||
.panel__title,
|
||||
.section__title {
|
||||
@@ -587,6 +663,27 @@ function fmt(ts) {
|
||||
padding: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
.sectionHeader {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.toolbar {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
}
|
||||
.toolbar__search,
|
||||
.toolbar__select {
|
||||
margin-top: 0;
|
||||
}
|
||||
.toolbar__button {
|
||||
margin-top: 0;
|
||||
}
|
||||
.uploadPreviewCard {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
@@ -664,6 +761,10 @@ function fmt(ts) {
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.detailHead__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.selectedGame__name {
|
||||
margin-top: 8px;
|
||||
font-size: 22px;
|
||||
@@ -674,10 +775,6 @@ function fmt(ts) {
|
||||
opacity: 0.72;
|
||||
word-break: break-all;
|
||||
}
|
||||
.detailHead__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.selectedThumb {
|
||||
width: min(100%, 256px);
|
||||
aspect-ratio: 16 / 9;
|
||||
@@ -734,7 +831,7 @@ function fmt(ts) {
|
||||
.thumbGrid {
|
||||
margin-top: 12px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.thumbCard {
|
||||
@@ -751,6 +848,11 @@ function fmt(ts) {
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.thumb--game {
|
||||
max-width: 150px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
.thumbLabel {
|
||||
margin-top: 8px;
|
||||
font-weight: 900;
|
||||
@@ -761,13 +863,6 @@ function fmt(ts) {
|
||||
.thumbLabel--preview {
|
||||
text-align: center;
|
||||
}
|
||||
.sectionHeader {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.customItemGrid {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
@@ -781,10 +876,12 @@ function fmt(ts) {
|
||||
overflow: hidden;
|
||||
}
|
||||
.customItemCard__image {
|
||||
width: 100%;
|
||||
width: min(100%, 150px);
|
||||
aspect-ratio: 1 / 1;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
margin: 12px auto 0;
|
||||
border-radius: 12px;
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
.customItemCard__body {
|
||||
@@ -800,10 +897,22 @@ function fmt(ts) {
|
||||
font-size: 13px;
|
||||
word-break: break-word;
|
||||
}
|
||||
.pager {
|
||||
margin-top: 16px;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.pager__info {
|
||||
opacity: 0.82;
|
||||
font-size: 14px;
|
||||
}
|
||||
.userList {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.userCard {
|
||||
@@ -831,6 +940,11 @@ function fmt(ts) {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.passwordBox {
|
||||
margin-top: 12px;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.roleBadge {
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
@@ -850,9 +964,8 @@ function fmt(ts) {
|
||||
opacity: 0.88;
|
||||
}
|
||||
@media (max-width: 980px) {
|
||||
.section--topGrid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.section--topGrid,
|
||||
.toolbar,
|
||||
.itemComposer {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@@ -861,16 +974,10 @@ function fmt(ts) {
|
||||
}
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.selectedThumb {
|
||||
width: min(100%, 256px);
|
||||
}
|
||||
.thumbGrid,
|
||||
.customItemGrid,
|
||||
.userList {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.itemPreviewCard {
|
||||
max-width: 192px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, onMounted, ref } from 'vue'
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import Sortable from 'sortablejs'
|
||||
import * as htmlToImage from 'html-to-image'
|
||||
@@ -38,12 +38,18 @@ const groupListEl = ref(null)
|
||||
const poolEl = ref(null)
|
||||
const groupDropEls = ref({})
|
||||
const fileEl = ref(null)
|
||||
const groupSortable = ref(null)
|
||||
const poolSortable = ref(null)
|
||||
const dropSortables = ref([])
|
||||
|
||||
const isNewTierList = computed(() => tierListId.value === 'new')
|
||||
const canEdit = computed(() => !!auth.user && (!ownerId.value || ownerId.value === auth.user.id))
|
||||
|
||||
function setGroupDropEl(groupId, el) {
|
||||
if (!el) return
|
||||
if (!el) {
|
||||
delete groupDropEls.value[groupId]
|
||||
return
|
||||
}
|
||||
groupDropEls.value[groupId] = el
|
||||
}
|
||||
|
||||
@@ -75,7 +81,9 @@ function resolveItemSrc(item) {
|
||||
async function initSortables() {
|
||||
if (!poolEl.value || !groupListEl.value) return
|
||||
|
||||
Sortable.create(groupListEl.value, {
|
||||
destroySortables()
|
||||
|
||||
groupSortable.value = Sortable.create(groupListEl.value, {
|
||||
animation: 160,
|
||||
handle: '[data-group-handle]',
|
||||
ghostClass: 'ghost',
|
||||
@@ -88,7 +96,7 @@ async function initSortables() {
|
||||
},
|
||||
})
|
||||
|
||||
Sortable.create(poolEl.value, {
|
||||
poolSortable.value = Sortable.create(poolEl.value, {
|
||||
group: 'tier-items',
|
||||
animation: 160,
|
||||
draggable: '[data-item-id]',
|
||||
@@ -98,7 +106,7 @@ async function initSortables() {
|
||||
onAdd: () => normalizeSort(poolEl.value),
|
||||
})
|
||||
|
||||
Object.entries(groupDropEls.value).forEach(([gid, el]) => {
|
||||
dropSortables.value = Object.entries(groupDropEls.value).map(([gid, el]) =>
|
||||
Sortable.create(el, {
|
||||
group: 'tier-items',
|
||||
animation: 160,
|
||||
@@ -108,7 +116,56 @@ async function initSortables() {
|
||||
onSort: () => normalizeSort(el),
|
||||
onAdd: () => normalizeSort(el),
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function destroySortables() {
|
||||
if (groupSortable.value) {
|
||||
groupSortable.value.destroy()
|
||||
groupSortable.value = null
|
||||
}
|
||||
if (poolSortable.value) {
|
||||
poolSortable.value.destroy()
|
||||
poolSortable.value = null
|
||||
}
|
||||
dropSortables.value.forEach((instance) => instance.destroy())
|
||||
dropSortables.value = []
|
||||
}
|
||||
|
||||
async function syncSortables() {
|
||||
await nextTick()
|
||||
if (canEdit.value) {
|
||||
await initSortables()
|
||||
}
|
||||
}
|
||||
|
||||
function createGroupName() {
|
||||
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
const index = groups.value.length
|
||||
if (index < alphabet.length) return alphabet[index]
|
||||
return `Tier ${index + 1}`
|
||||
}
|
||||
|
||||
async function addGroup() {
|
||||
groups.value = [
|
||||
...groups.value,
|
||||
{
|
||||
id: `g-${Date.now()}-${Math.random().toString(16).slice(2, 8)}`,
|
||||
name: createGroupName(),
|
||||
itemIds: [],
|
||||
},
|
||||
]
|
||||
await syncSortables()
|
||||
}
|
||||
|
||||
async function removeGroup(groupId) {
|
||||
if (groups.value.length <= 1) return
|
||||
const target = groups.value.find((group) => group.id === groupId)
|
||||
if (!target) return
|
||||
pool.value = [...target.itemIds, ...pool.value]
|
||||
groups.value = groups.value.filter((group) => group.id !== groupId)
|
||||
delete groupDropEls.value[groupId]
|
||||
await syncSortables()
|
||||
}
|
||||
|
||||
function addCustomImage(file) {
|
||||
@@ -278,6 +335,10 @@ onMounted(() => {
|
||||
}
|
||||
})()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
destroySortables()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -314,11 +375,15 @@ onMounted(() => {
|
||||
|
||||
<section class="layout">
|
||||
<div ref="boardEl" class="board">
|
||||
<div v-if="canEdit" class="boardTools">
|
||||
<button class="btn btn--ghost" @click="addGroup">티어 추가</button>
|
||||
</div>
|
||||
<div ref="groupListEl" class="rows">
|
||||
<div v-for="g in groups" :key="g.id" class="row">
|
||||
<div class="row__label">
|
||||
<span class="grab" title="드래그로 순서 변경" data-group-handle>↕</span>
|
||||
<input v-model="g.name" class="groupName" :readonly="!canEdit" />
|
||||
<button v-if="canEdit" class="rowRemoveBtn" :disabled="groups.length <= 1" @click="removeGroup(g.id)">삭제</button>
|
||||
</div>
|
||||
<div
|
||||
class="row__drop"
|
||||
@@ -471,6 +536,11 @@ onMounted(() => {
|
||||
border-radius: 16px;
|
||||
padding: 12px;
|
||||
}
|
||||
.boardTools {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.rows {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
@@ -517,6 +587,20 @@ onMounted(() => {
|
||||
outline: none;
|
||||
min-width: 0;
|
||||
}
|
||||
.rowRemoveBtn {
|
||||
padding: 6px 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(239, 68, 68, 0.28);
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
color: rgba(255, 255, 255, 0.92);
|
||||
cursor: pointer;
|
||||
font-weight: 800;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.rowRemoveBtn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.row__drop {
|
||||
border-radius: 14px;
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
|
||||
Reference in New Issue
Block a user