Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fe6b90d08 | |||
| 3b314381a0 |
@@ -85,6 +85,30 @@ function mapTierListRow(row) {
|
||||
}
|
||||
}
|
||||
|
||||
function mapTemplateRequestRow(row) {
|
||||
if (!row) return null
|
||||
return {
|
||||
id: row.id,
|
||||
type: row.request_type,
|
||||
requesterId: row.requester_id,
|
||||
requesterName: getUserDisplayName(row),
|
||||
requesterAccountName: getUserAccountName(row),
|
||||
requesterAvatarSrc: row.requester_avatar_src || '',
|
||||
sourceTierListId: row.source_tierlist_id,
|
||||
sourceGameId: row.source_game_id,
|
||||
sourceGameName: row.source_game_name || '',
|
||||
sourceTierListTitle: row.title_snapshot || '',
|
||||
sourceDescription: row.description_snapshot || '',
|
||||
thumbnailSrc: row.thumbnail_src_snapshot || '',
|
||||
targetGameId: row.target_game_id || '',
|
||||
targetGameName: row.target_game_name || '',
|
||||
status: row.status,
|
||||
items: parseJson(row.items_json, []),
|
||||
createdAt: Number(row.created_at),
|
||||
updatedAt: Number(row.updated_at),
|
||||
}
|
||||
}
|
||||
|
||||
function getUserDisplayName(row) {
|
||||
if (!row) return ''
|
||||
const nickname = (row.nickname || '').trim()
|
||||
@@ -226,6 +250,29 @@ async function ensureSchema() {
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
`)
|
||||
|
||||
await query(`
|
||||
CREATE TABLE IF NOT EXISTS template_requests (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
request_type VARCHAR(20) NOT NULL,
|
||||
requester_id VARCHAR(64) NOT NULL,
|
||||
source_tierlist_id VARCHAR(64) NOT NULL,
|
||||
source_game_id VARCHAR(120) NOT NULL,
|
||||
target_game_id VARCHAR(120) NOT NULL DEFAULT '',
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'pending',
|
||||
title_snapshot VARCHAR(120) NOT NULL,
|
||||
description_snapshot TEXT NOT NULL,
|
||||
thumbnail_src_snapshot VARCHAR(255) NOT NULL DEFAULT '',
|
||||
items_json LONGTEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL,
|
||||
INDEX idx_template_requests_status_created (status, created_at),
|
||||
INDEX idx_template_requests_source_tierlist (source_tierlist_id),
|
||||
INDEX idx_template_requests_requester (requester_id),
|
||||
CONSTRAINT fk_template_requests_requester FOREIGN KEY (requester_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_template_requests_source_tierlist FOREIGN KEY (source_tierlist_id) REFERENCES tierlists(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
|
||||
`)
|
||||
|
||||
const tierListThumbnailColumns = await query("SHOW COLUMNS FROM tierlists LIKE 'thumbnail_src'")
|
||||
if (!tierListThumbnailColumns.length) {
|
||||
await query("ALTER TABLE tierlists ADD COLUMN thumbnail_src VARCHAR(255) NOT NULL DEFAULT '' AFTER title")
|
||||
@@ -502,6 +549,24 @@ async function createCustomItem({ id, ownerId, src, label }) {
|
||||
return { id, ownerId, src, label, origin: 'custom', createdAt }
|
||||
}
|
||||
|
||||
async function syncOwnedCustomItemLabels({ ownerId, items }) {
|
||||
const customItems = Array.from(
|
||||
new Map(
|
||||
(items || [])
|
||||
.filter((item) => item?.origin === 'custom' && item?.id && typeof item.label === 'string')
|
||||
.map((item) => [item.id, item])
|
||||
).values()
|
||||
)
|
||||
|
||||
if (!customItems.length) return
|
||||
|
||||
await Promise.all(
|
||||
customItems.map((item) =>
|
||||
query('UPDATE custom_items SET label = ? WHERE id = ? AND owner_id = ?', [item.label.trim().slice(0, 60), item.id, ownerId])
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
async function findCustomItemById(id) {
|
||||
const rows = await query(
|
||||
`
|
||||
@@ -959,6 +1024,151 @@ async function findTierListById(id, currentUserId = '') {
|
||||
return applyFavoriteMetaToTierLists([tierList], favoriteStats)[0]
|
||||
}
|
||||
|
||||
async function findPendingTemplateRequestByTierList({ sourceTierListId, type }) {
|
||||
const rows = await query(
|
||||
`
|
||||
SELECT id, request_type, status
|
||||
FROM template_requests
|
||||
WHERE source_tierlist_id = ? AND request_type = ? AND status = 'pending'
|
||||
LIMIT 1
|
||||
`,
|
||||
[sourceTierListId, type]
|
||||
)
|
||||
return rows[0] || null
|
||||
}
|
||||
|
||||
async function createTemplateRequest({
|
||||
id,
|
||||
type,
|
||||
requesterId,
|
||||
sourceTierListId,
|
||||
sourceGameId,
|
||||
targetGameId = '',
|
||||
title,
|
||||
description = '',
|
||||
thumbnailSrc = '',
|
||||
items = [],
|
||||
}) {
|
||||
const existing = await findPendingTemplateRequestByTierList({ sourceTierListId, type })
|
||||
if (existing) {
|
||||
const err = new Error('template_request_exists')
|
||||
err.code = 'TEMPLATE_REQUEST_EXISTS'
|
||||
throw err
|
||||
}
|
||||
|
||||
const createdAt = now()
|
||||
await query(
|
||||
`
|
||||
INSERT INTO template_requests (
|
||||
id,
|
||||
request_type,
|
||||
requester_id,
|
||||
source_tierlist_id,
|
||||
source_game_id,
|
||||
target_game_id,
|
||||
status,
|
||||
title_snapshot,
|
||||
description_snapshot,
|
||||
thumbnail_src_snapshot,
|
||||
items_json,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, 'pending', ?, ?, ?, ?, ?, ?)
|
||||
`,
|
||||
[
|
||||
id,
|
||||
type,
|
||||
requesterId,
|
||||
sourceTierListId,
|
||||
sourceGameId,
|
||||
targetGameId,
|
||||
title,
|
||||
description,
|
||||
thumbnailSrc,
|
||||
serializeJson(items),
|
||||
createdAt,
|
||||
createdAt,
|
||||
]
|
||||
)
|
||||
return findTemplateRequestById(id)
|
||||
}
|
||||
|
||||
async function findTemplateRequestById(id) {
|
||||
const rows = await query(
|
||||
`
|
||||
SELECT
|
||||
tr.id,
|
||||
tr.request_type,
|
||||
tr.requester_id,
|
||||
tr.source_tierlist_id,
|
||||
tr.source_game_id,
|
||||
tr.target_game_id,
|
||||
tr.status,
|
||||
tr.title_snapshot,
|
||||
tr.description_snapshot,
|
||||
tr.thumbnail_src_snapshot,
|
||||
tr.items_json,
|
||||
tr.created_at,
|
||||
tr.updated_at,
|
||||
u.nickname,
|
||||
u.email,
|
||||
u.avatar_src AS requester_avatar_src,
|
||||
sg.name AS source_game_name,
|
||||
tg.name AS target_game_name
|
||||
FROM template_requests tr
|
||||
INNER JOIN users u ON u.id = tr.requester_id
|
||||
LEFT JOIN games sg ON sg.id = tr.source_game_id
|
||||
LEFT JOIN games tg ON tg.id = tr.target_game_id
|
||||
WHERE tr.id = ?
|
||||
LIMIT 1
|
||||
`,
|
||||
[id]
|
||||
)
|
||||
|
||||
return mapTemplateRequestRow(rows[0])
|
||||
}
|
||||
|
||||
async function listAdminTemplateRequests({ status = 'pending' } = {}) {
|
||||
const rows = await query(
|
||||
`
|
||||
SELECT
|
||||
tr.id,
|
||||
tr.request_type,
|
||||
tr.requester_id,
|
||||
tr.source_tierlist_id,
|
||||
tr.source_game_id,
|
||||
tr.target_game_id,
|
||||
tr.status,
|
||||
tr.title_snapshot,
|
||||
tr.description_snapshot,
|
||||
tr.thumbnail_src_snapshot,
|
||||
tr.items_json,
|
||||
tr.created_at,
|
||||
tr.updated_at,
|
||||
u.nickname,
|
||||
u.email,
|
||||
u.avatar_src AS requester_avatar_src,
|
||||
sg.name AS source_game_name,
|
||||
tg.name AS target_game_name
|
||||
FROM template_requests tr
|
||||
INNER JOIN users u ON u.id = tr.requester_id
|
||||
LEFT JOIN games sg ON sg.id = tr.source_game_id
|
||||
LEFT JOIN games tg ON tg.id = tr.target_game_id
|
||||
WHERE tr.status = ?
|
||||
ORDER BY tr.created_at DESC
|
||||
`,
|
||||
[status]
|
||||
)
|
||||
|
||||
return rows.map(mapTemplateRequestRow)
|
||||
}
|
||||
|
||||
async function updateTemplateRequestStatus({ id, status }) {
|
||||
await query('UPDATE template_requests SET status = ?, updated_at = ? WHERE id = ?', [status, now(), id])
|
||||
return findTemplateRequestById(id)
|
||||
}
|
||||
|
||||
async function deleteTierList(id) {
|
||||
await query('DELETE FROM tierlists WHERE id = ?', [id])
|
||||
}
|
||||
@@ -992,6 +1202,7 @@ async function deleteCustomItems(ids) {
|
||||
|
||||
async function saveTierList({ id, authorId, gameId, title, thumbnailSrc = '', description, isPublic, groups, pool }) {
|
||||
const existing = id ? await findTierListById(id, authorId) : null
|
||||
await syncOwnedCustomItemLabels({ ownerId: authorId, items: pool })
|
||||
|
||||
if (existing) {
|
||||
await query(
|
||||
@@ -1064,4 +1275,8 @@ module.exports = {
|
||||
findCustomItemsByIds,
|
||||
deleteCustomItems,
|
||||
saveTierList,
|
||||
createTemplateRequest,
|
||||
findTemplateRequestById,
|
||||
listAdminTemplateRequests,
|
||||
updateTemplateRequestStatus,
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ const {
|
||||
listUsers,
|
||||
listAdminTierLists,
|
||||
findTierListById,
|
||||
listAdminTemplateRequests,
|
||||
findTemplateRequestById,
|
||||
updateTemplateRequestStatus,
|
||||
adminUpdateUser,
|
||||
adminUpdateUserPassword,
|
||||
adminDeleteUser,
|
||||
@@ -181,6 +184,11 @@ router.get('/tierlists', requireAdmin, async (req, res) => {
|
||||
res.json(result)
|
||||
})
|
||||
|
||||
router.get('/template-requests', requireAdmin, async (req, res) => {
|
||||
const requests = await listAdminTemplateRequests({ status: 'pending' })
|
||||
res.json({ requests })
|
||||
})
|
||||
|
||||
async function removeCustomItemFiles(items) {
|
||||
await Promise.all(
|
||||
items.map(async (item) => {
|
||||
@@ -255,6 +263,24 @@ async function promoteTierListItemsToGame({ tierList, gameId, itemIds = [] }) {
|
||||
return createdItems
|
||||
}
|
||||
|
||||
async function promoteSnapshotItemsToGame({ items, gameId }) {
|
||||
const createdItems = []
|
||||
|
||||
for (const item of items || []) {
|
||||
const copiedSrc = await copyUploadIntoGameAsset(item.src)
|
||||
createdItems.push(
|
||||
await createGameItem({
|
||||
id: nanoid(),
|
||||
gameId,
|
||||
src: copiedSrc,
|
||||
label: item.label,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return createdItems
|
||||
}
|
||||
|
||||
async function createGameTemplateFromTierList({ tierList, gameId, gameName }) {
|
||||
await createGame({ id: gameId, name: gameName })
|
||||
if (tierList.thumbnailSrc) {
|
||||
@@ -278,6 +304,22 @@ async function createGameTemplateFromTierList({ tierList, gameId, gameName }) {
|
||||
return { game: await findGameById(gameId), items: createdItems }
|
||||
}
|
||||
|
||||
async function createGameTemplateFromRequest({ templateRequest, gameId, gameName }) {
|
||||
await createGame({ id: gameId, name: gameName })
|
||||
|
||||
if (templateRequest.thumbnailSrc) {
|
||||
const copiedThumb = await copyUploadIntoGameAsset(templateRequest.thumbnailSrc)
|
||||
await updateGameThumbnail(gameId, copiedThumb)
|
||||
}
|
||||
|
||||
const items = await promoteSnapshotItemsToGame({
|
||||
items: templateRequest.items || [],
|
||||
gameId,
|
||||
})
|
||||
|
||||
return { game: await findGameById(gameId), items }
|
||||
}
|
||||
|
||||
router.delete('/custom-items/:itemId', requireAdmin, async (req, res) => {
|
||||
const result = await listCustomItems({ page: 1, limit: 200, orphanOnly: false })
|
||||
const target = result.items.find((item) => item.id === req.params.itemId)
|
||||
@@ -355,6 +397,52 @@ router.post('/tierlists/:tierListId/create-game-template', requireAdmin, async (
|
||||
res.json(result)
|
||||
})
|
||||
|
||||
router.post('/template-requests/:requestId/approve', requireAdmin, async (req, res) => {
|
||||
const templateRequest = await findTemplateRequestById(req.params.requestId)
|
||||
if (!templateRequest) return res.status(404).json({ error: 'not_found' })
|
||||
if (templateRequest.status !== 'pending') return res.status(409).json({ error: 'request_already_handled' })
|
||||
|
||||
if (templateRequest.type === 'update') {
|
||||
const targetGameId = templateRequest.targetGameId || templateRequest.sourceGameId
|
||||
const game = await findGameById(targetGameId)
|
||||
if (!game) return res.status(404).json({ error: 'game_not_found' })
|
||||
|
||||
const items = await promoteSnapshotItemsToGame({
|
||||
items: templateRequest.items || [],
|
||||
gameId: game.id,
|
||||
})
|
||||
const request = await updateTemplateRequestStatus({ id: templateRequest.id, status: 'approved' })
|
||||
return res.json({ request, items })
|
||||
}
|
||||
|
||||
const schema = z.object({
|
||||
gameId: z.string().trim().min(1).max(120),
|
||||
name: z.string().trim().min(1).max(120),
|
||||
})
|
||||
const parsed = schema.safeParse(req.body)
|
||||
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
|
||||
|
||||
const exists = await findGameById(parsed.data.gameId)
|
||||
if (exists) return res.status(409).json({ error: 'game_id_taken' })
|
||||
|
||||
const result = await createGameTemplateFromRequest({
|
||||
templateRequest,
|
||||
gameId: parsed.data.gameId,
|
||||
gameName: parsed.data.name,
|
||||
})
|
||||
const request = await updateTemplateRequestStatus({ id: templateRequest.id, status: 'approved' })
|
||||
res.json({ request, ...result })
|
||||
})
|
||||
|
||||
router.post('/template-requests/:requestId/reject', requireAdmin, async (req, res) => {
|
||||
const templateRequest = await findTemplateRequestById(req.params.requestId)
|
||||
if (!templateRequest) return res.status(404).json({ error: 'not_found' })
|
||||
if (templateRequest.status !== 'pending') return res.status(409).json({ error: 'request_already_handled' })
|
||||
|
||||
const request = await updateTemplateRequestStatus({ id: templateRequest.id, status: 'rejected' })
|
||||
res.json({ request })
|
||||
})
|
||||
|
||||
router.delete('/custom-items', requireAdmin, async (req, res) => {
|
||||
const schema = z.object({
|
||||
q: z.string().trim().max(120).optional().default(''),
|
||||
|
||||
@@ -11,6 +11,7 @@ const {
|
||||
deleteTierList,
|
||||
saveTierList,
|
||||
createCustomItem,
|
||||
createTemplateRequest,
|
||||
findUserById,
|
||||
favoriteTierList,
|
||||
unfavoriteTierList,
|
||||
@@ -18,6 +19,8 @@ const {
|
||||
const { requireAuth } = require('../middleware/auth')
|
||||
|
||||
const router = express.Router()
|
||||
const FREEFORM_GAME_ID = 'freeform'
|
||||
const FREEFORM_DEFAULT_TITLE = '직접 티어표 만들기'
|
||||
|
||||
function normalizePoolItem(item) {
|
||||
if (!item || item.origin !== 'game' || typeof item.src !== 'string') return item
|
||||
@@ -42,6 +45,19 @@ function normalizeTierList(tierList) {
|
||||
}
|
||||
}
|
||||
|
||||
function isTierListBoardEmpty(tierList) {
|
||||
return !(tierList?.groups || []).some((group) => Array.isArray(group?.itemIds) && group.itemIds.length > 0)
|
||||
}
|
||||
|
||||
function getCustomTemplateItems(tierList) {
|
||||
const seen = new Set()
|
||||
return (tierList?.pool || []).filter((item) => {
|
||||
if (!item?.id || item.origin !== 'custom' || seen.has(item.id)) return false
|
||||
seen.add(item.id)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
function buildUploadFilename(file) {
|
||||
const ext = path.extname(file.originalname || '').toLowerCase()
|
||||
const safeExt = ext && /^[.a-z0-9]+$/.test(ext) ? ext : ''
|
||||
@@ -168,6 +184,52 @@ router.post('/thumbnail', requireAuth, thumbnailUpload.single('thumbnail'), asyn
|
||||
res.json({ thumbnailSrc: `/uploads/tierlists/${req.file.filename}` })
|
||||
})
|
||||
|
||||
router.post('/:id/template-request', requireAuth, async (req, res) => {
|
||||
const schema = z.object({
|
||||
type: z.enum(['create', 'update']),
|
||||
})
|
||||
const parsed = schema.safeParse(req.body)
|
||||
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
|
||||
|
||||
const tierList = await findTierListById(req.params.id, req.session.userId)
|
||||
if (!tierList) return res.status(404).json({ error: 'not_found' })
|
||||
if (tierList.authorId !== req.session.userId) return res.status(403).json({ error: 'forbidden' })
|
||||
|
||||
const customItems = getCustomTemplateItems(tierList)
|
||||
if (!customItems.length) return res.status(400).json({ error: 'custom_items_required' })
|
||||
|
||||
if (parsed.data.type === 'create') {
|
||||
if (tierList.gameId !== FREEFORM_GAME_ID) return res.status(400).json({ error: 'freeform_required' })
|
||||
if (!isTierListBoardEmpty(tierList)) return res.status(400).json({ error: 'board_must_be_empty' })
|
||||
if (!(tierList.title || '').trim() || (tierList.title || '').trim() === FREEFORM_DEFAULT_TITLE) {
|
||||
return res.status(400).json({ error: 'title_required' })
|
||||
}
|
||||
} else {
|
||||
if (tierList.gameId === FREEFORM_GAME_ID) return res.status(400).json({ error: 'game_template_required' })
|
||||
}
|
||||
|
||||
try {
|
||||
const request = await createTemplateRequest({
|
||||
id: nanoid(),
|
||||
type: parsed.data.type,
|
||||
requesterId: req.session.userId,
|
||||
sourceTierListId: tierList.id,
|
||||
sourceGameId: tierList.gameId,
|
||||
targetGameId: parsed.data.type === 'update' ? tierList.gameId : '',
|
||||
title: tierList.title,
|
||||
description: tierList.description || '',
|
||||
thumbnailSrc: tierList.thumbnailSrc || '',
|
||||
items: customItems,
|
||||
})
|
||||
return res.json({ request })
|
||||
} catch (e) {
|
||||
if (e?.code === 'TEMPLATE_REQUEST_EXISTS') {
|
||||
return res.status(409).json({ error: 'template_request_exists' })
|
||||
}
|
||||
throw e
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/', requireAuth, async (req, res) => {
|
||||
const parsed = tierListUpsertSchema.safeParse(req.body)
|
||||
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# 의사결정 이력
|
||||
|
||||
## 2026-03-27 v0.1.48
|
||||
- 템플릿 등록 요청은 실패 원인이 불명확하면 혼란이 크므로, 요청 전에 체크리스트 모달로 조건을 먼저 확인시키고 조건이 맞을 때만 전송하게 하는 편이 낫다고 정리했다.
|
||||
- freeform 템플릿 등록 요청은 제목이 곧 게임 이름 후보가 되므로, 기본값이 아닌 사용자가 직접 입력한 제목을 요구하기로 했다.
|
||||
- 관리자 입장에서는 처리하지 않을 요청을 대기 목록에서 바로 치울 수 있어야 하므로, 반려는 단순 상태 변경이 아니라 “대기 목록에서 숨김”으로 인지되게 문구를 맞추기로 했다.
|
||||
|
||||
## 2026-03-27 v0.1.47
|
||||
- 새 게임 템플릿 등록과 기존 템플릿 업데이트는 운영자가 직접 일일이 훑기보다, 사용자가 명시적으로 요청을 보내고 관리자가 승인하는 흐름이 더 빠르고 명확하다고 정리했다.
|
||||
- 템플릿 요청에 포함되는 커스텀 아이템 이름은 관리자 판단의 핵심 정보이므로, 티어표 편집 화면 안에서도 직접 이름을 정리하고 저장 시 원본 커스텀 아이템 라벨까지 함께 동기화하기로 결정했다.
|
||||
- 새 템플릿 등록 요청은 실제 템플릿처럼 비어 있는 상태가 더 활용도가 높으므로, `freeform + 빈 보드 + 커스텀 아이템 존재` 조건에서만 보낼 수 있게 제한하기로 했다.
|
||||
|
||||
## 2026-03-27 v0.1.46
|
||||
- 티어표 편집 중 등급 행에 넣은 아이템도 다시 제외할 수 있어야 배치 실험이 쉬우므로, 별도 제거 버튼으로 아이템 풀로 되돌리는 흐름을 제공하기로 결정했다.
|
||||
- 관리자 회원 관리는 수정 기능만으로는 부족하므로, 운영 판단에 바로 필요한 아바타, 작성 티어표 수, 최근 활동 시각을 함께 보여주기로 했다.
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
## `/admin`
|
||||
- 화면 파일: `frontend/src/views/AdminView.vue`
|
||||
- 역할: `게임 관리 / 아이템 관리 / 티어표 관리 / 회원 관리` 탭 분리, 선택된 게임의 썸네일 관리, 기본 아이템 다중 드래그 앤 드롭 업로드, 기본 아이템 이름 수정, 사용자 커스텀 아이템 검색/페이지네이션/사용 횟수 확인/미사용 이미지 개별·일괄 삭제, 사용자 커스텀 아이템의 기본 템플릿 승격, 전체 티어표 검색/페이지네이션/공개 여부 확인/완성본 이동, 티어표의 추가 커스텀 아이템을 모달 기반으로 기존 템플릿 또는 새 템플릿에 가져오기, freeform 티어표의 게임 템플릿화, 회원 비밀번호 초기화 포함 회원 관리, 파일 입력 초기화, 아이템 삭제, 게임 삭제
|
||||
- 연동 API: `POST /api/admin/games`, `POST /api/admin/games/:gameId/thumbnail`, `POST /api/admin/games/:gameId/images`, `PATCH /api/admin/games/:gameId/items/:itemId`, `GET /api/admin/custom-items`, `POST /api/admin/custom-items/:itemId/promote`, `DELETE /api/admin/custom-items/:itemId`, `DELETE /api/admin/custom-items`, `GET /api/admin/tierlists`, `POST /api/admin/tierlists/:tierListId/promote-items`, `POST /api/admin/tierlists/:tierListId/create-game-template`, `GET /api/admin/users`, `PATCH /api/admin/users/:userId`, `PATCH /api/admin/users/:userId/password`, `DELETE /api/admin/users/:userId`, `DELETE /api/admin/games/:gameId/items/:itemId`, `DELETE /api/admin/games/:gameId`
|
||||
- 역할: `게임 관리 / 아이템 관리 / 티어표 관리 / 회원 관리` 탭 분리, 선택된 게임의 썸네일 관리, 기본 아이템 다중 드래그 앤 드롭 업로드, 기본 아이템 이름 수정, 사용자 커스텀 아이템 검색/페이지네이션/사용 횟수 확인/미사용 이미지 개별·일괄 삭제, 사용자 커스텀 아이템의 기본 템플릿 승격, 전체 티어표 검색/페이지네이션/공개 여부 확인/완성본 이동, 티어표의 추가 커스텀 아이템을 모달 기반으로 기존 템플릿 또는 새 템플릿에 가져오기, freeform 티어표의 게임 템플릿화, 사용자 템플릿 등록/업데이트 요청 승인·반려, 회원 비밀번호 초기화 포함 회원 관리, 파일 입력 초기화, 아이템 삭제, 게임 삭제
|
||||
- 연동 API: `POST /api/admin/games`, `POST /api/admin/games/:gameId/thumbnail`, `POST /api/admin/games/:gameId/images`, `PATCH /api/admin/games/:gameId/items/:itemId`, `GET /api/admin/custom-items`, `POST /api/admin/custom-items/:itemId/promote`, `DELETE /api/admin/custom-items/:itemId`, `DELETE /api/admin/custom-items`, `GET /api/admin/tierlists`, `GET /api/admin/template-requests`, `POST /api/admin/template-requests/:requestId/approve`, `POST /api/admin/template-requests/:requestId/reject`, `POST /api/admin/tierlists/:tierListId/promote-items`, `POST /api/admin/tierlists/:tierListId/create-game-template`, `GET /api/admin/users`, `PATCH /api/admin/users/:userId`, `PATCH /api/admin/users/:userId/password`, `DELETE /api/admin/users/:userId`, `DELETE /api/admin/games/:gameId/items/:itemId`, `DELETE /api/admin/games/:gameId`
|
||||
|
||||
## `/profile`
|
||||
- 화면 파일: `frontend/src/views/ProfileView.vue`
|
||||
|
||||
10
docs/spec.md
10
docs/spec.md
@@ -83,6 +83,7 @@
|
||||
- `GET /api/tierlists/me`
|
||||
- `GET /api/tierlists/favorites/me`
|
||||
- `GET /api/tierlists/:id`
|
||||
- `POST /api/tierlists/:id/template-request`
|
||||
- `POST /api/tierlists/:id/favorite`
|
||||
- `DELETE /api/tierlists/:id/favorite`
|
||||
- `DELETE /api/tierlists/:id`
|
||||
@@ -96,6 +97,9 @@
|
||||
- 여러 이미지를 한 번에 업로드할 수 있고, 별도 라벨이 없으면 파일명 기준으로 기본 아이템 이름을 만든다.
|
||||
- `PATCH /api/admin/games/:gameId/items/:itemId`
|
||||
- `GET /api/admin/tierlists`
|
||||
- `GET /api/admin/template-requests`
|
||||
- `POST /api/admin/template-requests/:requestId/approve`
|
||||
- `POST /api/admin/template-requests/:requestId/reject`
|
||||
- `POST /api/admin/tierlists/:tierListId/promote-items`
|
||||
- `POST /api/admin/tierlists/:tierListId/create-game-template`
|
||||
- `GET /api/admin/custom-items`
|
||||
@@ -124,6 +128,8 @@
|
||||
- `티어표 관리` 탭의 추가 아이템은 작은 그리드 카드로 표시하고, 클릭 시 `기존 템플릿에 추가 / 새 템플릿 만들기` 모달을 통해 목적지를 선택한다.
|
||||
- `티어표 관리` 탭에서는 티어표 안의 커스텀 아이템을 개별 또는 일괄로 기존 게임 템플릿에 복제할 수 있다.
|
||||
- `freeform` 티어표는 관리자 화면에서 새 게임 ID/이름을 입력해 새로운 게임 템플릿으로 복제 생성할 수 있다.
|
||||
- 관리자 티어표 관리 상단에는 사용자가 보낸 템플릿 등록/업데이트 요청 목록이 별도로 표시되며, 여기서 승인/반려를 바로 처리할 수 있다.
|
||||
- 관리자 템플릿 요청 목록에서 `반려 후 숨김`을 누르면 해당 요청은 pending 목록에서 즉시 제외된다.
|
||||
- 관리자 화면에서는 회원 이메일/닉네임/권한 수정, 비밀번호 초기화, 계정 삭제가 가능하다.
|
||||
- 회원 관리 카드에는 아바타, 작성 티어표 수, 최근 활동 시각을 함께 표시한다.
|
||||
|
||||
@@ -136,11 +142,15 @@
|
||||
- 공개 티어표 목록은 현재 게임 기준으로 제목/작성자 검색을 지원한다.
|
||||
- `내 즐겨찾기` 화면에서는 즐겨찾기한 순, 최신 업데이트순, 인기순 정렬을 제공한다.
|
||||
- 커스텀 이미지 추가는 다중 파일 선택과 드래그 앤 드롭을 모두 지원한다.
|
||||
- 사용자가 직접 추가한 커스텀 아이템 이름은 편집 화면 우측 목록에서 정리할 수 있고, 저장 시 원본 커스텀 아이템 라벨과 함께 동기화된다.
|
||||
- 티어 행은 기본 5단으로 시작하지만, 사용자가 직접 추가하거나 제거할 수 있다.
|
||||
- 티어 행에 넣은 아이템은 작은 제거 버튼으로 다시 우측 아이템 풀로 되돌릴 수 있다.
|
||||
- 신규 티어표의 공개 여부 기본값은 `ON`이며, 기존 티어표는 편집 화면과 `내 티어표` 목록에서 직접 삭제할 수 있다.
|
||||
- 제목이 비어 있는 상태로 저장하면 내부 제목은 현재 게임명을 기본값으로 사용한다.
|
||||
- 제목 입력이 비어 있는 동안에는 무분별한 도배 방지를 위한 관리자 임의 삭제 가능성 안내 문구를 표시한다.
|
||||
- `freeform` 티어표는 보드가 비어 있고 커스텀 아이템이 준비된 상태에서만 `템플릿 등록 요청`을 보낼 수 있다.
|
||||
- `템플릿 등록 요청` 전에는 체크리스트 모달로 `제목 직접 입력`, `보드 비움 상태`를 확인하고 두 조건이 충족될 때만 전송할 수 있다.
|
||||
- 기존 게임 티어표는 커스텀 아이템이 포함되어 있으면 `템플릿 업데이트 요청`을 보낼 수 있다.
|
||||
- 티어표는 편집 화면에서 16:9 썸네일 이미지를 별도로 선택해 저장할 수 있고, 목록 카드에서는 그 이미지를 상단 대표 썸네일로 사용한다.
|
||||
- 편집 화면 상단 헤더는 좌측 제목/설명, 우측 썸네일 카드 구조를 사용하며 모바일에서는 한 열로 접힌다.
|
||||
- 티어표 편집기의 아이콘 기본 크기는 `80px`이며, 사용자가 `48 / 60 / 80 / 100 / 120` 단계로 즉시 조절할 수 있다.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
- 관리자 기본 아이템 다중 업로드는 현재 파일명 기반 자동 라벨만 지원하므로, 필요하면 업로드 후 일괄 라벨 수정/정렬 UX를 추가 검토한다.
|
||||
- 티어표 썸네일은 현재 업로드/교체만 지원하므로, 필요하면 자동 썸네일 추출이나 업로드 이미지 크롭 UX를 추가 검토한다.
|
||||
- 사용자 커스텀 아이템 승격은 현재 수동 복제 방식이므로, 필요하면 중복 감지나 “비슷한 항목 추천” 같은 보조 UX를 검토한다.
|
||||
- 템플릿 등록/업데이트 요청은 현재 승인/반려만 지원하므로, 필요하면 관리자 코멘트나 사용자용 요청 상태 이력 화면을 추가 검토한다.
|
||||
- 관리자 티어표 관리의 템플릿 생성은 현재 `freeform`만 직접 지원하므로, 필요하면 일반 게임 티어표의 전체 아이템을 복제한 파생 템플릿 생성 UX도 검토한다.
|
||||
- 관리자 티어표 관리의 추가 아이템 승격은 현재 커스텀(origin=`custom`) 아이템 기준이므로, 필요하면 “기존 게임 아이템과 비교한 차집합” 기준으로 더 정교하게 확장할 수 있다.
|
||||
- 즐겨찾기는 현재 `내 즐겨찾기` 목록과 정렬까지 지원하므로, 필요하면 폴더 분류나 메모 같은 개인 정리 기능을 추가 검토한다.
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# 업데이트 로그
|
||||
|
||||
## 2026-03-27 v0.1.48
|
||||
- **템플릿 등록 요청 체크리스트 모달 추가**: freeform 템플릿 등록 요청 전 `제목 직접 입력 여부`, `보드 비움 상태`를 확인하는 모달과 안내 문구를 추가하고, 조건이 맞을 때만 요청 버튼이 활성화되도록 조정
|
||||
- **등록 요청 실패 원인 구체화**: 템플릿 등록 요청 실패 시 제목 미입력, 보드 비우지 않음, 커스텀 아이템 없음, 중복 대기 요청 같은 주요 원인을 토스트로 구체적으로 안내하도록 보강
|
||||
- **관리자 요청 목록 정리 문구 추가**: 관리자 템플릿 요청 탭에서 반려 시 대기 목록에서 바로 제외된다는 안내와 `반려 후 숨김` 버튼 문구를 추가해 운영 관점의 흐름을 더 명확히 정리
|
||||
|
||||
## 2026-03-27 v0.1.47
|
||||
- **템플릿 등록/업데이트 요청 추가**: 사용자가 저장된 티어표를 기준으로 관리자에게 `새 템플릿 등록` 또는 `기존 템플릿 업데이트` 요청을 보낼 수 있도록 요청 API와 관리자 승인 흐름을 추가
|
||||
- **커스텀 아이템 이름 편집 확장**: 티어표 편집 화면에서 사용자가 직접 추가한 커스텀 아이템 이름을 정리할 수 있는 전용 입력 목록을 추가하고, 저장 시 MariaDB의 커스텀 아이템 라벨도 함께 동기화
|
||||
- **관리자 요청 목록 추가**: 관리자 티어표 관리 탭 상단에 처리 대기 중인 템플릿 요청 목록을 추가하고, 새 게임 템플릿 생성 승인과 기존 게임 템플릿 업데이트 승인을 바로 처리할 수 있게 개선
|
||||
|
||||
## 2026-03-27 v0.1.46
|
||||
- **티어 행 아이템 제거 추가**: 티어표 편집 화면에서 이미 등급 행에 넣은 아이템도 작은 제거 버튼으로 다시 아이템 풀로 빼낼 수 있도록 보강
|
||||
- **회원 관리 보조 정보 확장**: 관리자 회원 관리 카드에 아바타, 작성 티어표 수, 최근 활동 시각을 함께 표시해 운영 판단에 필요한 정보를 바로 확인할 수 있도록 개선
|
||||
|
||||
@@ -41,12 +41,16 @@ export const api = {
|
||||
),
|
||||
listAdminTierLists: ({ q = '', page = 1, limit = 50 } = {}) =>
|
||||
request(`/api/admin/tierlists?q=${encodeURIComponent(q)}&page=${encodeURIComponent(page)}&limit=${encodeURIComponent(limit)}`),
|
||||
listAdminTemplateRequests: () => request('/api/admin/template-requests'),
|
||||
promoteAdminCustomItem: (itemId, payload) =>
|
||||
request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/promote`, { method: 'POST', body: payload }),
|
||||
promoteAdminTierListItems: (tierListId, payload) =>
|
||||
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/promote-items`, { method: 'POST', body: payload }),
|
||||
createAdminGameTemplateFromTierList: (tierListId, payload) =>
|
||||
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/create-game-template`, { method: 'POST', body: payload }),
|
||||
approveAdminTemplateRequest: (requestId, payload) =>
|
||||
request(`/api/admin/template-requests/${encodeURIComponent(requestId)}/approve`, { method: 'POST', body: payload || {} }),
|
||||
rejectAdminTemplateRequest: (requestId) => request(`/api/admin/template-requests/${encodeURIComponent(requestId)}/reject`, { method: 'POST', body: {} }),
|
||||
listAdminUsers: () => request('/api/admin/users'),
|
||||
updateAdminUser: (userId, payload) =>
|
||||
request(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'PATCH', body: payload }),
|
||||
@@ -65,6 +69,7 @@ export const api = {
|
||||
favoriteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}/favorite`, { method: 'POST' }),
|
||||
unfavoriteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}/favorite`, { method: 'DELETE' }),
|
||||
deleteTierList: (id) => request(`/api/tierlists/${encodeURIComponent(id)}`, { method: 'DELETE' }),
|
||||
requestTierListTemplate: (id, payload) => request(`/api/tierlists/${encodeURIComponent(id)}/template-request`, { method: 'POST', body: payload }),
|
||||
saveTierList: (payload) => request('/api/tierlists', { method: 'POST', body: payload }),
|
||||
uploadTierListThumbnail: async (file) => {
|
||||
const fd = new FormData()
|
||||
|
||||
@@ -33,6 +33,7 @@ const adminTierListQuery = ref('')
|
||||
const adminTierListPage = ref(1)
|
||||
const adminTierListLimit = ref(50)
|
||||
const adminTierListTotal = ref(0)
|
||||
const templateRequests = ref([])
|
||||
const importModalOpen = ref(false)
|
||||
const importModalMode = ref('existing')
|
||||
const importModalTierList = ref(null)
|
||||
@@ -74,7 +75,7 @@ const importModalItemCount = computed(() => importModalItems.value.length)
|
||||
|
||||
onMounted(async () => {
|
||||
await auth.refresh()
|
||||
await Promise.all([refreshGames(), refreshCustomItems(), refreshAdminTierLists(), refreshUsers()])
|
||||
await Promise.all([refreshGames(), refreshCustomItems(), refreshAdminTierLists(), refreshUsers(), refreshTemplateRequests()])
|
||||
await syncFeaturedSortable()
|
||||
})
|
||||
|
||||
@@ -189,6 +190,30 @@ async function refreshAdminTierLists() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshTemplateRequests() {
|
||||
if (!auth.user?.isAdmin) return
|
||||
try {
|
||||
const data = await api.listAdminTemplateRequests()
|
||||
templateRequests.value = (data.requests || []).map((request) => ({
|
||||
...request,
|
||||
draftGameId:
|
||||
request.type === 'create'
|
||||
? (request.sourceTierListTitle || '')
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
.slice(0, 80) || 'new-template'
|
||||
: request.targetGameId || request.sourceGameId || '',
|
||||
draftGameName:
|
||||
request.type === 'create'
|
||||
? `${request.sourceTierListTitle || request.sourceGameName || '새 템플릿'}`
|
||||
: request.targetGameName || request.sourceGameName || '',
|
||||
}))
|
||||
} catch (e) {
|
||||
error.value = '템플릿 요청 목록을 불러오지 못했어요.'
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshUsers() {
|
||||
if (!auth.user?.isAdmin) return
|
||||
try {
|
||||
@@ -690,6 +715,59 @@ async function confirmTierListImport() {
|
||||
}
|
||||
}
|
||||
|
||||
function templateRequestTypeLabel(request) {
|
||||
return request.type === 'create' ? '템플릿 등록 요청' : '템플릿 업데이트 요청'
|
||||
}
|
||||
|
||||
function templateRequestTargetLabel(request) {
|
||||
return request.type === 'create' ? '새 게임 템플릿 생성' : request.targetGameName || request.targetGameId || request.sourceGameName
|
||||
}
|
||||
|
||||
async function approveTemplateRequest(request) {
|
||||
resetMessages()
|
||||
try {
|
||||
request.isHandling = true
|
||||
if (request.type === 'create') {
|
||||
const nextGameId = (request.draftGameId || '').trim()
|
||||
const nextGameName = (request.draftGameName || '').trim()
|
||||
if (!nextGameId || !nextGameName) {
|
||||
error.value = '새 게임 ID와 이름을 모두 입력해주세요.'
|
||||
return
|
||||
}
|
||||
await api.approveAdminTemplateRequest(request.id, {
|
||||
gameId: nextGameId,
|
||||
name: nextGameName,
|
||||
})
|
||||
await refreshGames()
|
||||
success.value = `"${nextGameName}" 템플릿 생성을 승인했어요.`
|
||||
} else {
|
||||
const data = await api.approveAdminTemplateRequest(request.id)
|
||||
if (selectedGameId.value === (request.targetGameId || request.sourceGameId)) await loadGame()
|
||||
success.value = `${data.items?.length || 0}개의 아이템 추가 요청을 승인했어요.`
|
||||
}
|
||||
await refreshTemplateRequests()
|
||||
await refreshAdminTierLists()
|
||||
} catch (e) {
|
||||
error.value = request.type === 'create' ? '템플릿 등록 요청 승인에 실패했어요.' : '템플릿 업데이트 요청 승인에 실패했어요.'
|
||||
} finally {
|
||||
request.isHandling = false
|
||||
}
|
||||
}
|
||||
|
||||
async function rejectTemplateRequest(request) {
|
||||
resetMessages()
|
||||
try {
|
||||
request.isHandling = true
|
||||
await api.rejectAdminTemplateRequest(request.id)
|
||||
await refreshTemplateRequests()
|
||||
success.value = '요청을 반려했어요.'
|
||||
} catch (e) {
|
||||
error.value = '요청 반려에 실패했어요.'
|
||||
} finally {
|
||||
request.isHandling = false
|
||||
}
|
||||
}
|
||||
|
||||
const displayThumbnailUrl = computed(() => {
|
||||
if (thumbPreviewUrl.value) return thumbPreviewUrl.value
|
||||
if (selectedGame.value?.game?.thumbnailSrc) return toApiUrl(selectedGame.value.game.thumbnailSrc)
|
||||
@@ -1006,6 +1084,53 @@ async function saveFeaturedOrder() {
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'tierlists'">
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
<div class="panel__title">사용자 템플릿 요청</div>
|
||||
<div class="hint hint--tight">freeform 템플릿 등록 요청과 기존 게임 템플릿 업데이트 요청을 여기서 승인하거나 반려할 수 있어요. 반려한 요청은 대기 목록에서 바로 제외됩니다.</div>
|
||||
</div>
|
||||
<button class="btn btn--ghost" @click="refreshTemplateRequests">새로고침</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!templateRequests.length" class="hint">현재 처리 대기 중인 템플릿 요청이 없어요.</div>
|
||||
<div v-else class="templateRequestList">
|
||||
<article v-for="request in templateRequests" :key="request.id" class="templateRequestCard">
|
||||
<div class="templateRequestCard__head">
|
||||
<div>
|
||||
<div class="templateRequestCard__title">{{ request.sourceTierListTitle }}</div>
|
||||
<div class="templateRequestCard__meta">
|
||||
{{ templateRequestTypeLabel(request) }} · {{ request.requesterName }} · {{ fmt(request.createdAt) }}
|
||||
</div>
|
||||
<div class="templateRequestCard__meta">{{ templateRequestTargetLabel(request) }}</div>
|
||||
</div>
|
||||
<button class="btn btn--ghost btn--small" @click="openAdminTierList({ id: request.sourceTierListId, gameId: request.sourceGameId })">
|
||||
원본 보기
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="request.items?.length" class="templateRequestItems">
|
||||
<div v-for="item in request.items" :key="item.id" class="templateRequestItem">
|
||||
<img class="templateRequestItem__thumb" :src="toApiUrl(item.src)" :alt="item.label" />
|
||||
<div class="templateRequestItem__label">{{ item.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="request.type === 'create'" class="templateRequestCard__form">
|
||||
<input v-model="request.draftGameId" class="input" placeholder="새 게임 ID" />
|
||||
<input v-model="request.draftGameName" class="input" placeholder="새 게임 이름" />
|
||||
</div>
|
||||
|
||||
<div class="templateRequestCard__actions">
|
||||
<button class="btn btn--primary" :disabled="request.isHandling" @click="approveTemplateRequest(request)">
|
||||
{{ request.isHandling ? '처리중...' : '승인' }}
|
||||
</button>
|
||||
<button class="btn btn--danger" :disabled="request.isHandling" @click="rejectTemplateRequest(request)">반려 후 숨김</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="sectionHeader">
|
||||
<div>
|
||||
@@ -1785,6 +1910,70 @@ async function saveFeaturedOrder() {
|
||||
.roleBadge--admin {
|
||||
background: rgba(96, 165, 250, 0.18);
|
||||
}
|
||||
.templateRequestList {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
.templateRequestCard {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
border-radius: 18px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
.templateRequestCard__head {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.templateRequestCard__title {
|
||||
font-weight: 900;
|
||||
font-size: 18px;
|
||||
}
|
||||
.templateRequestCard__meta {
|
||||
margin-top: 4px;
|
||||
font-size: 13px;
|
||||
opacity: 0.72;
|
||||
}
|
||||
.templateRequestItems {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.templateRequestItem {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.templateRequestItem__thumb {
|
||||
width: 100%;
|
||||
aspect-ratio: 1 / 1;
|
||||
object-fit: cover;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
.templateRequestItem__label {
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.templateRequestCard__form {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.templateRequestCard__actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tierAdminList {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
@@ -1960,7 +2149,8 @@ async function saveFeaturedOrder() {
|
||||
.toolbar,
|
||||
.itemComposer,
|
||||
.tierAdminCard,
|
||||
.userStats {
|
||||
.userStats,
|
||||
.templateRequestCard__form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.toolbar--secondary {
|
||||
|
||||
@@ -37,6 +37,7 @@ const error = ref('')
|
||||
const isSaving = ref(false)
|
||||
const isExporting = ref(false)
|
||||
const isSaveModalOpen = ref(false)
|
||||
const isTemplateRequestModalOpen = ref(false)
|
||||
const ownerId = ref('')
|
||||
const authorName = ref('')
|
||||
const authorAccountName = ref('')
|
||||
@@ -46,6 +47,7 @@ const iconSize = ref(80)
|
||||
const isFavoriteBusy = ref(false)
|
||||
const favoriteCount = ref(0)
|
||||
const isFavorited = ref(false)
|
||||
const isRequestingTemplate = ref(false)
|
||||
|
||||
const boardEl = ref(null)
|
||||
const exportBoardEl = ref(null)
|
||||
@@ -84,6 +86,31 @@ const untitledWarning = computed(
|
||||
'제목 없이 저장된 티어표는 무분별한 도배 방지를 위해 관리자에 의해 임의 삭제될 수 있어요.'
|
||||
)
|
||||
const canFavorite = computed(() => !!auth.user && !isNewTierList.value && !canEdit.value)
|
||||
const customItems = computed(() =>
|
||||
Object.values(itemsById.value)
|
||||
.filter((item) => item?.origin === 'custom')
|
||||
.sort((a, b) => (a.label || '').localeCompare(b.label || '', 'ko'))
|
||||
)
|
||||
const hasPlacedItems = computed(() => groups.value.some((group) => (group.itemIds || []).length > 0))
|
||||
const canRequestTemplateCreate = computed(
|
||||
() => canEdit.value && !isNewTierList.value && gameId.value === 'freeform' && !hasPlacedItems.value && customItems.value.length > 0
|
||||
)
|
||||
const canRequestTemplateUpdate = computed(
|
||||
() => canEdit.value && !isNewTierList.value && gameId.value !== 'freeform' && customItems.value.length > 0
|
||||
)
|
||||
const templateRequestChecks = computed(() => [
|
||||
{
|
||||
id: 'title',
|
||||
label: '티어표 이름(게임 이름)을 직접 입력했는지',
|
||||
passed: !!(title.value || '').trim() && (title.value || '').trim() !== (gameName.value || '').trim(),
|
||||
},
|
||||
{
|
||||
id: 'empty-board',
|
||||
label: '등록한 이미지를 티어에 배치하지 않은 원본 상태인지',
|
||||
passed: !hasPlacedItems.value,
|
||||
},
|
||||
])
|
||||
const canSubmitTemplateCreateRequest = computed(() => templateRequestChecks.value.every((item) => item.passed))
|
||||
|
||||
watch(error, (message) => {
|
||||
if (!message) return
|
||||
@@ -258,6 +285,18 @@ function addCustomImage(file) {
|
||||
pool.value = [id, ...pool.value]
|
||||
}
|
||||
|
||||
function updateCustomItemLabel(itemId, nextLabel) {
|
||||
const item = itemsById.value[itemId]
|
||||
if (!item || item.origin !== 'custom') return
|
||||
itemsById.value = {
|
||||
...itemsById.value,
|
||||
[itemId]: {
|
||||
...item,
|
||||
label: nextLabel.slice(0, 60),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function openFile() {
|
||||
if (!canEdit.value) return
|
||||
fileEl.value?.click()
|
||||
@@ -399,21 +438,26 @@ function buildPayload(existingId) {
|
||||
}
|
||||
}
|
||||
|
||||
async function persistTierList({ showModal = false } = {}) {
|
||||
await uploadPendingCustomItems()
|
||||
await uploadPendingThumbnail()
|
||||
const payload = buildPayload(tierListId.value && tierListId.value !== 'new' ? tierListId.value : null)
|
||||
const res = await api.saveTierList(payload)
|
||||
if (tierListId.value === 'new') history.replaceState({}, '', `/editor/${gameId.value}/${res.tierList.id}`)
|
||||
updatedAt.value = Number(res.tierList?.updatedAt || Date.now())
|
||||
authorName.value = res.tierList?.authorName || effectiveAuthorName.value
|
||||
authorAccountName.value = res.tierList?.authorAccountName || authorAccountName.value
|
||||
favoriteCount.value = Number(res.tierList?.favoriteCount || favoriteCount.value || 0)
|
||||
isFavorited.value = !!res.tierList?.isFavorited
|
||||
if (showModal) isSaveModalOpen.value = true
|
||||
return res
|
||||
}
|
||||
|
||||
async function save() {
|
||||
error.value = ''
|
||||
isSaving.value = true
|
||||
try {
|
||||
await uploadPendingCustomItems()
|
||||
await uploadPendingThumbnail()
|
||||
const payload = buildPayload(tierListId.value && tierListId.value !== 'new' ? tierListId.value : null)
|
||||
const res = await api.saveTierList(payload)
|
||||
if (tierListId.value === 'new') history.replaceState({}, '', `/editor/${gameId.value}/${res.tierList.id}`)
|
||||
updatedAt.value = Number(res.tierList?.updatedAt || Date.now())
|
||||
authorName.value = res.tierList?.authorName || effectiveAuthorName.value
|
||||
authorAccountName.value = res.tierList?.authorAccountName || authorAccountName.value
|
||||
favoriteCount.value = Number(res.tierList?.favoriteCount || favoriteCount.value || 0)
|
||||
isFavorited.value = !!res.tierList?.isFavorited
|
||||
isSaveModalOpen.value = true
|
||||
await persistTierList({ showModal: true })
|
||||
} catch (e) {
|
||||
error.value = '저장 실패: 로그인 상태인지 확인해주세요.'
|
||||
} finally {
|
||||
@@ -425,6 +469,14 @@ function closeSaveModal() {
|
||||
isSaveModalOpen.value = false
|
||||
}
|
||||
|
||||
function openTemplateRequestModal() {
|
||||
isTemplateRequestModalOpen.value = true
|
||||
}
|
||||
|
||||
function closeTemplateRequestModal() {
|
||||
isTemplateRequestModalOpen.value = false
|
||||
}
|
||||
|
||||
async function removeTierList() {
|
||||
if (!canEdit.value || isNewTierList.value) return
|
||||
error.value = ''
|
||||
@@ -454,6 +506,41 @@ async function toggleFavorite() {
|
||||
}
|
||||
}
|
||||
|
||||
async function requestTemplate(type) {
|
||||
if (isNewTierList.value) {
|
||||
toast.error('요청 전에 먼저 티어표를 저장해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
isRequestingTemplate.value = true
|
||||
await persistTierList({ showModal: false })
|
||||
await api.requestTierListTemplate(tierListId.value, { type })
|
||||
if (type === 'create') closeTemplateRequestModal()
|
||||
toast.success(type === 'create' ? '템플릿 등록 요청을 보냈어요.' : '템플릿 업데이트 요청을 보냈어요.')
|
||||
} catch (e) {
|
||||
if (e?.status === 400 && e?.data?.error === 'title_required') {
|
||||
toast.error('템플릿 등록 요청 전에는 티어표 이름을 직접 입력해주세요.')
|
||||
return
|
||||
}
|
||||
if (e?.status === 409) {
|
||||
toast.error('이미 처리 대기 중인 같은 요청이 있어요.')
|
||||
return
|
||||
}
|
||||
if (e?.status === 400 && e?.data?.error === 'board_must_be_empty') {
|
||||
toast.error('템플릿 등록 요청은 보드를 비운 상태에서만 보낼 수 있어요.')
|
||||
return
|
||||
}
|
||||
if (e?.status === 400 && e?.data?.error === 'custom_items_required') {
|
||||
toast.error('먼저 커스텀 아이템을 추가한 뒤 요청해주세요.')
|
||||
return
|
||||
}
|
||||
toast.error(type === 'create' ? '템플릿 등록 요청에 실패했어요.' : '템플릿 업데이트 요청에 실패했어요.')
|
||||
} finally {
|
||||
isRequestingTemplate.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
;(async () => {
|
||||
await auth.refresh()
|
||||
@@ -569,6 +656,22 @@ onUnmounted(() => {
|
||||
<button v-if="canFavorite" class="btn btn--ghost" :disabled="isFavoriteBusy" @click="toggleFavorite">
|
||||
{{ isFavorited ? '★ 즐겨찾기' : '☆ 즐겨찾기' }} {{ favoriteCount }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canRequestTemplateCreate"
|
||||
class="btn btn--ghost"
|
||||
:disabled="isRequestingTemplate"
|
||||
@click="openTemplateRequestModal"
|
||||
>
|
||||
템플릿 등록 요청
|
||||
</button>
|
||||
<button
|
||||
v-if="canRequestTemplateUpdate"
|
||||
class="btn btn--ghost"
|
||||
:disabled="isRequestingTemplate"
|
||||
@click="requestTemplate('update')"
|
||||
>
|
||||
{{ isRequestingTemplate ? '요청중...' : '템플릿 업데이트 요청' }}
|
||||
</button>
|
||||
<label class="toggle" :class="{ 'toggle--disabled': !canEdit }">
|
||||
<input v-model="isPublic" type="checkbox" :disabled="!canEdit" />
|
||||
<span>{{ isPublic ? '공개 ON' : '공개 OFF' }}</span>
|
||||
@@ -588,6 +691,35 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isTemplateRequestModalOpen" class="modalOverlay" @click.self="closeTemplateRequestModal">
|
||||
<div class="modalCard" role="dialog" aria-modal="true" aria-labelledby="templateRequestTitle">
|
||||
<div id="templateRequestTitle" class="modalCard__title">템플릿 등록 요청</div>
|
||||
<div class="modalCard__desc">
|
||||
여러 사용자가 비슷한 주제로 요청할 수 있으니, 관리자에게 전달되기 전에 아래 조건을 먼저 확인해주세요.
|
||||
</div>
|
||||
<div class="requestChecklist">
|
||||
<div
|
||||
v-for="check in templateRequestChecks"
|
||||
:key="check.id"
|
||||
class="requestChecklist__item"
|
||||
:class="{ 'requestChecklist__item--passed': check.passed }"
|
||||
>
|
||||
<span class="requestChecklist__icon">{{ check.passed ? '완료' : '확인 필요' }}</span>
|
||||
<span>{{ check.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="requestChecklist__hint">
|
||||
제목이 명확하고, 보드는 비워둔 채 원본 아이템만 정리되어 있을수록 관리자가 새 게임 템플릿으로 빠르게 등록하기 쉬워져요.
|
||||
</div>
|
||||
<div class="modalCard__actions">
|
||||
<button class="btn btn--ghost" @click="closeTemplateRequestModal">취소</button>
|
||||
<button class="btn btn--save" :disabled="!canSubmitTemplateCreateRequest || isRequestingTemplate" @click="requestTemplate('create')">
|
||||
{{ isRequestingTemplate ? '요청중...' : '등록 요청 보내기' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="layout" :style="{ '--thumb-size': `${iconSize}px` }">
|
||||
<div ref="boardEl" class="board">
|
||||
<div v-if="canEdit && !isExporting" class="boardTools">
|
||||
@@ -665,6 +797,24 @@ onUnmounted(() => {
|
||||
<div class="poolItem__label">{{ itemsById[id]?.label || id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="canEdit && customItems.length" class="customItemEditor">
|
||||
<div class="customItemEditor__title">추가한 커스텀 아이템 이름 정리</div>
|
||||
<div class="customItemEditor__desc">
|
||||
템플릿 요청 전에 이름을 정리해두면 관리자가 그대로 기본 템플릿으로 반영할 수 있어요.
|
||||
</div>
|
||||
<div class="customItemEditor__list">
|
||||
<label v-for="item in customItems" :key="item.id" class="customItemEditor__row">
|
||||
<img class="customItemEditor__thumb" :src="resolveItemSrc(item)" :alt="item.label" />
|
||||
<input
|
||||
class="customItemEditor__input"
|
||||
:value="item.label"
|
||||
maxlength="60"
|
||||
placeholder="아이템 이름"
|
||||
@input="updateCustomItemLabel(item.id, $event.target.value)"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="canEdit"
|
||||
class="dropzone"
|
||||
@@ -928,6 +1078,36 @@ onUnmounted(() => {
|
||||
justify-content: flex-end;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.requestChecklist {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.requestChecklist__item {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(251, 191, 36, 0.22);
|
||||
background: rgba(251, 191, 36, 0.08);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.requestChecklist__item--passed {
|
||||
border-color: rgba(52, 211, 153, 0.24);
|
||||
background: rgba(52, 211, 153, 0.1);
|
||||
}
|
||||
.requestChecklist__icon {
|
||||
flex: 0 0 auto;
|
||||
min-width: 56px;
|
||||
font-size: 12px;
|
||||
font-weight: 900;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.requestChecklist__hint {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
opacity: 0.78;
|
||||
}
|
||||
.boardTools {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
@@ -1144,6 +1324,51 @@ onUnmounted(() => {
|
||||
font-size: 13px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.customItemEditor {
|
||||
margin-top: 12px;
|
||||
padding: 12px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
}
|
||||
.customItemEditor__title {
|
||||
font-weight: 900;
|
||||
}
|
||||
.customItemEditor__desc {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
opacity: 0.72;
|
||||
}
|
||||
.customItemEditor__list {
|
||||
margin-top: 12px;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.customItemEditor__row {
|
||||
display: grid;
|
||||
grid-template-columns: 44px minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
.customItemEditor__thumb {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 10px;
|
||||
object-fit: cover;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
}
|
||||
.customItemEditor__input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 9px 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
color: rgba(255, 255, 255, 0.92);
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.dropzone {
|
||||
margin-top: 12px;
|
||||
padding: 14px;
|
||||
|
||||
Reference in New Issue
Block a user