Files
web-temp/layers/composables/useGameDataLoader.ts
clkim 53aee6963b refactor. 게임 데이터 로딩 및 언어 전환 로직 개선
- LanguageSwitcher.vue에서 setLocale 및 gameData 로딩 로직 통합
- useGameDataLoader.ts 추가로 게임 데이터 로딩 기능 구현
- init.route.global.ts에서 초기화 로직 개선 및 중복 호출 방지
- useGameDataStore.ts에 currentLangCode 상태 추가 및 설정 함수 구현

Made-with: Cursor
2026-03-20 18:07:04 +09:00

32 lines
907 B
TypeScript

import type { GameDataResponse } from '#layers/types/api/gameData'
import { getGameDomain } from '#layers/utils/urlUtil'
export const useGameDataLoader = () => {
const runtimeConfig = useRuntimeConfig()
const gameDataStore = useGameDataStore()
const loadGameData = async (langCode: string) => {
const normalizedLangCode = `${langCode}`.toLowerCase()
const stoveApiBaseUrl = runtimeConfig.public.stoveApiUrl
const gameDomain = getGameDomain()
const response = await $fetch<GameDataResponse>(
`${stoveApiBaseUrl}/pub-comm/v1.0/template/game`,
{
query: {
game_domain: gameDomain || '',
lang_code: normalizedLangCode,
},
}
)
if (response?.code === 0 && 'value' in response) {
gameDataStore.setGameData(response.value)
gameDataStore.setCurrentLangCode(normalizedLangCode)
}
}
return { loadGameData }
}