릴리스: v1.4.21 프런트 topic 응답 소비 정리
This commit is contained in:
@@ -169,27 +169,28 @@ export function useAdminGameManager({
|
||||
if (!res.ok) throw new Error('failed')
|
||||
|
||||
const data = await res.json()
|
||||
const createdTemplate = data.template || data.game || {}
|
||||
if (activeTemplateRequest.value?.type === 'create' && activeTemplateRequest.value?.id) {
|
||||
const linkData = await api.linkAdminTemplateRequestGame(activeTemplateRequest.value.id, {
|
||||
gameId: data.game.id,
|
||||
gameId: createdTemplate.id,
|
||||
})
|
||||
activeTemplateRequest.value = {
|
||||
...activeTemplateRequest.value,
|
||||
targetGameId: linkData.request?.targetGameId || data.game.id,
|
||||
targetGameName: linkData.request?.targetGameName || data.game.name || nextGameName,
|
||||
targetGameId: linkData.request?.targetGameId || createdTemplate.id,
|
||||
targetGameName: linkData.request?.targetGameName || createdTemplate.name || nextGameName,
|
||||
}
|
||||
const requestIndex = templateRequests.value.findIndex((entry) => entry.id === activeTemplateRequest.value.id)
|
||||
if (requestIndex >= 0) {
|
||||
templateRequests.value.splice(requestIndex, 1, {
|
||||
...templateRequests.value[requestIndex],
|
||||
targetGameId: linkData.request?.targetGameId || data.game.id,
|
||||
targetGameName: linkData.request?.targetGameName || data.game.name || nextGameName,
|
||||
targetGameId: linkData.request?.targetGameId || createdTemplate.id,
|
||||
targetGameName: linkData.request?.targetGameName || createdTemplate.name || nextGameName,
|
||||
})
|
||||
}
|
||||
}
|
||||
await refreshTemplates()
|
||||
selectedTemplateId.value = data.game.id
|
||||
if (customItemModalOpen.value) customItemModalTargetTemplateId.value = data.game.id
|
||||
selectedTemplateId.value = createdTemplate.id
|
||||
if (customItemModalOpen.value) customItemModalTargetTemplateId.value = createdTemplate.id
|
||||
closeTemplateCreateModal()
|
||||
await loadTemplate({ preserveUploadState })
|
||||
if (!preserveUploadState && activeTemplateRequest.value?.id) {
|
||||
|
||||
@@ -1173,15 +1173,16 @@ async function saveTemplateVisibility() {
|
||||
const data = await api.updateAdminTemplate(selectedTemplate.value.game.id, {
|
||||
isPublic: !!selectedTemplate.value.game.isPublic,
|
||||
})
|
||||
const nextTemplate = data.template || data.game || {}
|
||||
selectedTemplate.value = {
|
||||
...selectedTemplate.value,
|
||||
game: {
|
||||
...selectedTemplate.value.game,
|
||||
...data.game,
|
||||
...nextTemplate,
|
||||
},
|
||||
}
|
||||
await refreshTemplates()
|
||||
success.value = data.game?.isPublic ? '템플릿을 공개 상태로 전환했어요.' : '템플릿을 비공개 상태로 전환했어요.'
|
||||
success.value = nextTemplate?.isPublic ? '템플릿을 공개 상태로 전환했어요.' : '템플릿을 비공개 상태로 전환했어요.'
|
||||
return true
|
||||
} catch (e) {
|
||||
error.value = '템플릿 공개 상태를 저장하지 못했어요.'
|
||||
|
||||
@@ -48,7 +48,7 @@ async function loadFavorites() {
|
||||
}
|
||||
|
||||
function openTierList(tierList) {
|
||||
router.push(editorPath(tierList.gameId, tierList.id))
|
||||
router.push(editorPath(tierList.topicId || tierList.gameId, tierList.id))
|
||||
}
|
||||
|
||||
onMounted(loadFavorites)
|
||||
|
||||
@@ -53,11 +53,11 @@ function handleThumbnailError(tierListId) {
|
||||
async function loadTierLists() {
|
||||
isTopicLoading.value = true
|
||||
try {
|
||||
const [gameRes, listRes] = await Promise.all([
|
||||
const [topicRes, listRes] = await Promise.all([
|
||||
api.getTopic(topicId.value),
|
||||
api.searchPublicTierListsByTopic(topicId.value, query.value),
|
||||
])
|
||||
topicName.value = gameRes.game?.name || ''
|
||||
topicName.value = topicRes.topic?.name || topicRes.game?.name || ''
|
||||
brokenThumbnailIds.value = {}
|
||||
tierLists.value = listRes.tierLists || []
|
||||
} catch (e) {
|
||||
|
||||
@@ -37,7 +37,7 @@ const templates = computed(() => {
|
||||
async function loadTemplates() {
|
||||
try {
|
||||
const data = await api.listTopics()
|
||||
templateRecords.value = data.games || []
|
||||
templateRecords.value = data.topics || data.games || []
|
||||
} catch (e) {
|
||||
error.value = '백엔드에 연결할 수 없어요. backend 서버가 실행 중인지 확인해주세요.'
|
||||
}
|
||||
@@ -61,7 +61,7 @@ async function toggleFavorite(template, event) {
|
||||
try {
|
||||
loadingFavoriteId.value = template.id
|
||||
const res = template.isFavorited ? await api.unfavoriteTopic(template.id) : await api.favoriteTopic(template.id)
|
||||
templateRecords.value = templateRecords.value.map((entry) => (entry.id === template.id ? { ...entry, ...res.game } : entry))
|
||||
templateRecords.value = templateRecords.value.map((entry) => (entry.id === template.id ? { ...entry, ...(res.topic || res.game || {}) } : entry))
|
||||
} catch (e) {
|
||||
error.value = '즐겨찾기 변경에 실패했어요.'
|
||||
} finally {
|
||||
|
||||
@@ -60,7 +60,7 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
function openList(t) {
|
||||
router.push(editorPath(t.gameId, t.id))
|
||||
router.push(editorPath(t.topicId || t.gameId, t.id))
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ function tierListThumbnailUrl(tierList) {
|
||||
}
|
||||
|
||||
function openTierList(tierList) {
|
||||
router.push(editorPath(tierList.gameId, tierList.id))
|
||||
router.push(editorPath(tierList.topicId || tierList.gameId, tierList.id))
|
||||
}
|
||||
|
||||
async function loadResults() {
|
||||
|
||||
@@ -898,9 +898,9 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
try {
|
||||
const gameRes = await api.getTopic(templateId.value)
|
||||
templateName.value = gameRes.game?.name || templateId.value
|
||||
const base = (gameRes.items || []).map((img) => ({
|
||||
const topicRes = await api.getTopic(templateId.value)
|
||||
templateName.value = topicRes.topic?.name || topicRes.game?.name || templateId.value
|
||||
const base = (topicRes.items || []).map((img) => ({
|
||||
id: img.id,
|
||||
src: img.src,
|
||||
label: img.label,
|
||||
|
||||
Reference in New Issue
Block a user